Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

MultiplexStreamBuf Class Reference

Used by MultiplexStream to implement an ostream that sends what is written to it to any number of additional sources, like other ostreams. More...

#include <multiplexStreamBuf.h>

List of all members.

Public Types

enum  BufferType { BT_none, BT_line }
enum  OutputType { OT_ostream, OT_stdio, OT_system_debug }

Public Member Functions

 MultiplexStreamBuf ()
virtual ~MultiplexStreamBuf ()
void add_output (BufferType buffer_type, OutputType output_type, ostream *out=(ostream *) NULL, FILE *fout=(FILE *) NULL, bool owns_obj=false)
 Adds the indicated output destinition to the set of things that will be written to when characters are output to the MultiplexStream.

void flush ()
 Forces out all output that hasn't yet been written.


Protected Member Functions

virtual int overflow (int c)
 Called by the system ostream implementation when its internal buffer is filled, plus one character.

virtual int sync ()
 Called by the system ostream implementation when the buffer should be flushed to output (for instance, on destruction).


Private Types

typedef pvector< OutputOutputs

Private Member Functions

void write_chars (const char *start, int length, bool flush)
 An internal function called by sync() and overflow() to store one or more characters written to the stream into the memory buffer.


Private Attributes

Outputs _outputs
string _line_buffer


Detailed Description

Used by MultiplexStream to implement an ostream that sends what is written to it to any number of additional sources, like other ostreams.

Definition at line 45 of file multiplexStreamBuf.h.


Member Typedef Documentation

typedef pvector<Output> MultiplexStreamBuf::Outputs [private]
 

Definition at line 88 of file multiplexStreamBuf.h.


Member Enumeration Documentation

enum MultiplexStreamBuf::BufferType
 

Enumeration values:
BT_none 
BT_line 

Definition at line 50 of file multiplexStreamBuf.h.

enum MultiplexStreamBuf::OutputType
 

Enumeration values:
OT_ostream 
OT_stdio 
OT_system_debug 

Definition at line 55 of file multiplexStreamBuf.h.


Constructor & Destructor Documentation

MultiplexStreamBuf::MultiplexStreamBuf  ) 
 

Definition at line 109 of file multiplexStreamBuf.cxx.

References _outputs, MultiplexStreamBuf::Output::close(), and sync().

MultiplexStreamBuf::~MultiplexStreamBuf  )  [virtual]
 

Definition at line 125 of file multiplexStreamBuf.cxx.

References MultiplexStreamBuf::Output::_buffer_type, MultiplexStreamBuf::Output::_fout, MultiplexStreamBuf::Output::_out, MultiplexStreamBuf::Output::_output_type, _outputs, and MultiplexStreamBuf::Output::_owns_obj.


Member Function Documentation

void MultiplexStreamBuf::add_output MultiplexStreamBuf::BufferType  buffer_type,
MultiplexStreamBuf::OutputType  output_type,
ostream *  out = (ostream *)NULL,
FILE *  fout = (FILE *)NULL,
bool  owns_obj = false
 

Adds the indicated output destinition to the set of things that will be written to when characters are output to the MultiplexStream.

Definition at line 149 of file multiplexStreamBuf.cxx.

References write_chars().

Referenced by MultiplexStream::add_file(), MultiplexStream::add_ostream(), and MultiplexStream::MultiplexStream().

void MultiplexStreamBuf::flush void   ) 
 

Forces out all output that hasn't yet been written.

Definition at line 177 of file multiplexStreamBuf.cxx.

References write_chars().

int MultiplexStreamBuf::overflow int  c  )  [protected, virtual]
 

Called by the system ostream implementation when its internal buffer is filled, plus one character.

Definition at line 196 of file multiplexStreamBuf.cxx.

References streamsize, and write_chars().

int MultiplexStreamBuf::sync void   )  [protected, virtual]
 

Called by the system ostream implementation when the buffer should be flushed to output (for instance, on destruction).

Definition at line 230 of file multiplexStreamBuf.cxx.

References _line_buffer, length, and size_t.

Referenced by MultiplexStreamBuf().

void MultiplexStreamBuf::write_chars const char *  start,
int  length,
bool  flush
[private]
 

An internal function called by sync() and overflow() to store one or more characters written to the stream into the memory buffer.

It is assumed that there is only one thread at a time running this code; it is the responsibility of the caller to grab the _lock mutex before calling this.

Definition at line 269 of file multiplexStreamBuf.cxx.

Referenced by add_output(), flush(), and overflow().


Member Data Documentation

string MultiplexStreamBuf::_line_buffer [private]
 

Definition at line 91 of file multiplexStreamBuf.h.

Referenced by sync().

Outputs MultiplexStreamBuf::_outputs [private]
 

Definition at line 89 of file multiplexStreamBuf.h.

Referenced by MultiplexStreamBuf(), and ~MultiplexStreamBuf().


The documentation for this class was generated from the following files:
Generated on Fri May 2 00:52:29 2003 for Panda by doxygen1.3