cisst-saw
|
A Streambuffer class that allows output to multiple streambuf objects for Level of Detail information. More...
#include <cmnLODMultiplexerStreambuf.h>
Public Types | |
typedef cmnLODMultiplexerStreambuf < _element, _trait > | ThisType |
typedef std::basic_streambuf < _element, _trait > | BaseClassType |
typedef std::basic_streambuf < _element, _trait > | ChannelType |
typedef std::pair< ChannelType *, cmnLogMask > | ElementType |
typedef std::list< ElementType > | ChannelContainerType |
typedef ChannelContainerType::iterator | IteratorType |
typedef ChannelContainerType::const_iterator | ConstIteratorType |
typedef std::list< ThisType * > | MultiplexerContainerType |
typedef MultiplexerContainerType::iterator | MultiplexerIteratorType |
typedef MultiplexerContainerType::const_iterator | MultiplexerConstIteratorType |
Public Member Functions | |
cmnLODMultiplexerStreambuf (std::ofstream &fileStream) | |
cmnLODMultiplexerStreambuf () | |
bool | AddChannel (ChannelType *channel, cmnLogMask mask) |
bool | AddChannel (std::ostream &outstream, cmnLogMask mask) |
bool | AddMultiplexer (ThisType *multiplexer) |
void | RemoveChannel (ChannelType *channel) |
void | RemoveMultiplexer (ThisType *multiplexer) |
void | RemoveChannel (std::ostream &outstream) |
void | RemoveAllChannels (void) |
bool | SetChannelMask (ChannelType *channel, cmnLogMask mask) |
bool | GetChannelMask (const ChannelType *channel, cmnLogMask &mask) const |
const ChannelContainerType & | GetChannels (void) const |
Protected Types | |
typedef std::basic_streambuf < _element, _trait >::int_type | int_type |
Protected Member Functions | |
virtual std::streamsize | xsputn (const _element *s, std::streamsize n, cmnLogLevel level) |
virtual int | sync () |
virtual int_type | overflow (int_type c, cmnLogLevel level) |
virtual std::streamsize | xsputn (const _element *s, std::streamsize n) |
virtual int_type | overflow (int_type c=_trait::eof()) |
IteratorType | FindChannel (const ChannelType *channel) |
ConstIteratorType | FindChannel (const ChannelType *channel) const |
MultiplexerIteratorType | FindMultiplexer (const ThisType *multiplexer) |
MultiplexerConstIteratorType | FindMultiplexer (const ThisType *multiplexer) const |
Protected Attributes | |
ChannelContainerType | Channels |
MultiplexerContainerType | Multiplexers |
Friends | |
class | cmnMultiplexerStreambufProxy< _element, _trait > |
A Streambuffer class that allows output to multiple streambuf objects for Level of Detail information.
Types for dynamic control of output messages. This includes debugging information, error reporting, state logging etc. This file declares class cmnLODMultiplexerStreambuf. It is a templated class derived from the standard library's basic_streambuf, with the additional feature that enables channeling the output to multiple other streambuf objects, and each output channel is associated with a Level Of Detail (LOD) descriptor. The cmnLODMultiplexerStreambuf provides both the standard interface functions of basic_streambuf, and a substitute with an extra parameter, which is the output LOD. cmnLODMultiplexerStreambuf the extra-parameter methods should be called from a streambuf proxy that implements the standard basic_streambuf virtual methods, and wraps calls to the multiplexer. Note that the cmnLODMultiplexerStreambuf can be used independently as an output multiplexer withoud LOD, using the standard basic_streambuf interface.
Usage: Include the module in your application with: #include <cmnLODMultiplexerStreambuf.h>
Add output streambuf channels to the multiplexer using the AddChannel() method.
Remove output channels from the multiplexer using the RemoveChannel() method.
Set the output LOD of a channel using the SetChannelMask() method.
Create proxy streambuf objects that store their LOD, and pass it to the cmnLODMultiplexerStreambuf to do the actual multiplexing. The proxy streambufs should be attached to an ostream object, which is then used by the client module.
Example of using a cmnLODOutputMultiplexer, which is an ostream that is attached to a proxy. Assume that the object lodMultiplexerStreambuf is a cmnLODMultiplexerStreambuf.
Notes:
typedef std::basic_streambuf<_element, _trait> cmnLODMultiplexerStreambuf< _element, _trait >::BaseClassType |
typedef std::list<ElementType> cmnLODMultiplexerStreambuf< _element, _trait >::ChannelContainerType |
Type of internal data structure storing the channels. I chose to use a list for efficiency in output iteration over the channels, rather than, for example, a map.
typedef std::basic_streambuf<_element, _trait> cmnLODMultiplexerStreambuf< _element, _trait >::ChannelType |
typedef ChannelContainerType::const_iterator cmnLODMultiplexerStreambuf< _element, _trait >::ConstIteratorType |
typedef std::pair<ChannelType *, cmnLogMask> cmnLODMultiplexerStreambuf< _element, _trait >::ElementType |
|
protected |
typedef ChannelContainerType::iterator cmnLODMultiplexerStreambuf< _element, _trait >::IteratorType |
typedef MultiplexerContainerType::const_iterator cmnLODMultiplexerStreambuf< _element, _trait >::MultiplexerConstIteratorType |
typedef std::list<ThisType *> cmnLODMultiplexerStreambuf< _element, _trait >::MultiplexerContainerType |
typedef MultiplexerContainerType::iterator cmnLODMultiplexerStreambuf< _element, _trait >::MultiplexerIteratorType |
typedef cmnLODMultiplexerStreambuf<_element, _trait> cmnLODMultiplexerStreambuf< _element, _trait >::ThisType |
|
inline |
Create Multiplexer with a default output filestream
fileStream | Default Filestream |
|
inline |
Constructor: currently empty.
bool cmnLODMultiplexerStreambuf< _element, _trait >::AddChannel | ( | ChannelType * | channel, |
cmnLogMask | mask | ||
) |
Add an output channel. See notes above.
channel | A pointer to the output channel to be added. |
lod | Level Of Detail for the channel. |
|
inline |
Add a channel defined by an output stream. This methods relies on the existence of a rdbuf() method and calls AddChannel(ChannelType, LoDtype).
outstream | Output stream providing the rdbuf. |
lod | Level of Detail for the stream. |
bool cmnLODMultiplexerStreambuf< _element, _trait >::AddMultiplexer | ( | ThisType * | multiplexer | ) |
|
protected |
Find a channel in the container and return the container's iterator for the element with that channel.
|
protected |
Find a channel in the container and return the container's iterator for the element with that channel.
|
protected |
Find a multiplexer in the container and return the container's iterator for the element with that multiplexer.
|
protected |
Find a multiplexer in the container and return the container's iterator for the element with that multiplexer.
bool cmnLODMultiplexerStreambuf< _element, _trait >::GetChannelMask | ( | const ChannelType * | channel, |
cmnLogMask & | mask | ||
) | const |
Find the output LOD of a channel
channel | a pointer to the output channel to be added. |
lod | Level Of Detail for the channel |
|
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.
|
protectedvirtual |
Multiplexed and LODed version of basic_streambuf overflow for multiplexing. overflow() is called when sputc() discovers it does not have space in the storage buffer. In our case, it's always. See more on it in the basic_streambuf documentation.
Reimplemented in mtsLODMultiplexerStreambuf.
|
protectedvirtual |
Override the basic_streambuf overflow for multiplexing. overflow() is called when sputc() discovers it does not have space in the storage buffer. In our case, it's always. See more on it in the basic_streambuf documentation.
Reimplemented in mtsLODMultiplexerStreambuf.
void cmnLODMultiplexerStreambuf< _element, _trait >::RemoveAllChannels | ( | void | ) |
Remove all output channels.
void cmnLODMultiplexerStreambuf< _element, _trait >::RemoveChannel | ( | ChannelType * | channel | ) |
Remove an output channel.
channel | A pointer to the output channel to be removed. No change occurs if the pointer is not on the list of channels for this multiplexer. |
|
inline |
Remove an output channel. This methods relies on the existence of a rdbuf() method and calls RemoveChannel(ChannelType).
outstream | Output stream providing the rdbuf. |
void cmnLODMultiplexerStreambuf< _element, _trait >::RemoveMultiplexer | ( | ThisType * | multiplexer | ) |
bool cmnLODMultiplexerStreambuf< _element, _trait >::SetChannelMask | ( | ChannelType * | channel, |
cmnLogMask | mask | ||
) |
Set the output LOD of a channel
channel | A pointer to the output channel to be added. |
lod | Level Of Detail for the channel |
|
protectedvirtual |
Override the basic_streambuf sync for multiplexing. Note that in this one we sync() all the channels, regardless of the LOD.
Reimplemented in mtsLODMultiplexerStreambuf.
|
protectedvirtual |
Multiplexed and LODed version of basic_streambuf xsputn.
Reimplemented in mtsLODMultiplexerStreambuf.
|
protectedvirtual |
Override the basic_streambuf xsputn to do the multiplexing
Reimplemented in mtsLODMultiplexerStreambuf.
|
friend |
|
protected |
The actual container that stores channel addresses.
|
protected |
The actual container that stores multiplexers addresses.