Nebula
Loading...
Searching...
No Matches
Messaging::Dispatcher Class Reference

#include <dispatcher.h>

Detailed Description

A message Dispatcher is a specialization of a message Port.

A message Dispatcher distributes all messages it receives to the attached Ports which are interested in this message id.

                                +------+
                            +-->| Port |
                           /    +------+
            +------------+/     +------+
--- Msg --->| Dispatcher |----->| Port |
            +------------+\     +------+
                           \    +------+
                            +-->| Port |
                                +------+

Dispatcher objects usually serve as front end message ports which hide a more complex message processing infrastructure underneath.

Inherits Messaging::Port.

Public Member Functions

 Dispatcher ()
 constructor
virtual void HandleMessage (const Ptr< Messaging::Message > &msg)
 handle a single message (distribute to ports which accept the message)
void AttachPort (const Ptr< Port > &port)
 attach a message port
void RemovePort (const Ptr< Port > &port)
 remove a message port
bool HasPort (const Ptr< Port > &port) const
 return true if a port exists
Public Member Functions inherited from Messaging::Port
virtual void SetupAcceptedMessages ()
 override to register accepted messages
void AttachHandler (const Ptr< Handler > &h)
 attach a message handler to the port
void RemoveHandler (const Ptr< Handler > &h)
 remove a message handler from the port
void RemoveAllHandlers ()
 remove all message handler from the port
SizeT GetNumHandlers () const
 return number of handlers attached to the port
const Ptr< Handler > & GetHandlerAtIndex (IndexT i) const
 get a message handler by index
virtual void Send (const Ptr< Message > &msg)
 send a message to the port
const Util::Array< const Id * > & GetAcceptedMessages () const
 get the array of accepted messages (sorted)
bool AcceptsMessage (const Id &msgId) const
 return true if port accepts this msg
Public Member Functions inherited from Core::RefCounted
 RefCounted ()
 constructor
int GetRefCount () const
 get the current refcount
void AddRef ()
 increment refcount by one
void Release ()
 decrement refcount and destroy object if refcount is zero
bool IsInstanceOf (const Rtti &rtti) const
 return true if this object is instance of given class
bool IsInstanceOf (const Util::String &className) const
 return true if this object is instance of given class by string
bool IsInstanceOf (const Util::FourCC &classFourCC) const
 return true if this object is instance of given class by fourcc
bool IsA (const Rtti &rtti) const
 return true if this object is instance of given class, or a derived class
bool IsA (const Util::String &rttiName) const
 return true if this object is instance of given class, or a derived class, by string
bool IsA (const Util::FourCC &rttiFourCC) const
 return true if this object is instance of given class, or a derived class, by fourcc
const Util::StringGetClassName () const
 get the class name
Util::FourCC GetClassFourCC () const
 get the class FourCC code

Private Member Functions

 __DeclareClass (Dispatcher)

Private Attributes

Util::Array< Ptr< Port > > portArray
Util::Array< Util::Array< Ptr< Port > > > idPorts
Util::Dictionary< const Id *, IndexTidPortMap

Additional Inherited Members

Static Public Member Functions inherited from Core::RefCounted
static void DumpRefCountingLeaks ()
 dump refcounting leaks, call at end of application (NEBULA_DEBUG builds only!)
Protected Member Functions inherited from Messaging::Port
void RegisterMessage (const Id &msgId)
 register a single accepted message
Protected Member Functions inherited from Core::RefCounted
virtual ~RefCounted ()
 destructor (called when refcount reaches zero)

Constructor & Destructor Documentation

◆ Dispatcher()

Messaging::Dispatcher::Dispatcher ( )

constructor

Member Function Documentation

◆ __DeclareClass()

Messaging::Dispatcher::__DeclareClass ( Dispatcher )
private

◆ AttachPort()

void Messaging::Dispatcher::AttachPort ( const Ptr< Port > & port)

attach a message port

Attach a new message port.

Parameters
portpointer to a message port object

◆ HandleMessage()

void Messaging::Dispatcher::HandleMessage ( const Ptr< Messaging::Message > & msg)
virtual

handle a single message (distribute to ports which accept the message)

Handle a message.

The message will only be distributed to ports which accept the message.

Reimplemented from Messaging::Port.

◆ HasPort()

bool Messaging::Dispatcher::HasPort ( const Ptr< Port > & port) const

return true if a port exists

Return true if a port is already attached.

◆ RemovePort()

void Messaging::Dispatcher::RemovePort ( const Ptr< Port > & port)

remove a message port

Remove a message port object.

Parameters
handlerpointer to message port object to be removed

Member Data Documentation

◆ idPortMap

Util::Dictionary<const Id*,IndexT> Messaging::Dispatcher::idPortMap
private

◆ idPorts

Util::Array<Util::Array<Ptr<Port> > > Messaging::Dispatcher::idPorts
private

◆ portArray

Util::Array<Ptr<Port> > Messaging::Dispatcher::portArray
private

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