Dv::Debugable Class Reference

An abstract class that provides debugging services. More...

#include <debug.h>

Inheritance diagram for Dv::Debugable:
Inheritance graph
[legend]
Collaboration diagram for Dv::Debugable:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Debugable ()
 Constructor.
virtual ~Debugable ()
virtual unsigned int debug () const
virtual ostream_ptrlogif (bool condition) const
 Return an Dv::ostream_ptr to write debug or log info on.
virtual ostream_ptrlog (unsigned int i=0) const
 Return an Dv::ostream_ptr to write debug or log info on.

Protected Attributes

ostream_ptr log_0

Detailed Description

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.


Constructor & Destructor Documentation

Dv::Debugable::Debugable (  )  [inline]

Constructor.

Sets log_0, which is a null ostream_ptr.

Definition at line 173 of file debug.h.

virtual Dv::Debugable::~Debugable (  )  [inline, virtual]

Definition at line 175 of file debug.h.


Member Function Documentation

virtual unsigned int Dv::Debugable::debug (  )  const [inline, virtual]
Returns:
debug level.

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

Parameters:
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).
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

Parameters:
i minimal debug level for getting a non-null Dv::ostream_ptr (however, the default implementation here always returns a null Dv::ostream_ptr).
Returns:
a null Dv::ostream_ptr
See also:
Debugable::logif

Definition at line 195 of file debug.h.

References debug(), and logif().


Member Data Documentation

Definition at line 197 of file debug.h.

Referenced by Dv::Debug::logif(), and logif().


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

dvutil-1.0.10 [ 5 December, 2009]