42#include "Teuchos_VerboseObjectParameterListHelpers.hpp"
43#include "Teuchos_StandardParameterEntryValidators.hpp"
49const std::string VerboseObject_name =
"VerboseObject";
51const std::string OutputFile_name =
"Output File";
52const std::string OutputFile_default =
"none";
54const std::string VerbosityLevel_name =
"Verbosity Level";
55const std::string VerbosityLevel_default =
"default";
59VerbosityLevel_validator;
67Teuchos::getValidVerboseObjectSublist()
69 using Teuchos::rcp_implicit_cast;
70 static RCP<const ParameterList> validParams;
73 pl =
rcp(
new ParameterList(VerboseObject_name));
74 VerbosityLevel_validator = verbosityLevelParameterEntryValidator(VerbosityLevel_name);
76 VerbosityLevel_name, VerbosityLevel_default,
77 "The verbosity level to use to override whatever is set in code.\n"
78 "The value of \"default\" will allow the level set in code to be used.",
79 rcp_implicit_cast<const ParameterEntryValidator>(VerbosityLevel_validator)
82 OutputFile_name, OutputFile_default,
83 "The file to send output to. If the value \"none\" is used, then\n"
84 "whatever is set in code will be used. However, any other std::string value\n"
85 "will be used to create an std::ofstream object to a file with the given name.\n"
86 "Therefore, any valid file name is a valid std::string value for this parameter."
94void Teuchos::setupVerboseObjectSublist( ParameterList* paramList )
97 paramList->sublist(VerboseObject_name).setParameters(
98 *getValidVerboseObjectSublist()
99 ).disableRecursiveValidation();
103void Teuchos::readVerboseObjectSublist(
104 ParameterList* paramList,
105 RCP<FancyOStream> *oStream, EVerbosityLevel *verbLevel
113 &voSublist = paramList->sublist(VerboseObject_name);
114 voSublist.validateParameters(*getValidVerboseObjectSublist());
116 outputFileStr = voSublist.get(OutputFile_name,OutputFile_default);
117 *verbLevel = VerbosityLevel_validator->getIntegralValue(
118 voSublist,VerbosityLevel_name,VerbosityLevel_default
121 if (outputFileStr==OutputFile_default) {
162 *oStream = Teuchos::fancyOStream(Teuchos::rcpFromRef(std::cout));
165 const int outputFileMPIRank = 0;
167 #if defined(HAVE_TEUCHOS_MPI)
170 const int rank = outputFileMPIRank;
173 if ( rank == outputFileMPIRank) {
174 RCP<std::ofstream> oFileStream =
rcp(
new std::ofstream());
179 oFileStream->open(outputFileStr);
182 oFileStream->eof(), Exceptions::InvalidParameterValue,
183 "Error, the file \"" << outputFileStr <<
"\n given by the parameter\n"
184 "\'" << OutputFile_name <<
"\' in the sublist\n"
185 "\'" << voSublist.name() <<
"\' count not be opened for output!"
188 *oStream = fancyOStream(rcp_implicit_cast<std::ostream>(oFileStream));
191 #if defined(HAVE_TEUCHOS_MPI)
193 (*oStream)->setOutputToRootOnly(outputFileMPIRank);
197 voSublist.validateParameters(*getValidVerboseObjectSublist());
static int getRank()
The rank of the calling process in MPI_COMM_WORLD.
Smart reference counting pointer class for automatic garbage collection.
#define TEUCHOS_TEST_FOR_EXCEPTION_PURE_MSG(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
This macro is designed to be a short version of TEUCHOS_TEST_FOR_EXCEPTION() that is easier to call.
bool is_null(const boost::shared_ptr< T > &p)
Returns true if p.get()==NULL.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.