vstream Class Reference

A output stream to enable certain levels of verbosity. More...

#include <mia/core/msgstream.hh>

Public Types

enum  Level {
  ml_trace, ml_debug, ml_info, ml_message,
  ml_warning, ml_fail, ml_error, ml_fatal,
  ml_undefined
}
 

Public Member Functions

void flush ()
 write pending output More...
 
vstream::Level get_level () const
 
 operator std::ostream & ()
 
vstreamoperator<< (Level const l)
 
template<class T >
vstreamoperator<< (const T &text)
 
vstreamoperator<< (std::ostream &(*f)(std::ostream &))
 
std::ostream & set_stream (std::ostream &os)
 
void set_verbosity (Level l)
 
bool show_debug () const
 
bool shows (Level l) const
 

Static Public Member Functions

static vstreaminstance ()
 
static void set_output_target (std::ostream *os)
 

Detailed Description

A output stream to enable certain levels of verbosity.

This class impelemtns a std::ostream like class to output messages during run-time, supporting various levels of verbosity. The class is implemened as a singleton. On initialization it is set to use std::cerr as output stream, but this can be replaced by any type implementing the std::ostream interface.

Remarks
if -DNDEBUG is set, the levels debug and trace are not compiled in - i.e. the corresponding output operators are replaced by dummy functions that should be optimized away.

Definition at line 55 of file msgstream.hh.

Member Function Documentation

void vstream::flush ( )
inline

write pending output

Definition at line 270 of file msgstream.hh.

vstream::Level vstream::get_level ( ) const
inline
Returns
the curent verbosity level

Definition at line 265 of file msgstream.hh.

static vstream& vstream::instance ( )
static

initialise a stream that writes only messages above a certain verbosity level

Referenced by CTrace::CTrace(), cvdebug(), cverr(), cvfail(), cvfatal(), cvinfo(), cvmsg(), cvwarn(), and CTrace::~CTrace().

vstream::operator std::ostream & ( )
inline

Transparent conversion operator to an std::ostream.

Definition at line 141 of file msgstream.hh.

vstream& vstream::operator<< ( Level const  l)

a special handling to set the output level "inline"

Parameters
lthe level of the following messages
template<class T >
vstream& vstream::operator<< ( const T &  text)
inline

general output routine; output is only given, if the data verbosity level is set higher or equal to the stream verbosity level.

Parameters
textthe text to be written to the stream
Returns
a reference to this object

Definition at line 118 of file msgstream.hh.

vstream& vstream::operator<< ( std::ostream &(*)(std::ostream &)  f)

A funny construct to enable std::endl to work on this stream idea of Dave Brondsema: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8567

static void vstream::set_output_target ( std::ostream *  os)
static

Set the output target with which the stream should be initialized if std::cerr is not to be used.

std::ostream& vstream::set_stream ( std::ostream &  os)

sets the output stream

Parameters
os
Returns
the old output stream
void vstream::set_verbosity ( Level  l)

set the verbosity output level

Parameters
l
bool vstream::show_debug ( ) const
inline
Returns
true if the output level is equal or below "debug"

Definition at line 258 of file msgstream.hh.

References ml_debug, and shows().

bool vstream::shows ( Level  l) const
inline
Parameters
lverbosity level
Returns
true if cverb will show the given verbosity level

Definition at line 172 of file msgstream.hh.

Referenced by show_debug().


The documentation for this class was generated from the following file: