Teuchos - Trilinos Tools Package
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
core
src
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
10
#include "
Teuchos_VerbosityLevel.hpp
"
11
#include "Teuchos_Tuple.hpp"
12
#include "
Teuchos_as.hpp
"
13
14
15
Teuchos::ArrayView<const Teuchos::EVerbosityLevel>
Teuchos::getValidVerbLevels
()
16
{
17
static
const
Tuple<Teuchos::EVerbosityLevel, EVerbosityLevel_size>
18
verbLevelArray =
tuple<Teuchos::EVerbosityLevel>
(
19
Teuchos::VERB_DEFAULT
,
20
Teuchos::VERB_NONE
,
21
Teuchos::VERB_LOW
,
22
Teuchos::VERB_MEDIUM
,
23
Teuchos::VERB_HIGH
,
24
Teuchos::VERB_EXTREME
25
);
26
return
verbLevelArray();
27
}
28
29
30
Teuchos::ArrayView<const std::string>
Teuchos::getValidVerbLevelsNames
()
31
{
32
static
const
Tuple<std::string, EVerbosityLevel_size>
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
45
Teuchos::ArrayView<const char * const>
Teuchos::getValidVerbLevelsNamesRawStrings
()
46
{
47
ArrayView<const std::string>
verbLevelNamesArray =
getValidVerbLevelsNames
();
48
static
const
Tuple<const char*, EVerbosityLevel_size>
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
:
73
TEUCHOS_TEST_FOR_EXCEPTION
(
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
94
bool
Teuchos::includesVerbLevel
(
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
108
Teuchos::EVerbosityLevel
109
Teuchos::incrVerbLevel
(
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
}
Teuchos_VerbosityLevel.hpp
Teuchos_as.hpp
Definition of Teuchos::as, for conversions between types.
Teuchos::ArrayView
Nonowning array view.
Definition
Teuchos_ArrayViewDecl.hpp:90
Teuchos::Tuple
Statically sized simple array (tuple) class.
Definition
Teuchos_Tuple.hpp:35
Teuchos::Tuple::tuple
Tuple< T, 1 > tuple(const T &a)
Create a Tuple<T,1>.
TEUCHOS_TEST_FOR_EXCEPTION
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
Definition
Teuchos_TestForException.hpp:146
Teuchos::as
TypeTo as(const TypeFrom &t)
Convert from one value type to another.
Definition
Teuchos_as.hpp:2808
Teuchos::getValidVerbLevels
TEUCHOSCORE_LIB_DLL_EXPORT ArrayView< const EVerbosityLevel > getValidVerbLevels()
Definition
Teuchos_VerbosityLevel.cpp:15
Teuchos::getValidVerbLevelsNamesRawStrings
TEUCHOSCORE_LIB_DLL_EXPORT ArrayView< const char *const > getValidVerbLevelsNamesRawStrings()
Definition
Teuchos_VerbosityLevel.cpp:45
Teuchos::getValidVerbLevelsNames
TEUCHOSCORE_LIB_DLL_EXPORT ArrayView< const std::string > getValidVerbLevelsNames()
Definition
Teuchos_VerbosityLevel.cpp:30
Teuchos::EVerbosityLevel
EVerbosityLevel
Verbosity level.
Definition
Teuchos_VerbosityLevel.hpp:31
Teuchos::VERB_MEDIUM
@ VERB_MEDIUM
Generate more output.
Definition
Teuchos_VerbosityLevel.hpp:35
Teuchos::VERB_HIGH
@ VERB_HIGH
Generate a high level of output.
Definition
Teuchos_VerbosityLevel.hpp:36
Teuchos::VERB_EXTREME
@ VERB_EXTREME
Generate the most output possible.
Definition
Teuchos_VerbosityLevel.hpp:37
Teuchos::VERB_NONE
@ VERB_NONE
Generate no output.
Definition
Teuchos_VerbosityLevel.hpp:33
Teuchos::VERB_DEFAULT
@ VERB_DEFAULT
Generate output as defined by the object.
Definition
Teuchos_VerbosityLevel.hpp:32
Teuchos::VERB_LOW
@ VERB_LOW
Generate only a minimal amount of output.
Definition
Teuchos_VerbosityLevel.hpp:34
Teuchos::includesVerbLevel
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.
Definition
Teuchos_VerbosityLevel.cpp:94
Teuchos::incrVerbLevel
TEUCHOSCORE_LIB_DLL_EXPORT EVerbosityLevel incrVerbLevel(const EVerbosityLevel inputVerbLevel, const int numLevels)
Return an increased or decreased verbosity level.
Definition
Teuchos_VerbosityLevel.cpp:109
Teuchos::EVerbosityLevel_size
constexpr const int EVerbosityLevel_size
Definition
Teuchos_VerbosityLevel.hpp:42
Generated by
1.17.0