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

Creates a collection of objects that channels output to multiple sinks. More...

#include <cmnOutputMultiplexer.h>

Inheritance diagram for cmnOutputMultiplexer:

Public Types

typedef char char_type
typedef std::ostream ChannelType
typedef std::list< ChannelType * > ChannelContainerType

Public Member Functions

 cmnOutputMultiplexer ()
ChannelTypeAddChannel (ChannelType *channel)
ChannelTypeRemoveChannel (ChannelType *channel)
const ChannelContainerTypeGetChannels () const

Protected Attributes

ChannelContainerType m_ChannelContainer
cmnLODMultiplexerStreambuf< char_typem_Streambuf

Detailed Description

Creates a collection of objects that channels output to multiple sinks.

Types for dynamic control of output messages. This includes debugging information, error reporting, state logging etc. This file declares class cmnOutputMultiplexer. a cmnOutputMultiplexer inherits the public interface of a generic ostream, and channels the output to multiple sinks.

Usage: Include the module in your application with: #include "cmnOutputMultiplexer.h"

Create a collection of ostream objects, and attach them to a cmnOutputMultiplexer. Use the standrard ostream syntax (operator <<) to stream objects to the multiplexer.

ofstream log("logfile.txt");
windowoutputstream display; // hypothetical class
multiplexer.AddChannel(&log);
multiplexer.AddChannel(&windowoutputstream);
multiplexer << "Hello, world" << endl; // channel the message ot all streams.
ChannelType & AddChannel(ChannelType *channel)
cmnOutputMultiplexer()
Definition cmnOutputMultiplexer.h:90

Notes:

  1. cmnOutputMultiplexer does not OWN the output streams. They are created and destroyed externally.
  2. The initial implementation uses a list to store the addresses of the output channels. There is no guarantee on the order of storage or the order of output channelling.
  3. It is assumed that none of the output channels modifies the data arguments.
  4. The multiplexer does not buffer any output. There is no implementation for seekp() and tellp().
  5. It is guaranteed that at most one instance of an ostream object is stored as a channel in a single multiplexer. The AddChannel() function checks for uniqueness.

Member Typedef Documentation

◆ ChannelContainerType

Type of internal data structure storing the channels.

◆ ChannelType

typedef std::ostream cmnOutputMultiplexer::ChannelType

◆ char_type

Constructor & Destructor Documentation

◆ cmnOutputMultiplexer()

cmnOutputMultiplexer::cmnOutputMultiplexer ( )
inline

Default constructor - initialize base class.

Member Function Documentation

◆ AddChannel()

ChannelType & cmnOutputMultiplexer::AddChannel ( ChannelType * channel)

Add an output channel. See notes above.

Parameters
channelA pointer to the output channel to be added.

◆ GetChannels()

const ChannelContainerType & cmnOutputMultiplexer::GetChannels ( ) const
inline

Enable access to the channel storage, without addition or removal of channels. Elements of the container can be accessed using the standard const_iterator interfaces. Note that the channels themselves are non-const, so individual manipulation of each is enabled.

◆ RemoveChannel()

ChannelType & cmnOutputMultiplexer::RemoveChannel ( ChannelType * channel)

Remove an output channel.

Parameters
channelA pointer to the output channel to be removed. No change occurs if the pointer is not on the list of channels for this multiplexer.
Returns
channel Returns *this, The output channel.

Member Data Documentation

◆ m_ChannelContainer

ChannelContainerType cmnOutputMultiplexer::m_ChannelContainer
protected

◆ m_Streambuf

cmnLODMultiplexerStreambuf<char_type> cmnOutputMultiplexer::m_Streambuf
protected

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