An abstract class that provides debugging services. More...
#include <debug.h>
Public Member Functions | |
Debugable () | |
Constructor. | |
virtual | ~Debugable () |
virtual unsigned int | debug () const |
virtual ostream_ptr & | logif (bool condition) const |
Return an Dv::ostream_ptr to write debug or log info on. | |
virtual ostream_ptr & | log (unsigned int i=0) const |
Return an Dv::ostream_ptr to write debug or log info on. | |
Protected Attributes | |
ostream_ptr | log_0 |
An abstract class that provides debugging services.
It is not really abstract, the interface has a default implementation which will be used by slave debug objects that have lost their master.
Other Dv::DebugSlave objects may use a Dv::Debugable as a master, i.e. such objects use their master's debug and log facilities, possibly modified by an extra threshold so that the slave will obtain a non-null Dv::ostream_ptr from Debugable::log(0) only if the master's debug level is not less than this threashold. The intended usage of this feature is that, e.g. a higher level object acts as a master while more lower level objects are its slaves. Oftentimes, one wants debug output from the lower level objects only in extreme cases, i.e. if the debug level of the master is already quite high.
E.g.
Collection<Elements> master; master.debug(1); .. class Element: public DebugSlave { Element(Collection& c): DebugSlave(3) { set_master(&c); log() << "blabla"; // only if master.debug() >= 3 } }
The default implementation provided by Debugable always returns a null Dv::ostream_ptr.
Definition at line 170 of file debug.h.
Dv::Debugable::Debugable | ( | ) | [inline] |
virtual unsigned int Dv::Debugable::debug | ( | ) | const [inline, virtual] |
Reimplemented in Dv::DebugSlave, and Dv::Debug.
Definition at line 178 of file debug.h.
Referenced by Dv::DebugSlave::debug(), and log().
virtual ostream_ptr& Dv::Debugable::logif | ( | bool | condition | ) | const [inline, virtual] |
Return an Dv::ostream_ptr to write debug or log info on.
The default implementation always returns a null Dv::ostream_ptr
condition | a non-null Dv::ostream_ptr will be returned only if this condition is true (however, the default implementation here always returns a null Dv::ostream_ptr). |
Reimplemented in Dv::DebugSlave, and Dv::Debug.
Definition at line 187 of file debug.h.
References log_0.
Referenced by log(), and Dv::DebugSlave::logif().
virtual ostream_ptr& Dv::Debugable::log | ( | unsigned int | i = 0 |
) | const [inline, virtual] |
Return an Dv::ostream_ptr to write debug or log info on.
The default implementation always returns a null Dv::ostream_ptr
i | minimal debug level for getting a non-null Dv::ostream_ptr (however, the default implementation here always returns a null Dv::ostream_ptr). |
ostream_ptr Dv::Debugable::log_0 [protected] |
Definition at line 197 of file debug.h.
Referenced by Dv::Debug::logif(), and logif().
dvutil-1.0.10 | [ 5 December, 2009] |