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 #include "Teuchos_VerbosityLevel.hpp" 00030 #include "Teuchos_Array.hpp" 00031 #include "Teuchos_as.hpp" 00032 00033 00034 namespace { 00035 00036 00037 const Teuchos::Array<Teuchos::EVerbosityLevel> 00038 verbLevelArray = Teuchos::tuple<Teuchos::EVerbosityLevel>( 00039 Teuchos::VERB_NONE, 00040 Teuchos::VERB_LOW, 00041 Teuchos::VERB_MEDIUM, 00042 Teuchos::VERB_HIGH, 00043 Teuchos::VERB_EXTREME 00044 ); 00045 00046 00047 } // namespace 00048 00049 00050 00051 std::string Teuchos::toString(const EVerbosityLevel verbLevel) 00052 { 00053 switch(verbLevel) { 00054 case VERB_DEFAULT: 00055 return "VERB_DEFAULT"; 00056 case VERB_NONE: 00057 return "VERB_NONE"; 00058 case VERB_LOW: 00059 return "VERB_LOW"; 00060 case VERB_MEDIUM: 00061 return "VERB_MEDIUM"; 00062 case VERB_HIGH: 00063 return "VERB_HIGH"; 00064 case VERB_EXTREME: 00065 return "VERB_EXTREME"; 00066 default: 00067 TEST_FOR_EXCEPT("Should never get here!"); 00068 } 00069 return ""; // Never get here! 00070 } 00071 00072 00073 bool Teuchos::includesVerbLevel( 00074 const EVerbosityLevel verbLevel, 00075 const EVerbosityLevel requestedVerbLevel, 00076 const bool isDefaultLevel 00077 ) 00078 { 00079 return ( 00080 ( as<int>(verbLevel) >= as<int>(requestedVerbLevel) ) 00081 || 00082 ( verbLevel == VERB_DEFAULT && isDefaultLevel ) 00083 ); 00084 } 00085 00086 00087 Teuchos::EVerbosityLevel 00088 Teuchos::incrVerbLevel( 00089 const EVerbosityLevel inputVerbLevel, 00090 const int numLevels 00091 ) 00092 { 00093 if (inputVerbLevel == VERB_DEFAULT) 00094 return VERB_DEFAULT; 00095 if (inputVerbLevel == VERB_EXTREME) 00096 return VERB_EXTREME; 00097 const int intVerbLevel = as<int>(inputVerbLevel) + numLevels; 00098 if (intVerbLevel < as<int>(VERB_NONE)) 00099 return VERB_NONE; 00100 else if (intVerbLevel > as<int>(VERB_EXTREME)) 00101 return VERB_EXTREME; 00102 // If we get here, then intVerbLevel is a valid verbosity level. 00103 return verbLevelArray[intVerbLevel]; 00104 }