|
Teuchos Package Browser (Single Doxygen Collection) Version of the Day
|
00001 // @HEADER 00002 // *********************************************************************** 00003 // 00004 // Teuchos: Common Tools Package 00005 // Copyright (2004) Sandia Corporation 00006 // 00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00008 // license for use of this work by or on behalf of the U.S. Government. 00009 // 00010 // This library is free software; you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as 00012 // published by the Free Software Foundation; either version 2.1 of the 00013 // License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00023 // USA 00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00025 // 00026 // *********************************************************************** 00027 // @HEADER 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 // The above variable is Intialized below in order so that if exceptions are 00068 // thrown then they will be caught in main()! 00069 00070 00071 } // namespace 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 }
1.7.4