Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
Teuchos_VerbosityLevelCommandLineProcessorHelpers.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_VerbosityLevelCommandLineProcessorHelpers.hpp"
12#include "Teuchos_Array.hpp"
13#include "Teuchos_Assert.hpp"
14#include "Teuchos_implicit_cast.hpp"
15
16
17namespace {
18
19
20using Teuchos::Array;
21using Teuchos::tuple;
22
23
24const Array<Teuchos::EVerbosityLevel>
25verbosityLevelValues = tuple<Teuchos::EVerbosityLevel>(
32 );
33
34
35const Array<std::string>
36verbosityLevelNamesStorage = tuple<std::string>(
37 toString(Teuchos::VERB_DEFAULT),
38 toString(Teuchos::VERB_NONE),
39 toString(Teuchos::VERB_LOW),
40 toString(Teuchos::VERB_MEDIUM),
41 toString(Teuchos::VERB_HIGH),
42 toString(Teuchos::VERB_EXTREME)
43 );
44
45
46Array<const char*> verbosityLevelNames;
47// The above variable is Intialized below in order so that if exceptions are
48// thrown then they will be caught in main()!
49
50
51} // namespace
52
53
54void Teuchos::setVerbosityLevelOption(
55 const std::string &optionName,
56 EVerbosityLevel *verbLevel,
57 const std::string &docString,
58 CommandLineProcessor *clp,
59 const bool required
60 )
61{
62 const int numVerbLevels = implicit_cast<int>(verbosityLevelValues.size());
63
64 if ( !verbosityLevelNames.size() ) {
65 verbosityLevelNames = tuple<const char*>(
66 verbosityLevelNamesStorage[0].c_str(),
67 verbosityLevelNamesStorage[1].c_str(),
68 verbosityLevelNamesStorage[2].c_str(),
69 verbosityLevelNamesStorage[3].c_str(),
70 verbosityLevelNamesStorage[4].c_str(),
71 verbosityLevelNamesStorage[5].c_str()
72 );
73 }
74
75#ifdef TEUCHOS_DEBUG
76 TEUCHOS_ASSERT( optionName.length() );
77 TEUCHOS_ASSERT( verbLevel );
78 TEUCHOS_ASSERT( clp );
79 TEUCHOS_ASSERT( implicit_cast<int>(verbosityLevelNamesStorage.size()) == numVerbLevels );
80 TEUCHOS_ASSERT( implicit_cast<int>(verbosityLevelNames.size()) == numVerbLevels );
81#endif
82 clp->setOption(
83 optionName.c_str(), verbLevel,
84 numVerbLevels, &verbosityLevelValues[0], &verbosityLevelNames[0],
85 docString.c_str(), required
86 );
87}
Templated array class derived from the STL std::vector.
Basic command line parser for input from (argc,argv[])
Replacement for std::vector that is compatible with the Teuchos Memory Management classes.
#define TEUCHOS_ASSERT(assertion_test)
This macro is throws when an assert fails.
@ VERB_MEDIUM
Generate more output.
@ VERB_HIGH
Generate a high level of output.
@ VERB_EXTREME
Generate the most output possible.
@ VERB_NONE
Generate no output.
@ VERB_DEFAULT
Generate output as defined by the object.
@ VERB_LOW
Generate only a minimal amount of output.