#include <CPacketStreamFilter.h>
Inherits CStreamFilter.
Inheritance diagram for CPacketStreamFilter:
Public Member Functions | |
CPacketStreamFilter (IStream *stream, bool adoptStream=true) | |
~CPacketStreamFilter () | |
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 | shutdownInput () |
Shutdown input. | |
virtual bool | isReady () const |
Test if read() will succeed. | |
virtual UInt32 | getSize () const |
Get bytes available to read. | |
Protected Member Functions | |
virtual void | filterEvent (const CEvent &) |
Handle events from source stream. |
Filters a stream to read and write packets.
Definition at line 26 of file CPacketStreamFilter.h.
void CPacketStreamFilter::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.
Reimplemented from CStreamFilter.
Definition at line 40 of file CPacketStreamFilter.cpp.
References CStreamFilter::close(), CStreamBuffer::getSize(), and CStreamBuffer::pop().
void CPacketStreamFilter::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 from CStreamFilter.
Definition at line 173 of file CPacketStreamFilter.cpp.
References CStreamFilter::filterEvent(), IStream::getInputReadyEvent(), IStream::getInputShutdownEvent(), and CEvent::getType().
UInt32 CPacketStreamFilter::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.
Reimplemented from CStreamFilter.
Definition at line 118 of file CPacketStreamFilter.cpp.
bool CPacketStreamFilter::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.
Reimplemented from CStreamFilter.
Definition at line 111 of file CPacketStreamFilter.cpp.
UInt32 CPacketStreamFilter::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.
Reimplemented from CStreamFilter.
Definition at line 49 of file CPacketStreamFilter.cpp.
References CStreamFilter::getEventTarget(), IStream::getInputShutdownEvent(), CStreamBuffer::peek(), and CStreamBuffer::pop().
void CPacketStreamFilter::shutdownInput | ( | ) | [virtual] |
Shutdown input.
Shutdown the input side of the stream. Any pending input data is discarded and further reads immediately return 0.
Reimplemented from CStreamFilter.
Definition at line 102 of file CPacketStreamFilter.cpp.
References CStreamBuffer::getSize(), CStreamBuffer::pop(), and CStreamFilter::shutdownInput().
void CPacketStreamFilter::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.
Reimplemented from CStreamFilter.
Definition at line 87 of file CPacketStreamFilter.cpp.
References CStreamFilter::getStream(), and IStream::write().