#include <StrMod/SimpleMulti.h>
Inheritance diagram for strmod::strmod::SimpleMultiplexer:

Count adjusting functions. | |
| These functions maintain a count of MultiPlugs that are in a particular state.
The counts are used for adjusting the SingPlug's readable or writeable state. This provides a way for the plugs, which don't directly know about eachother, to communicate. adjustMultiWriteables adjusts the number of MultiPlugs who's partners are writeable. If there are none, the SinglePlug's state is changed to not be writeable. A write to a SinglePlug where there are no MultiPlug partners to forward that data onto would be counterproductive and introduce unecessary buffering.
adjustMultiReadables adjusts the number of MultiPlugs who's partners are readable. If there are no such MultiPlugs, then the SinglePlug won't be able to be read from. If there is even one MultiPlug who's partner is readable, then a read from the SinglePlug will read from that MultiPlug's partner, so the SinglePlug should be set to readable. | |
| enum | AdjDir { ADJ_Down, ADJ_Up } |
| Use to say which direction an adjustment should go in. | |
| void | adjustMultiReadables (AdjDir dir) |
| Adjust the number of MultiPlugs who's partners are in a readable state. | |
| void | adjustMultiWriteables (AdjDir dir) |
| Adjust the number of MultiPlugs who's partners are in a writeable state. | |
Public Types | |
| enum | PublicSides { SingleSide, MultiSide } |
| The two sides available in a SimpleMultiplexer. More... | |
Public Methods | |
| SimpleMultiplexer (unievent::Dispatcher &disp) | |
| Construct a SimpleMultiplexer. | |
| virtual | ~SimpleMultiplexer () |
| Also destroys all Plug's and any unsent data. | |
| 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 |
| 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 | |
Protected Methods | |
| virtual void | plugDisconnected (Plug *plug) |
| Called whenever a plug is disconnected. | |
| virtual Plug * | i_MakePlug (int side) |
| Makes a plug on the given side. | |
| void | postScan (MultiPlug &toend) |
| If a scan event isn't posted, post one. | |
| void | doPost () |
| Post a scan event to dispatcher_. | |
| void | moveToEnd (MultiPlug &toend) |
| Move a MultiPlug to the end of the list. | |
| void | multiDidRead (MultiPlug &mplug) |
| Process the fact that a MultiPlug read the mchunk_. | |
| void | doScan () |
| This is called by ScanEvent when its triggerEvent method is called. | |
Friends | |
| class | MultiPlug |
| class | SinglePlug |
| class | mpother_readable_p |
| class | mp_written_p |
| class | auto_mpptr |
| class | ScanEvent |
This implements a simple multiplexer that duplicates all input on the 'single' side to all the plugs attached to the 'multi' side, and combines all the data from the 'multi' side into one flow on the 'single' side.
A 'multi' side plug that isn't plugged in is considered to be dead, and no data is routed to it. This prevents the stream from backing up.
Currently, 'multi' side plug deletion is implemented by simply unplugging the plug. Please don't take advantage of this detail. In the future, 'multi' side plugs will be actually deleted.
Definition at line 57 of file SimpleMulti.h.
|
|
The two sides available in a SimpleMultiplexer.
Definition at line 67 of file SimpleMulti.h. |
|
|
Construct a SimpleMultiplexer. The strmod::unievent::Dispatcher is needed for making sure data from all MultiSide plugs is handled fairly. Whenever the SimpleMultiplexer gets data from a MultiPlug, it flags that plug as non-writeable and posts an event to a strmod::unievent::Dispatcher. When that event is fired, it resets all MultiPlugs to being writeable again. The prevens any MultiPlug from monopolizing the SinglePlug.
Definition at line 394 of file SimpleMulti.cxx. |
|
|
Adjust the number of MultiPlugs who's partners are in a readable state. This may cause the SinglePlug's readable state to change. Definition at line 468 of file SimpleMulti.cxx. |
|
|
Adjust the number of MultiPlugs who's partners are in a writeable state. This may cause the SinglePlug's writeable state to change. Definition at line 487 of file SimpleMulti.cxx. |
|
|
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.
Reimplemented from strmod::strmod::StreamModule. Definition at line 235 of file SimpleMulti.h. |
|
|
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 602 of file SimpleMulti.cxx. |
|
|
This is called by ScanEvent when its triggerEvent method is called. This resets the 'haswritten' flags of all the MultiPlugs to false. This flag is used to ensure that one MultiPlug can't monopolize the SinglePlug. A MultiPlug that has written is not allowed to write again until all other MultiPlugs also have a chance to write. Definition at line 554 of file SimpleMulti.cxx. |
|
|
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. Definition at line 528 of file SimpleMulti.cxx. |
|
|
Called whenever a plug is disconnected. Used here to record a MultiPlug as having read the mchunk_ if it's disconnected while it's waiting to be read from. Also calls StreamModule::plugDisconnected so that PDstrategy handling and things can be done there. Reimplemented from strmod::strmod::StreamModule. Definition at line 509 of file SimpleMulti.cxx. |
|
|
If a scan event isn't posted, post one. A scan is always posted because a piece of data came into a MultiPlug, and data is only allowed to into a MultiPlug once per scan. Data coming into a plug is also cause for that plug to be considered last when checking for data to pull in through a plug. Definition at line 251 of file SimpleMulti.h. |
1.3-rc1