cisst-saw
Loading...
Searching...
No Matches
cmnLODOutputMultiplexer Class Reference

Types for dynamic control of output messages. More...

#include <cmnLODOutputMultiplexer.h>

Inheritance diagram for cmnLODOutputMultiplexer:

Public Types

typedef char char_type
typedef cmnLODMultiplexerStreambuf< char_typeSinkType
typedef std::ostream BaseType

Public Member Functions

 cmnLODOutputMultiplexer (SinkType *multiplexer, cmnLogLevel level)
cmnLODOutputMultiplexerRef (void)
cmnLogLevel GetLOD (void) const
void SetLOD (cmnLogLevel lod)

Detailed Description

Types for dynamic control of output messages.

This includes debugging information, error reporting, state logging etc. This file declares class cmnLODOutputMultiplexer. A cmnLODOutputMultiplexer inherits the public interface of a generic ostream, and attaches each output message with a Level Of Detail (LOD) descriptor. The LOD descriptor is forwarded through a cmnMultiplexerStreambufProxy to a cmnLODMultiplexerStreambuf that performs the actual multiplexing.

Create a collection of ostream objects, and attach them to a cmnLODMultiplexerStreambuf. Create a cmnLODOutputMultiplexer and assign it with the LOD value and the cmnLODMultiplexerStreambuf address. Use the standard ostream syntax (operator <<) to stream objects to the multiplexer.

Example (assume that the object lodMultiplexerStreambuf is a cmnLODMultiplexerStreambuf):

// The multiple output channels
ofstream log("logfile.txt");
windowoutputstream display; // hypothetical class
cmnLODOutputMultiplexer multiplexerOutput(&lodMultiplexetStreambuf, CMN_LOG_ALLOW_DEFAULT);
lodMultiplexerStreambuf.AddChannel(log, CMN_LOG_ALLOW_DEFAULT);
lodMultiplexerStreambuf.AddChannel(windowoutputstream, CMN_LOG_ALLOW_ALL);
multiplexerStreambuf << "Hello, world" << endl; // channel the message only to 'log'
#define CMN_LOG_ALLOW_DEFAULT
Definition cmnLogLoD.h:76
#define CMN_LOG_ALLOW_ALL
Definition cmnLogLoD.h:75
See also
cmnLODMultiplexerStreambuf.h, cmnMultiplexerStreambufProxy.h, C++ documentation of basic_streambuf and iostream

Member Typedef Documentation

◆ BaseType

typedef std::ostream cmnLODOutputMultiplexer::BaseType

◆ char_type

◆ SinkType

Constructor & Destructor Documentation

◆ cmnLODOutputMultiplexer()

cmnLODOutputMultiplexer::cmnLODOutputMultiplexer ( SinkType * multiplexer,
cmnLogLevel level )
inline

Constructor that initializes base class and stores LOD.

Member Function Documentation

◆ GetLOD()

cmnLogLevel cmnLODOutputMultiplexer::GetLOD ( void ) const
inline

Returns the Level of Detail.

◆ Ref()

cmnLODOutputMultiplexer & cmnLODOutputMultiplexer::Ref ( void )
inline

This method simply returns a reference to this object. It is used when a cmnLODOutputMultiplexer is created and immediately operated on, to ensure that the object operated on is an l-value rather than r-value. This solves compiler ambiguities and errors that lead to incorrect printout. Use it where the old CMN_LOG_HACK would be used. Normally, one doesn't need to call this method in other cases.

◆ SetLOD()

void cmnLODOutputMultiplexer::SetLOD ( cmnLogLevel lod)
inline

Sets the Level of Detail.


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