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

CStreamFilter Class Reference

A stream filter. More...

#include <CStreamFilter.h>

Inherits IStream.

Inherited by CPacketStreamFilter.

Inheritance diagram for CStreamFilter:

Inheritance graph
[legend]
Collaboration diagram for CStreamFilter:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 CStreamFilter (IStream *stream, bool adoptStream=true)
virtual void close ()
 Close the stream.
virtual UInt32 read (void *buffer, UInt32 n)
 Read from stream.
virtual void write (const void *buffer, UInt32 n)
 Write to stream.
virtual void flush ()
 Flush the stream.
virtual void shutdownInput ()
 Shutdown input.
virtual void shutdownOutput ()
 Shutdown output.
virtual void * getEventTarget () const
 Get event target.
virtual bool isReady () const
 Test if read() will succeed.
virtual UInt32 getSize () const
 Get bytes available to read.

Protected Member Functions

IStreamgetStream () const
 Get the stream.
virtual void filterEvent (const CEvent &)
 Handle events from source stream.

Detailed Description

A stream filter.

This class wraps a stream. Subclasses provide indirect access to the wrapped stream, typically performing some filtering.

Definition at line 25 of file CStreamFilter.h.


Constructor & Destructor Documentation

CStreamFilter::CStreamFilter IStream stream,
bool  adoptStream = true
 

Create a wrapper around stream. Iff adoptStream is true then this object takes ownership of the stream and will delete it in the d'tor.

Definition at line 23 of file CStreamFilter.cpp.

References IStream::getEventTarget().


Member Function Documentation

void CStreamFilter::close  )  [virtual]
 

Close the stream.

Closes the stream. Pending input data and buffered output data are discarded. Use flush() before close() to send buffered output data. Attempts to read() after a close return 0, attempts to write() generate output error events, and attempts to flush() return immediately.

Implements IStream.

Reimplemented in CPacketStreamFilter.

Definition at line 43 of file CStreamFilter.cpp.

References IStream::close(), and getStream().

Referenced by CPacketStreamFilter::close().

void CStreamFilter::filterEvent const CEvent  )  [protected, virtual]
 

Handle events from source stream.

Does the event filtering. The default simply dispatches an event identical except using this object as the event target.

Reimplemented in CPacketStreamFilter.

Definition at line 103 of file CStreamFilter.cpp.

References CEvent::getData(), getEventTarget(), and CEvent::getType().

Referenced by CPacketStreamFilter::filterEvent().

void CStreamFilter::flush  )  [virtual]
 

Flush the stream.

Waits until all buffered data has been written to the stream.

Implements IStream.

Definition at line 61 of file CStreamFilter.cpp.

References IStream::flush(), and getStream().

void * CStreamFilter::getEventTarget  )  const [virtual]
 

Get event target.

Returns the event target for events generated by this stream. It should be the source stream in a chain of stream filters.

Implements IStream.

Definition at line 79 of file CStreamFilter.cpp.

Referenced by filterEvent(), and CPacketStreamFilter::read().

UInt32 CStreamFilter::getSize  )  const [virtual]
 

Get bytes available to read.

Returns a conservative estimate of the available bytes to read (i.e. a number not greater than the actual number of bytes). Some streams may not be able to determine this and will always return zero.

Implements IStream.

Reimplemented in CPacketStreamFilter.

Definition at line 91 of file CStreamFilter.cpp.

References IStream::getSize(), and getStream().

IStream * CStreamFilter::getStream  )  const [protected]
 

Get the stream.

Returns the stream passed to the c'tor.

Definition at line 97 of file CStreamFilter.cpp.

Referenced by close(), flush(), getSize(), isReady(), read(), shutdownInput(), shutdownOutput(), write(), and CPacketStreamFilter::write().

bool CStreamFilter::isReady  )  const [virtual]
 

Test if read() will succeed.

Returns true iff an immediate read() will return data. This may or may not be the same as getSize() > 0, depending on the stream type.

Implements IStream.

Reimplemented in CPacketStreamFilter.

Definition at line 85 of file CStreamFilter.cpp.

References getStream(), and IStream::isReady().

UInt32 CStreamFilter::read void *  buffer,
UInt32  n
[virtual]
 

Read from stream.

Read up to n bytes into buffer, returning the number read (zero if no data is available or input is shutdown). buffer may be NULL in which case the data is discarded.

Implements IStream.

Reimplemented in CPacketStreamFilter.

Definition at line 49 of file CStreamFilter.cpp.

References getStream(), and IStream::read().

void CStreamFilter::shutdownInput  )  [virtual]
 

Shutdown input.

Shutdown the input side of the stream. Any pending input data is discarded and further reads immediately return 0.

Implements IStream.

Reimplemented in CPacketStreamFilter.

Definition at line 67 of file CStreamFilter.cpp.

References getStream(), and IStream::shutdownInput().

Referenced by CPacketStreamFilter::shutdownInput().

void CStreamFilter::shutdownOutput  )  [virtual]
 

Shutdown output.

Shutdown the output side of the stream. Any buffered output data is discarded and further writes generate output error events. Use flush() before shutdownOutput() to send buffered output data.

Implements IStream.

Definition at line 73 of file CStreamFilter.cpp.

References getStream(), and IStream::shutdownOutput().

void CStreamFilter::write const void *  buffer,
UInt32  n
[virtual]
 

Write to stream.

Write n bytes from buffer to the stream. If this can't complete immediately it will block. Data may be buffered in order to return more quickly. A output error event is generated when writing fails.

Implements IStream.

Reimplemented in CPacketStreamFilter.

Definition at line 55 of file CStreamFilter.cpp.

References getStream(), and IStream::write().


The documentation for this class was generated from the following files:
Generated on Fri Nov 6 00:21:30 2009 for synergy-plus by  doxygen 1.3.9.1