00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef TEUCHOS_DESCRIBABLE_HPP
00030 #define TEUCHOS_DESCRIBABLE_HPP
00031
00032 #include "Teuchos_ConfigDefs.hpp"
00033
00034 namespace Teuchos {
00035
00037 enum EVerbosityLevel {
00038 VERB_DEFAULT=0
00039 ,VERB_LOW=1
00040 ,VERB_MEDIUM=2
00041 ,VERB_HIGH=3
00042 ,VERB_EXTREME=4
00043 };
00044
00068 class Describable {
00069 public:
00070
00072 static const EVerbosityLevel verbLevel_default;
00074 static const std::string leadingIndent_default;
00076 static const std::string indentSpacer_default;
00077
00079 virtual ~Describable() {}
00080
00083
00095 virtual std::string description() const;
00096
00134 virtual std::ostream& describe(
00135 std::ostream &out
00136 ,const EVerbosityLevel verbLevel = verbLevel_default
00137 ,const std::string leadingIndent = leadingIndent_default
00138 ,const std::string indentSpacer = indentSpacer_default
00139 ) const;
00140
00141 };
00142
00151 struct DescribableStreamManipulatorState {
00152 const Describable &describable;
00153 const EVerbosityLevel verbLevel;
00154 const std::string leadingIndent;
00155 const std::string indentSpacer;
00156 DescribableStreamManipulatorState(
00157 const Describable &_describable
00158 ,const EVerbosityLevel _verbLevel
00159 ,const std::string _leadingIndent
00160 ,const std::string _indentSpacer
00161 )
00162 :describable(_describable)
00163 ,verbLevel(_verbLevel)
00164 ,leadingIndent(_leadingIndent)
00165 ,indentSpacer(_indentSpacer)
00166 {}
00167 };
00168
00170 inline DescribableStreamManipulatorState describe(
00171 const Describable &describable
00172 ,const EVerbosityLevel verbLevel = Describable::verbLevel_default
00173 ,const std::string leadingIndent = Describable::leadingIndent_default
00174 ,const std::string indentSpacer = Describable::indentSpacer_default
00175 )
00176 {
00177 return DescribableStreamManipulatorState(describable,verbLevel,leadingIndent,indentSpacer);
00178 }
00179
00181 inline
00182 std::ostream& operator<<( std::ostream& os, const DescribableStreamManipulatorState& d )
00183 {
00184 return d.describable.describe(os,d.verbLevel,d.leadingIndent,d.indentSpacer);
00185 }
00186
00187 }
00188
00189 #endif // TEUCHOS_DESCRIBABLE_HPP