10#include "Teuchos_VerboseObjectParameterListHelpers.hpp" 
   11#include "Teuchos_StandardParameterEntryValidators.hpp" 
   17const std::string VerboseObject_name = 
"VerboseObject";
 
   19const std::string OutputFile_name = 
"Output File";
 
   20const std::string OutputFile_default = 
"none";
 
   22const std::string VerbosityLevel_name = 
"Verbosity Level";
 
   23const std::string  VerbosityLevel_default = 
"default";
 
   27VerbosityLevel_validator;
 
   35Teuchos::getValidVerboseObjectSublist()
 
   37  using Teuchos::rcp_implicit_cast;
 
   38  static RCP<const ParameterList> validParams;
 
   39  if (is_null(validParams)) {
 
   41      pl = 
rcp(
new ParameterList(VerboseObject_name));
 
   42    VerbosityLevel_validator = verbosityLevelParameterEntryValidator(VerbosityLevel_name);
 
   44      VerbosityLevel_name, VerbosityLevel_default,
 
   45      "The verbosity level to use to override whatever is set in code.\n" 
   46      "The value of \"default\" will allow the level set in code to be used.",
 
   47      rcp_implicit_cast<const ParameterEntryValidator>(VerbosityLevel_validator)
 
   50      OutputFile_name, OutputFile_default,
 
   51      "The file to send output to.  If the value \"none\" is used, then\n" 
   52      "whatever is set in code will be used.  However, any other std::string value\n" 
   53      "will be used to create an std::ofstream object to a file with the given name.\n" 
   54      "Therefore, any valid file name is a valid std::string value for this parameter." 
   62void Teuchos::setupVerboseObjectSublist( ParameterList* paramList )
 
   65  paramList->sublist(VerboseObject_name).setParameters(
 
   66    *getValidVerboseObjectSublist()
 
   67    ).disableRecursiveValidation();
 
   71void Teuchos::readVerboseObjectSublist(
 
   72  ParameterList* paramList,
 
   73  RCP<FancyOStream> *oStream, EVerbosityLevel *verbLevel
 
   81    &voSublist = paramList->sublist(VerboseObject_name);
 
   82  voSublist.validateParameters(*getValidVerboseObjectSublist());
 
   84    outputFileStr = voSublist.get(OutputFile_name,OutputFile_default);
 
   85  *verbLevel = VerbosityLevel_validator->getIntegralValue(
 
   86    voSublist,VerbosityLevel_name,VerbosityLevel_default
 
   89  if (outputFileStr==OutputFile_default) {
 
  130    *oStream = Teuchos::fancyOStream(Teuchos::rcpFromRef(std::cout));
 
  133    const int outputFileMPIRank = 0;
 
  135    #if defined(HAVE_TEUCHOS_MPI) 
  138    const int rank = outputFileMPIRank;
 
  141    if ( rank  == outputFileMPIRank) {
 
  142      RCP<std::ofstream> oFileStream = 
rcp(
new std::ofstream());
 
  147      oFileStream->open(outputFileStr);
 
  150        oFileStream->eof(), Exceptions::InvalidParameterValue,
 
  151        "Error, the file \"" << outputFileStr << 
"\n given by the parameter\n" 
  152        "\'" << OutputFile_name << 
"\' in the sublist\n" 
  153        "\'" << voSublist.name() << 
"\' count not be opened for output!" 
  156      *oStream = fancyOStream(rcp_implicit_cast<std::ostream>(oFileStream));
 
  159    #if defined(HAVE_TEUCHOS_MPI) 
  161    (*oStream)->setOutputToRootOnly(outputFileMPIRank);
 
  165  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.
 
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.