Teuchos - Trilinos Tools Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_VerbosityLevel.cpp
1 // @HEADER
2 // *****************************************************************************
3 // Teuchos: Common Tools Package
4 //
5 // Copyright 2004 NTESS and the Teuchos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
11 #include "Teuchos_Tuple.hpp"
12 #include "Teuchos_as.hpp"
13 
14 
16 {
18  verbLevelArray = tuple<Teuchos::EVerbosityLevel>(
25  );
26  return verbLevelArray();
27 }
28 
29 
31 {
33  verbLevelNamesArray = tuple<std::string>(
34  "VERB_DEFAULT",
35  "VERB_NONE",
36  "VERB_LOW",
37  "VERB_MEDIUM",
38  "VERB_HIGH",
39  "VERB_EXTREME"
40  );
41  return verbLevelNamesArray();
42 }
43 
44 
46 {
49  verbLevelNamesRawStringsArray;
50  for (int i = 0; i < EVerbosityLevel_size; ++i) {
51  verbLevelNamesRawStringsArray[i] = verbLevelNamesArray[i].c_str();
52  }
53  return verbLevelNamesRawStringsArray();
54 }
55 
56 
57 std::string Teuchos::toString(const EVerbosityLevel verbLevel)
58 {
59  switch (verbLevel) {
60  case VERB_DEFAULT:
61  return "VERB_DEFAULT";
62  case VERB_NONE:
63  return "VERB_NONE";
64  case VERB_LOW:
65  return "VERB_LOW";
66  case VERB_MEDIUM:
67  return "VERB_MEDIUM";
68  case VERB_HIGH:
69  return "VERB_HIGH";
70  case VERB_EXTREME:
71  return "VERB_EXTREME";
72  default:
74  true, std::invalid_argument, "Teuchos::toString(const Teuchos::"
75  "EVerbosityLevel): Input argument " << verbLevel << " has an invalid "
76  "value. Valid values are VERB_DEFAULT=" << VERB_DEFAULT << ", VERB_NONE"
77  "=" << VERB_NONE << ", VERB_LOW=" << VERB_LOW << ", VERB_MEDIUM="
78  << VERB_MEDIUM << ", VERB_HIGH=" << VERB_HIGH << ", AND VERB_EXTREME="
79  << VERB_EXTREME << ".");
80  }
81 
82  // NOTE (mfh 15 Sep 2014): Most compilers have figured out that the
83  // return statement below is unreachable. Some older compilers
84  // might not realize this. That's why the return statement was put
85  // there, so that those compilers don't warn that this function
86  // doesn't return a value. If it's a choice between one warning and
87  // another, I would prefer the choice that produces less code and
88  // doesn't have unreachable code (which never gets tested).
89 
90  //return ""; // Never get here!
91 }
92 
93 
95  const EVerbosityLevel verbLevel,
96  const EVerbosityLevel requestedVerbLevel,
97  const bool isDefaultLevel
98  )
99 {
100  return (
101  ( as<int>(verbLevel) >= as<int>(requestedVerbLevel) )
102  ||
103  ( verbLevel == VERB_DEFAULT && isDefaultLevel )
104  );
105 }
106 
107 
110  const EVerbosityLevel inputVerbLevel,
111  const int numLevels
112  )
113 {
114  if (inputVerbLevel == VERB_DEFAULT)
115  return VERB_DEFAULT;
116  if (inputVerbLevel == VERB_EXTREME)
117  return VERB_EXTREME;
118  const int intVerbLevel = as<int>(inputVerbLevel) + numLevels;
119  if (intVerbLevel < as<int>(VERB_NONE))
120  return VERB_NONE;
121  else if (intVerbLevel > as<int>(VERB_EXTREME))
122  return VERB_EXTREME;
123  // If we get here, then intVerbLevel is a valid verbosity level.
124  return getValidVerbLevels()[intVerbLevel];
125 }
Generate output as defined by the object.
Generate only a minimal amount of output.
Generate no output.
constexpr const int EVerbosityLevel_size
TEUCHOSCORE_LIB_DLL_EXPORT ArrayView< const EVerbosityLevel > getValidVerbLevels()
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
Generate the most output possible.
EVerbosityLevel
Verbosity level.
Generate more output.
Statically sized simple array (tuple) class.
Generate a high level of output.
TEUCHOSCORE_LIB_DLL_EXPORT ArrayView< const char *const > getValidVerbLevelsNamesRawStrings()
TEUCHOSCORE_LIB_DLL_EXPORT ArrayView< const std::string > getValidVerbLevelsNames()
TEUCHOSCORE_LIB_DLL_EXPORT bool includesVerbLevel(const EVerbosityLevel verbLevel, const EVerbosityLevel requestedVerbLevel, const bool isDefaultLevel=false)
Return true if the verbosity level includes the given level.
TEUCHOSCORE_LIB_DLL_EXPORT EVerbosityLevel incrVerbLevel(const EVerbosityLevel inputVerbLevel, const int numLevels)
Return an increased or decreased verbosity level.
Nonowning array view.
Definition of Teuchos::as, for conversions between types.