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

strmod::strmod::RouterModule Class Reference

Provides an abstract base for classes that route chunks from a plug to a set of other plugs based on contents. More...

#include <StrMod/RouterModule.h>

Inheritance diagram for strmod::strmod::RouterModule:

Inheritance graph
[legend]
List of all members.

Public Methods

 RouterModule (unievent::Dispatcher &disp)
 Construct, given the strmod::unievent::Dispatcher to use to post scan events.

virtual ~RouterModule ()
 Destroy the RouterModule and all of its plugs.

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

virtual bool canCreate (int side) const=0
 Can a plug be created on the given side?

virtual bool ownsPlug (const Plug *plug) const
 Does the module own this plug?

virtual bool deletePlug (Plug *plug)
 Please delete this plug.


Static Public Attributes

const STR_ClassIdent identifier
 A unique identifier for this class.


Protected Types

typedef std::deque< RPlug * > RPlugList
 Just a type alias to avoid errors in typing deque<RPlug *>.

typedef std::back_insert_iterator<
RPlugList
RPlugAdder
 Just a type alias to avoid errors in typing back_insert_iterator<RPlugList>.


Protected Methods

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

virtual Plug * i_MakePlug (int side)=0
 Makes a plug on the given side.

void addNewPlug (RPlug *rp)
 Add a new plug to the internal list of all plugs.

void postScan ()
 If a scan event isn't posted, post one.

virtual void getDestinations (const StrChunkPtr &chunk, const RPlug &source, const RPlugList::const_iterator &begin, const RPlugList::const_iterator &end, RPlugAdder &destlist) const=0
 Compute a list of destination plugs for a given incoming chunk.


Friends

class RPlug
class ScanEvent

Detailed Description

Provides an abstract base for classes that route chunks from a plug to a set of other plugs based on contents.

Definition at line 49 of file RouterModule.h.


Member Function Documentation

void strmod::strmod::RouterModule::addNewPlug RPlug *    rp [protected]
 

Add a new plug to the internal list of all plugs.

Must be called before i_MakePlug returns a new plug!

Definition at line 129 of file RouterModule.cxx.

virtual int strmod::strmod::RouterModule::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::strmod::StreamModule.

Definition at line 67 of file RouterModule.h.

bool strmod::strmod::RouterModule::deletePlug Plug *    plug [virtual]
 

Please delete this plug.

Modules are supposed to own plugs, so you aren't supposed to delete them yourself.

Returns false on failure. Failure could happen because module does not own the plug.

Implements strmod::strmod::StreamModule.

Definition at line 109 of file RouterModule.cxx.

virtual void strmod::strmod::RouterModule::getDestinations const StrChunkPtr   chunk,
const RPlug &    source,
const RPlugList::const_iterator &    begin,
const RPlugList::const_iterator &    end,
RPlugAdder   destlist
const [protected, pure virtual]
 

Compute a list of destination plugs for a given incoming chunk.

Parameters:
chunk The chunk that's going somewhere.
source Where it came from.
begin Beginning of a list of all RPlugs in this RouterModule.
end STL style end of list started at begin.
destlist Output iterator to store destination plugs in.

virtual const lcore::ClassIdent* strmod::strmod::RouterModule::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::strmod::StreamModule.

Definition at line 78 of file RouterModule.h.

virtual Plug* strmod::strmod::RouterModule::i_MakePlug int    side [protected, pure virtual]
 

Makes a plug on the given side.

Guaranteed to never be called if canCreate would return false. Must NEVER return 0 (NULL).

Implements strmod::strmod::StreamModule.

void strmod::strmod::RouterModule::postScan   [inline, protected]
 

If a scan event isn't posted, post one.

A scan is always posted because a piece of data came in from an RPlug, and data is only allowed to in from a particular RPlug once per scan. This is to ensure that one RPlug cannot monopolize the RouterModule.

Definition at line 163 of file RouterModule.h.


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