94 <<
"\n***\n*** Printing to default OStream before main() even starts!\n***\n\n"
105 int main(
int argc,
char* argv[])
124 CommandLineProcessor clp;
125 clp.throwExceptions(
false);
126 clp.addOutputSetupOptions(
true);
127 CommandLineProcessor::EParseCommandLineReturn parse_return = clp.parse(argc,argv);
128 if( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL )
return parse_return;
132 out = VerboseObjectBase::getDefaultOStream();
144 *out <<
"\n***\n*** Testing VerboseObject base class use\n***\n";
146 *out <<
"\n*** Algorithm output with default formatting\n\n";
149 out->setShowAllFrontMatter(
false).setShowProcRank(numProcs>1);
150 *out <<
"\n*** Algorithm output with no front matter\n\n";
151 out->setShowAllFrontMatter(
false);
154 out->setShowAllFrontMatter(
false).setShowProcRank(numProcs>1);
155 *out <<
"\n*** Algorithm output with processor ranks\n\n";
156 out->setShowAllFrontMatter(
false).setShowProcRank(
true);
159 out->setShowAllFrontMatter(
false).setShowProcRank(numProcs>1);
160 *out <<
"\n*** Algorithm output with line prefix names\n\n";
161 out->setShowAllFrontMatter(
false).setShowLinePrefix(
true);
164 out->setShowAllFrontMatter(
false).setShowProcRank(numProcs>1);
165 *out <<
"\n*** Algorithm output with tab counts\n\n";
166 out->setShowAllFrontMatter(
false).setShowTabCount(
true);
169 out->setShowAllFrontMatter(
false).setShowProcRank(numProcs>1);
170 *out <<
"\n*** Algorithm output with line prefix names and tab counts\n\n";
171 out->setShowAllFrontMatter(
false).setShowLinePrefix(
true).setShowTabCount(
true);
174 out->setShowAllFrontMatter(
false).setShowProcRank(numProcs>1);
175 *out <<
"\n*** Algorithm output with processor ranks and line prefix names\n\n";
176 out->setShowAllFrontMatter(
false).setShowProcRank(
true).setShowLinePrefix(
true);
179 out->setShowAllFrontMatter(
false).setShowProcRank(numProcs>1);
180 *out <<
"\n*** Algorithm output with processor ranks and tab counts\n\n";
181 out->setShowAllFrontMatter(
false).setShowProcRank(
true).setShowTabCount(
true);
184 out->setShowAllFrontMatter(
false).setShowProcRank(numProcs>1);
185 *out <<
"\n*** Algorithm output with processor ranks, line prefix names, and tab counts\n\n";
186 out->setShowAllFrontMatter(
false).setShowProcRank(
true).setShowLinePrefix(
true).setShowTabCount(
true);
189 out->setShowAllFrontMatter(
false).setShowProcRank(numProcs>1);
190 *out <<
"\n*** Algorithm output with processor ranks, line prefix names, and tab counts but no output for AlgorithmA\n\n";
192 out->setShowAllFrontMatter(
false).setShowProcRank(
true).setShowLinePrefix(
true).setShowTabCount(
true);
196 *out <<
"\n*** Running the algorithm by setting parameters in the parameter list ...\n";
200 out->setShowAllFrontMatter(
false).setShowProcRank(numProcs>1);
201 *out <<
"\n*** Set AlgorithmA verbosity level to extreme through a parameter list\n\n";
202 algoParams.
sublist(
"VerboseObject").
set(
"Verbosity Level",
"extreme");
203 algoParams.
set(
"Algo Type",
"Harry");
204 algoParams.
set(
"Algo Tol",0.3);
207 out->setShowAllFrontMatter(
false).setShowProcRank(numProcs>1);
208 *out <<
"\n*** Set AlgorithmA verbosity level to medium and the output file \"AlgorithmA.out\" through a parameter list\n\n";
209 algoParams.
sublist(
"VerboseObject").
set(
"Verbosity Level",
"medium");
210 algoParams.
sublist(
"VerboseObject").
set(
"Output File",
"AlgorithmA.out");
211 algoParams.
set(
"Algo Type",
"John");
212 algoParams.
set(
"Algo Tol",10);
215 out->setShowAllFrontMatter(
false).setShowProcRank(numProcs>1);
216 *out <<
"\n*** Set AlgorithmA verbosity level to low and the output back to default through a parameter list\n\n";
217 algoParams.
sublist(
"VerboseObject").
set(
"Verbosity Level",
"low");
218 algoParams.
sublist(
"VerboseObject").
set(
"Output File",
"none");
219 algoParams.
set(
"Algo Tol",
"20");
222 out->setShowAllFrontMatter(
false).setShowProcRank(numProcs>1);
223 *out <<
"\n***\n*** Do some more simple tests to make sure things work correctly\n***\n\n";
230 out->setShowAllFrontMatter(
false).setShowProcRank(numProcs>1).setShowTabCount(
true);
233 *out <<
"\n***\n*** Testing basic FancyOStream and OSTab classes\n***\n\n";
235 *out <<
"\nThis is very good output\nand I like it a lot!\n";
238 *out <<
"This should";
240 *out <<
" printed on";
242 *out <<
" line two lines below the above output!\n";
247 *out <<
"This should be indented one tab!\n";
250 *out <<
"This should be indented two tabs!\n";
251 *out2 <<
"This should be indented zero tabs from out2!\n";
254 *out <<
"This should be indented two tabs!\n";
255 *out2 <<
"This should be indented one tab from out2!\n";
258 *out <<
"This should be indented one tab!\n";
260 *out <<
"This should be indented zero tabs!\n";
264 *out <<
"\n***\n*** Now outputting the latent output that was sent to out2\n***\n\n"
265 <<
dyn_cast<std::ostringstream>(*out2->getOStream()).str();
268 *out <<
"\nEnd Result: TEST PASSED" << std::endl;
273 return ( success ? 0 : 1 );
RCP< T > rcp(const boost::shared_ptr< T > &sptr)
Conversion function that takes in a boost::shared_ptr object and spits out a Teuchos::RCP object...
static int getRank()
The rank of the calling process in MPI_COMM_WORLD.
EVerbosityLevel
Verbosity level.
void setParameterList(Teuchos::RCP< Teuchos::ParameterList > const ¶mList)
Set parameters from a parameter list and return with default values.
static int getNProc()
The number of processes in MPI_COMM_WORLD.
static void setDefaultVerbLevel(const EVerbosityLevel defaultVerbLevel)
Set the default verbosity level.
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Set a parameter whose value has type T.
Initialize, finalize, and query the global MPI session.
basic_OSTab< char > OSTab
T * getRawPtr() const
Get the raw C++ pointer to the underlying object.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
static EVerbosityLevel getDefaultVerbLevel()
Get the default verbosity level.
T_To & dyn_cast(T_From &from)
Dynamic casting utility function meant to replace dynamic_cast<T&> by throwing a better documented er...
#define TEUCHOS_STANDARD_CATCH_STATEMENTS(VERBOSE, ERR_STREAM, SUCCESS_FLAG)
Simple macro that catches and reports standard exceptions and other exceptions.
static RCP< FancyOStream > getDefaultOStream()
Get the default output stream object.
TestVerboseObjectBaseInitialization()
Teuchos::RCP< const Teuchos::ParameterList > getParameterList() const
Get const version of the parameter list that was set using setParameterList().
Non-templated base class for objects that can print their activities to a stream. ...
std::string Teuchos_Version()
A list of parameters of arbitrary type.
static TestVerboseObjectBaseInitialization testVerboseObjectBaseInitialization
int main(int argc, char *argv[])
basic_FancyOStream< char > FancyOStream
A MPI utilities class, providing methods for initializing, finalizing, and querying the global MPI se...
Basic command line parser for input from (argc,argv[])
#define TEUCHOS_TEST_FOR_EXCEPT_PRINT(throw_exception_test, out_ptr)
This macro is the same as TEUCHOS_TEST_FOR_EXCEPT() except that the exception will be caught...
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
Creates an empty sublist and returns a reference to the sublist name. If the list already exists...
Smart reference counting pointer class for automatic garbage collection.
#define TEUCHOS_ASSERT(assertion_test)
This macro is throws when an assert fails.
void doAlgorithmStuff(Teuchos::ParameterList *algoParams=0)
virtual RCP< FancyOStream > getOStream() const
Return the output stream to be used for out for *this object.
Class that helps parse command line input arguments from (argc,argv[]) and set options.
Generate output as defined by the object.