Teuchos_VerbosityLevelCommandLineProcessorHelpers.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "Teuchos_VerbosityLevelCommandLineProcessorHelpers.hpp"
00031 #include "Teuchos_CommandLineProcessor.hpp"
00032 #include "Teuchos_Array.hpp"
00033 #include "Teuchos_Assert.hpp"
00034 #include "Teuchos_implicit_cast.hpp"
00035
00036
00037 namespace {
00038
00039
00040 using Teuchos::Array;
00041 using Teuchos::tuple;
00042
00043
00044 const Array<Teuchos::EVerbosityLevel>
00045 verbosityLevelValues = tuple<Teuchos::EVerbosityLevel>(
00046 Teuchos::VERB_DEFAULT,
00047 Teuchos::VERB_NONE,
00048 Teuchos::VERB_LOW,
00049 Teuchos::VERB_MEDIUM,
00050 Teuchos::VERB_HIGH,
00051 Teuchos::VERB_EXTREME
00052 );
00053
00054
00055 const Array<std::string>
00056 verbosityLevelNamesStorage = tuple<std::string>(
00057 toString(Teuchos::VERB_DEFAULT),
00058 toString(Teuchos::VERB_NONE),
00059 toString(Teuchos::VERB_LOW),
00060 toString(Teuchos::VERB_MEDIUM),
00061 toString(Teuchos::VERB_HIGH),
00062 toString(Teuchos::VERB_EXTREME)
00063 );
00064
00065
00066 Array<const char*> verbosityLevelNames;
00067
00068
00069
00070
00071 }
00072
00073
00074 void Teuchos::setVerbosityLevelOption(
00075 const std::string &optionName,
00076 EVerbosityLevel *verbLevel,
00077 const std::string &docString,
00078 CommandLineProcessor *clp,
00079 const bool required
00080 )
00081 {
00082 const int numVerbLevels = verbosityLevelValues.size();
00083
00084 if ( !verbosityLevelNames.size() ) {
00085 verbosityLevelNames = tuple<const char*>(
00086 verbosityLevelNamesStorage[0].c_str(),
00087 verbosityLevelNamesStorage[1].c_str(),
00088 verbosityLevelNamesStorage[2].c_str(),
00089 verbosityLevelNamesStorage[3].c_str(),
00090 verbosityLevelNamesStorage[4].c_str(),
00091 verbosityLevelNamesStorage[5].c_str()
00092 );
00093 }
00094
00095 #ifdef TEUCHOS_DEBUG
00096 TEUCHOS_ASSERT( optionName.length() );
00097 TEUCHOS_ASSERT( verbLevel );
00098 TEUCHOS_ASSERT( clp );
00099 TEUCHOS_ASSERT( implicit_cast<int>(verbosityLevelNamesStorage.size()) == numVerbLevels );
00100 TEUCHOS_ASSERT( implicit_cast<int>(verbosityLevelNames.size()) == numVerbLevels );
00101 #endif
00102 clp->setOption(
00103 optionName.c_str(), verbLevel,
00104 numVerbLevels, &verbosityLevelValues[0], &verbosityLevelNames[0],
00105 docString.c_str(), required
00106 );
00107 }