Dv::Debug Class Reference

A Debug object is typically a master. More...

#include <debug.h>

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

List of all members.

Public Member Functions

 Debug (std::ostream *log=0, int dbg=0)
 Constructor.
unsigned int set_debug (unsigned int dbg)
 Set the debug level.
unsigned int add_debug (unsigned int dbg)
 Set some bits in the current debug flag.
unsigned int del_debug (unsigned int dbg)
 Clear bits in the current debug flag.
unsigned int debug () const
std::ostream * set_log (std::ostream *log)
 Set a log stream.
ostream_ptrlogif (bool condition) const
 Retrieve log file, depending on a condition.

Private Attributes

unsigned int debug_
Dv::ostream_ptr log_1

Detailed Description

A Debug object is typically a master.

It has an actual debug level and Dv::ostream_ptr for debug and log output.

However, it can also be made to act as a slave. The latter is accomplished by using DebugSlave::set_debug_master.

Definition at line 280 of file debug.h.


Constructor & Destructor Documentation

Dv::Debug::Debug ( std::ostream *  log = 0,
int  dbg = 0 
) [inline]

Constructor.

Parameters:
log initial (pointer to) std::ostream that will be used as log stream
dbg initial debug level

Definition at line 286 of file debug.h.


Member Function Documentation

unsigned int Dv::Debug::set_debug ( unsigned int  dbg  )  [inline]

Set the debug level.

Parameters:
dbg the new debug level.
Returns:
the old debug level

Definition at line 293 of file debug.h.

References debug_.

Referenced by add_debug(), and del_debug().

unsigned int Dv::Debug::add_debug ( unsigned int  dbg  )  [inline]

Set some bits in the current debug flag.

Parameters:
dbg bit pattern to add
Returns:
the old debug level

Definition at line 303 of file debug.h.

References debug(), and set_debug().

unsigned int Dv::Debug::del_debug ( unsigned int  dbg  )  [inline]

Clear bits in the current debug flag.

Parameters:
dbg bit pattern to add
Returns:
the old debug level

Definition at line 311 of file debug.h.

References debug(), and set_debug().

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

Reimplemented from Dv::DebugSlave.

Definition at line 316 of file debug.h.

References debug_.

Referenced by add_debug(), del_debug(), and logif().

std::ostream* Dv::Debug::set_log ( std::ostream *  log  )  [inline]

Set a log stream.

Parameters:
log the new log stream (or 0)
Returns:
the old log stream

Definition at line 322 of file debug.h.

References log_1, and Dv::ostream_ptr::set_os().

ostream_ptr& Dv::Debug::logif ( bool  condition  )  const [inline, virtual]

Retrieve log file, depending on a condition.

This allows one to write e.g.

 x.log(debug() & THIS_MODULE_DEBUG) << "blabla"

which will actually write only if there is a non-zero log stream and the current debug level has the appropriate THIS_MODULE_DEBUG bits set.

Parameters:
condition only return valid log stream if condition is true
Returns:
the log stream as returned by log() but only if the condition is true. Otherwise, a zero ostream_ptr is returned.

Reimplemented from Dv::DebugSlave.

Definition at line 335 of file debug.h.

References debug(), Dv::DebugSlave::debug_master(), Dv::Debugable::log_0, log_1, and Dv::DebugSlave::threshold_.


Member Data Documentation

unsigned int Dv::Debug::debug_ [private]

Definition at line 346 of file debug.h.

Referenced by debug(), and set_debug().

Definition at line 347 of file debug.h.

Referenced by logif(), and set_log().


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

dvutil-1.0.10 [ 5 December, 2009]