#include <cmnLODMultiplexerStreambuf.h>
Inheritance diagram for cmnLODMultiplexerStreambuf< _element, _trait >:


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 SetChannelLOD() 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.
// The multiple output channels ofstream log("logfile.txt"); windowoutputstream display; // hypothesized class lodMultiplexerStreambuf.AddChannel(&log.rdbuf(), CMN_LOG_LOD_RUN_ERROR); lodMultiplexerStreambuf.AddChannel(&windowoutputstream.rdbuf(), CMN_LOG_LOD_INIT_WARNING); cmnLODOutputMultiplexer multiplexerOutput(&lodMultiplexetStreambuf, CMN_LOG_LOD_INIT_VERBOSE); multiplexerStreambuf << "Hello, world" << endl; // channel the message only to 'log'
Notes:
Definition at line 109 of file cmnLODMultiplexerStreambuf.h.
| typedef cmnLogLoD cmnLODMultiplexerStreambuf< _element, _trait >::LogLoDType |
The type of Level of Detail
Definition at line 120 of file cmnLODMultiplexerStreambuf.h.
| 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.
Definition at line 128 of file cmnLODMultiplexerStreambuf.h.
| cmnLODMultiplexerStreambuf< _element, _trait >::cmnLODMultiplexerStreambuf | ( | std::ofstream & | fileStream | ) | [inline] |
Create Multiplexer with a default output filestream
| fileStream | Default Filestream |
Definition at line 136 of file cmnLODMultiplexerStreambuf.h.
| cmnLODMultiplexerStreambuf< _element, _trait >::cmnLODMultiplexerStreambuf | ( | ) | [inline] |
Constructor: currently empty.
Definition at line 143 of file cmnLODMultiplexerStreambuf.h.
| bool cmnLODMultiplexerStreambuf< _element, _trait >::AddChannel | ( | ChannelType * | channel, | |
| LogLoDType | lod | |||
| ) |
Add an output channel. See notes above.
| channel | A pointer to the output channel to be added. | |
| lod | Level Of Detail for the channel. |
Definition at line 282 of file cmnLODMultiplexerStreambuf.h.
Referenced by cmnLODMultiplexerStreambuf< char >::AddChannel(), and cmnLODMultiplexerStreambuf< char >::cmnLODMultiplexerStreambuf().
| bool cmnLODMultiplexerStreambuf< _element, _trait >::AddChannel | ( | std::ostream & | outstream, | |
| LogLoDType | lod | |||
| ) | [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. |
Definition at line 163 of file cmnLODMultiplexerStreambuf.h.
| 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. |
Definition at line 295 of file cmnLODMultiplexerStreambuf.h.
Referenced by cmnLODMultiplexerStreambuf< char >::RemoveChannel().
| void cmnLODMultiplexerStreambuf< _element, _trait >::RemoveChannel | ( | std::ostream & | outstream | ) | [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. |
Definition at line 184 of file cmnLODMultiplexerStreambuf.h.
| void cmnLODMultiplexerStreambuf< _element, _trait >::RemoveAllChannels | ( | void | ) |
Remove all output channels.
Definition at line 306 of file cmnLODMultiplexerStreambuf.h.
| bool cmnLODMultiplexerStreambuf< _element, _trait >::SetChannelLOD | ( | ChannelType * | channel, | |
| LogLoDType | lod | |||
| ) |
Set the output LOD of a channel
| channel | A pointer to the output channel to be added. | |
| lod | Level Of Detail for the channel |
Definition at line 313 of file cmnLODMultiplexerStreambuf.h.
| bool cmnLODMultiplexerStreambuf< _element, _trait >::GetChannelLOD | ( | const ChannelType * | channel, | |
| LogLoDType & | lod | |||
| ) | 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 |
Definition at line 325 of file cmnLODMultiplexerStreambuf.h.
| const ChannelContainerType& cmnLODMultiplexerStreambuf< _element, _trait >::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.
Definition at line 220 of file cmnLODMultiplexerStreambuf.h.
| std::streamsize cmnLODMultiplexerStreambuf< _element, _trait >::xsputn | ( | const _element * | s, | |
| std::streamsize | n, | |||
| LogLoDType | lod | |||
| ) | [protected, virtual] |
Multiplexed and LODed version of basic_streambuf xsputn.
Definition at line 337 of file cmnLODMultiplexerStreambuf.h.
Referenced by cmnMultiplexerStreambufProxy< _element, _trait >::xsputn().
| int cmnLODMultiplexerStreambuf< _element, _trait >::sync | ( | ) | [protected, virtual] |
Override the basic_streambuf sync for multiplexing. Note that in this one we sync() all the channels, regardless of the LOD.
Definition at line 350 of file cmnLODMultiplexerStreambuf.h.
Referenced by cmnMultiplexerStreambufProxy< _element, _trait >::sync().
| cmnLODMultiplexerStreambuf< _element, _trait >::int_type cmnLODMultiplexerStreambuf< _element, _trait >::overflow | ( | int_type | c, | |
| LogLoDType | lod | |||
| ) | [protected, virtual] |
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.
Definition at line 363 of file cmnLODMultiplexerStreambuf.h.
Referenced by cmnMultiplexerStreambufProxy< _element, _trait >::overflow().
| std::streamsize cmnLODMultiplexerStreambuf< _element, _trait >::xsputn | ( | const _element * | s, | |
| std::streamsize | n | |||
| ) | [protected, virtual] |
Override the basic_streambuf xsputn to do the multiplexing
Definition at line 383 of file cmnLODMultiplexerStreambuf.h.
| cmnLODMultiplexerStreambuf< _element, _trait >::int_type cmnLODMultiplexerStreambuf< _element, _trait >::overflow | ( | int_type | c = _trait::eof() |
) | [protected, virtual] |
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.
Definition at line 396 of file cmnLODMultiplexerStreambuf.h.