Teuchos::Describable Class Reference

Base class for all objects that can describe themselves and their current state. More...

#include <Teuchos_Describable.hpp>

List of all members.

Public Member Functions

virtual ~Describable ()
 
Public virtual member functions
virtual std::string description () const
 Return a simple description (usually just one line) of this object.
virtual std::ostream & describe (std::ostream &out, const EVerbosityLevel verbLevel=verbLevel_default, const std::string leadingIndent=leadingIndent_default, const std::string indentSpacer=indentSpacer_default) const
 Print the object using given indentation with some verbosity level to an std::ostream object.

Static Public Attributes

const EVerbosityLevel verbLevel_default = VERB_DEFAULT
 Default value for verLevel in description().
const std::string leadingIndent_default = ""
 Default value for leadingIndent in description().
const std::string indentSpacer_default = " "
 Default value for indentSpacer in description().


Detailed Description

Base class for all objects that can describe themselves and their current state.

This base class is designed to be a minimally invasive approach for allowing subclasses to optionally provide detailed debug-style information about their current state. This interface has just two virtual member functions, describe(void) and description(), which both have default implementations. The shorter version of describe(void) (which takes no arguments and returns an std::string object) is meant for very short descriptions while the longer version of description() takes and returns an std::ostream argument and is designed for more detailed formated output.

Since both of these description() functions have reasonable default implementations, when a subclass inherits from this base class, no virtual functions need to be overridden to start with. However, when debugging time comes, one or both of these functions should be overridden to provide more useful information.

ToDo: Include an example/testing function for a few different use cases to demonstrate how to use this interface properly.

Definition at line 68 of file Teuchos_Describable.hpp.


Constructor & Destructor Documentation

virtual Teuchos::Describable::~Describable  )  [inline, virtual]
 

Definition at line 79 of file Teuchos_Describable.hpp.


Member Function Documentation

std::string Teuchos::Describable::description  )  const [virtual]
 

Return a simple description (usually just one line) of this object.

The default implementation just returns typeid(*this).name() but a subclass can modify this if needed. Note that some compilers return a mangled name from std::type_info::name() (e.g. g++ version 3.4.x and before) that is hard for non-g++ developers to read. Therefore, it is usually beneficial to override this function an build a more human-readable name for a subclass, especially if templating is used.

Definition at line 39 of file Teuchos_Describable.cpp.

std::ostream & Teuchos::Describable::describe std::ostream &  out,
const EVerbosityLevel  verbLevel = verbLevel_default,
const std::string  leadingIndent = leadingIndent_default,
const std::string  indentSpacer = indentSpacer_default
const [virtual]
 

Print the object using given indentation with some verbosity level to an std::ostream object.

Parameters:
out [in] The std::ostream object that output is sent to.
verbLevel [in] Determines the level of verbosity for which the the object will be printed. If verbLevel==VERB_DEFAULT (which is the default value), then the verbosity level will be determined by the *this object (i.e. perhaps through the ObjectWithVerbosity interface). It is up to *this how to interpret the level represented by verbLevel. The default value is VERB_DEFAULT.
leadingIndent [in] This is the leading indentation space that should be inserted before each new line is printed to out. Default value is "" (i.e. no initial indentation).
indentSpacer [in] This is the character string to use to create internal indentation. This allows a consistent level of indentation for all output. The default value is " " (i.e. two spaces).
In order for this function to work effectively for independently developed classes, a general consensus needs be reached as to what the various verbosity levels represented in verbLevel mean in relation to the amount of output produced.

A default implementation of this function is provided that simply performs:


   return out << leadingIndent << this->description() << std::endl; 

A subclass should override this function to provide more interesting and more useful information about the object.

Definition at line 44 of file Teuchos_Describable.cpp.


Member Data Documentation

const EVerbosityLevel Teuchos::Describable::verbLevel_default = VERB_DEFAULT [static]
 

Default value for verLevel in description().

Definition at line 33 of file Teuchos_Describable.cpp.

const std::string Teuchos::Describable::leadingIndent_default = "" [static]
 

Default value for leadingIndent in description().

Definition at line 35 of file Teuchos_Describable.cpp.

const std::string Teuchos::Describable::indentSpacer_default = " " [static]
 

Default value for indentSpacer in description().

Definition at line 37 of file Teuchos_Describable.cpp.


The documentation for this class was generated from the following files:
Generated on Thu Sep 18 12:39:12 2008 for Teuchos - Trilinos Tools Package by doxygen 1.3.9.1