libglass::PluginBase Class Reference

#include <plugin.h>

Inheritance diagram for libglass::PluginBase:

libglass::AliasBase libglass::BarrierBase libglass::EventBase libglass::MessengerBase libglass::RemoteBase libglass::SharedBase libglass::StreamBase

List of all members.

Public Member Functions

 PluginBase (const PluginId id, bool *registered)
virtual ~PluginBase ()=0
PluginId getPluginId (void) const

Protected Member Functions

virtual bool processPacket (Packet &p)=0
virtual PluginBaseinstance (PluginManager *parent)=0
virtual void unregisterNode (nodeId id)=0
virtual bool sendPacket (Packet &p)
nodeRelation getNodeRelation (nodeId id) const
GlassgetGlass (void) const

Protected Attributes

PluginManagerpm_parent

Friends

class PluginManagerBase
class PluginManager


Detailed Description

Base class for all plugins.

Let me explain in the philosophy of PluginBase and derived classes. This is a singleton class (per PluginManager instance, that is) that should be unknown to the user. This is a good thing (TM), because the user doesn't have to use static methods to get a handle and all that kind of stuff. This class has a virtual method processPacket() that is called for every packet that arrives for this plugin.

To let the user interact with the plugin, you should provide classes derived from PluginInterface. These classes are not singletons, and they provide a method to talk to PluginBase. You can keep track of all these objects, calling the PluginBase class from the constructor, etc.

Since you're probably not following this lousy explanation, let's see an example. I'll use the Barrier plugin to illustrate this discussion. First, you have the PluginBase derived class, which is BarrierBase. This class is responsible for processing all barrier packets.

If the user wants to setup a barrier, he'll create a instance of another class, Barrier (which is derived from PluginInterface). To him, BarrierBase doesn't exist. When a Barrier is instanced, it calls BarrierBase, which keeps track of all Barrier objects. This way BarrierBase can release barriers when the appropriate packets arrive, etc.

Definition at line 235 of file plugin.h.


Constructor & Destructor Documentation

libglass::PluginBase::PluginBase ( const PluginId  id,
bool *  registered 
)

Constructor.

virtual libglass::PluginBase::~PluginBase (  )  [pure virtual]

Destructor.


Member Function Documentation

Glass* libglass::PluginBase::getGlass ( void   )  const [protected]

Get Glass wrapper.

Returns:
Our Glass owner.

nodeRelation libglass::PluginBase::getNodeRelation ( nodeId  id  )  const [protected]

Get node type wrapper.

Returns:
Our node type.

PluginId libglass::PluginBase::getPluginId ( void   )  const

Returns this plugin's id.

virtual PluginBase* libglass::PluginBase::instance ( PluginManager parent  )  [protected, pure virtual]

Virtual constructor, used by PluginManagerBase::createPluginManager.

This function is automatically created by PLUGIN(cl).

Parameters:
parent Our parent PluginManager, to fill pm_parent.
Returns:
A brand new PluginBase.

virtual bool libglass::PluginBase::processPacket ( Packet p  )  [protected, pure virtual]

Callback from PluginManager.

This prototype is automatically added by PLUGIN(cl).

Parameters:
p The packet to process.
Return values:
true If packet was correctly processed.
false Otherwise.
See also:
sendPacket().

virtual bool libglass::PluginBase::sendPacket ( Packet p  )  [protected, virtual]

Wrapper to send a packet. You can override if desired.

Parameters:
p The packet to send.
Return values:
true If packet was correctly sent.
false Otherwise.
See also:
processPacket().

virtual void libglass::PluginBase::unregisterNode ( nodeId  id  )  [protected, pure virtual]

Clean up system.

Guarantees that a node quit event is properly handled by the plugin, avoiding potential deadlocks.

This prototype is automatically added by PLUGIN(cl).

Parameters:
id The nodeId of the node.


Friends And Related Function Documentation

friend class PluginManager [friend]

Definition at line 244 of file plugin.h.

friend class PluginManagerBase [friend]

Definition at line 243 of file plugin.h.


Member Data Documentation

Our boss and owner.

Definition at line 249 of file plugin.h.


The documentation for this class was generated from the following file:

Generated on Fri May 28 13:19:01 2010 for libGlass by  doxygen 1.5.8