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

strmod::strmod::StreamProcessor Class Reference

Describes a simple non-active processor of a unidirectional data stream that has one input and one output. More...

#include <StrMod/StreamProcessor.h>

Inheritance diagram for strmod::strmod::StreamProcessor:

Inheritance graph
[legend]
List of all members.

Public Methods

 StreamProcessor ()
 Abstract base classes don't have substansive constructors.

virtual ~StreamProcessor ()
 Abstract base classes don't have substansive destructors.

virtual int AreYouA (const lcore::ClassIdent &cid) const
 Asks if a class is of a particular type, or publicly derived from that type.

bool canWriteTo () const
 Can you put data into this thing? Note that this is !incoming_.

void writeTo (const StrChunkPtr &chnk)
 Shove in some data. Must not be called when !canWriteTo().

bool canReadFrom () const
 Can you get any data from this thing? Note that this is outgoing_ready_.

const StrChunkPtr readFrom ()
 Pull out some data. Must not be called when !canReadFrom().


Static Public Attributes

const STR_ClassIdent identifier
 Globally unique identifier for this class.


Protected Methods

virtual const lcore::ClassIdent * i_GetIdent () const
 Returns the class identifier for the class the object actually is.

virtual void processIncoming ()=0
 Do something with your incoming_ data.


Protected Attributes

StrChunkPtr incoming_
 Where to find the incoming data when processIncoming() is called.

StrChunkPtr outgoing_
 Where to stick data that's ready to go out.

bool outgoing_ready_
 Set this when the data in outgoing_ is actually ready to go out.


Detailed Description

Describes a simple non-active processor of a unidirectional data stream that has one input and one output.

Non-active means that this things readable or writeable status can't change unless it's a result of being read or written to.

This class is intended to be used with a ProcessorModule to create modules that do some sort of processing on every chunk that passes through.

A prime example of this sort of thing are streams that re-chunk the data passing through them according to some criteria. Another example is a stream which simply prepends a header of some sort to every chunk coming through.

Another prime example is a process in a Unix pipeline.

Definition at line 66 of file StreamProcessor.h.


Member Function Documentation

int strmod::strmod::StreamProcessor::AreYouA const lcore::ClassIdent &    cid const [inline, virtual]
 

Asks if a class is of a particular type, or publicly derived from that type.

Overriden in every derived class (with a static identifier member) to compare against the identifier, then call the AreYouA methods of all the superclasses.

Parameters:
cid Usually <class>::identifier for the class you want to ask if the object is an instance of.

Reimplemented from strmod::lcore::Protocol.

Reimplemented in strmod::strmod::CharChopper, strmod::strmod::NewlineChopper, strmod::strmod::PassThrough, and strmod::strmod::TelnetChunker.

Definition at line 126 of file StreamProcessor.h.

bool strmod::strmod::StreamProcessor::canReadFrom   const [inline]
 

Can you get any data from this thing? Note that this is outgoing_ready_.

It's a gross error for !outgoing_ && outgoing_ready_. Set outgoing_ready_ when the data in outgoing_ is ready to go.

Definition at line 146 of file StreamProcessor.h.

bool strmod::strmod::StreamProcessor::canWriteTo   const [inline]
 

Can you put data into this thing? Note that this is !incoming_.

This means that if you need more data to complete your processing, your must clear incoming_ and store the partially processed data someplace else, like outgoing_.

Definition at line 131 of file StreamProcessor.h.

virtual const lcore::ClassIdent* strmod::strmod::StreamProcessor::i_GetIdent   const [inline, protected, virtual]
 

Returns the class identifier for the class the object actually is.

Should always be overridden in any class that has a static identifier member.

Reimplemented from strmod::lcore::Protocol.

Reimplemented in strmod::strmod::NewlineChopper, strmod::strmod::PassThrough, and strmod::strmod::TelnetChunker.

Definition at line 101 of file StreamProcessor.h.

virtual void strmod::strmod::StreamProcessor::processIncoming   [protected, pure virtual]
 

Do something with your incoming_ data.

Precondition:
(incoming_ && !outoing_ready_) will always be true when entering this function, meaning that incoming_ points at a valid chunk.
Postcondition:
A post condition of this function is (!incoming_ || (outgoing_ready_ && outgoing_)).

Implemented in strmod::strmod::PassThrough, and strmod::strmod::TelnetChunker.


Member Data Documentation

const STR_ClassIdent strmod::strmod::StreamProcessor::identifier [static]
 

Globally unique identifier for this class.

Every class that might need to be identified should have a public static const identifier object in it.

Reimplemented from strmod::lcore::Protocol.

Reimplemented in strmod::strmod::CharChopper, strmod::strmod::NewlineChopper, strmod::strmod::PassThrough, and strmod::strmod::TelnetChunker.


The documentation for this class was generated from the following files:
Generated on Wed Jan 29 00:32:56 2003 for libNet by doxygen1.3-rc1