The message dispatch class is used to deliver messages to a callback method by message identifier, see MessageThread. More...

#include "murl_util_message_dispatch.h"

Public Member Functions

 MessageDispatch ()
 The constructor.
 
virtual ~MessageDispatch ()
 The destructor.
 
template<class MessageClass , class ObjectClass >
Bool Register (const UInt32 messageId, ObjectClass *instance, Bool(ObjectClass::*method)(AutoPointer< MessageClass >))
 Register a method to call for a specified message identifier. More...
 
template<class MessageClass , class ObjectClass >
Bool RegisterDefault (ObjectClass *instance, Bool(ObjectClass::*method)(AutoPointer< MessageClass >))
 Register a default method to call for unknown message identifiers. More...
 
template<class ObjectClass >
Bool RegisterTimeout (ObjectClass *instance, Bool(ObjectClass::*method)(Message::AutoPtr))
 Register a method to call for timeout messages. More...
 
virtual Bool Register (UInt32 messageId, MessageCallBack::AutoPtr callBack)
 Register a callback object for a specified message identifier. More...
 
virtual Bool RegisterDefault (MessageCallBack::AutoPtr callBack)
 Register the default callback object. More...
 
virtual Bool RegisterTimeout (MessageCallBack::AutoPtr callBack)
 Register the timeout callback object. More...
 
virtual Bool Unregister (UInt32 messageId)
 Unregister a message identifier. More...
 
virtual Bool Dispatch (Message::AutoPtr &message)
 Dispatch a message by message identifier. More...
 
virtual Bool ExecuteTimeout ()
 Execute the timeout callback. More...
 

Protected Attributes

Map< UInt32, MessageCallBack::AutoPtrmMessageCallback
 The callback registry mapped by the message identifier.
 
MessageCallBack::AutoPtr mDefaultCallback
 The default callback.
 
MessageCallBack::AutoPtr mTimeoutCallback
 The timeout callback.
 

Detailed Description

The message dispatch class is used to deliver messages to a callback method by message identifier, see MessageThread.

Member Function Documentation

◆ Register() [1/2]

template<class MessageClass , class ObjectClass >
Bool Murl::Util::MessageDispatch::Register ( const UInt32  messageId,
ObjectClass *  instance,
Bool(ObjectClass::*)(AutoPointer< MessageClass >)  method 
)
inline

Register a method to call for a specified message identifier.

Template Parameters
MessageClassThe type of the message class.
ObjectClassThe type of the class to call the method.
Parameters
messageIdThe message identifier to register.
instanceThe instance pointer of the class to call the method.
methodThe method pointer to call.
Returns
true if successful, false if the message identifier is already registered.

◆ RegisterDefault() [1/2]

template<class MessageClass , class ObjectClass >
Bool Murl::Util::MessageDispatch::RegisterDefault ( ObjectClass *  instance,
Bool(ObjectClass::*)(AutoPointer< MessageClass >)  method 
)
inline

Register a default method to call for unknown message identifiers.

Template Parameters
MessageClassThe type of the message class.
ObjectClassThe type of the class to call the method.
Parameters
instanceThe instance pointer of the class to call the method.
methodThe method pointer to call.
Returns
true if successful, false if the message identifier is already registered.

◆ RegisterTimeout() [1/2]

template<class ObjectClass >
Bool Murl::Util::MessageDispatch::RegisterTimeout ( ObjectClass *  instance,
Bool(ObjectClass::*)(Message::AutoPtr method 
)
inline

Register a method to call for timeout messages.

The timeout message is a Message object with identifier ID_TIMEOUT.

Template Parameters
ObjectClassThe type of the class to call the method.
Parameters
instanceThe instance pointer of the class to call the method.
methodThe method pointer to call.
Returns
true if successful, false if the message identifier is already registered.

◆ Register() [2/2]

virtual Bool Murl::Util::MessageDispatch::Register ( UInt32  messageId,
MessageCallBack::AutoPtr  callBack 
)
virtual

Register a callback object for a specified message identifier.

A registered callback is executed by the Dispatch() method if a message with the corresponding identifier is delivered.

Parameters
messageIdThe message identifier to register.
callBackThe callback object to register.
Returns
true if successful, false if the message identifier is already registered.

◆ RegisterDefault() [2/2]

virtual Bool Murl::Util::MessageDispatch::RegisterDefault ( MessageCallBack::AutoPtr  callBack)
virtual

Register the default callback object.

The default callback is executed by the Dispatch() method if a message with a not registered identifier is delivered.

Parameters
callBackThe callback object to register.
Returns
true if successful.

◆ RegisterTimeout() [2/2]

virtual Bool Murl::Util::MessageDispatch::RegisterTimeout ( MessageCallBack::AutoPtr  callBack)
virtual

Register the timeout callback object.

Parameters
callBackThe callback object to register.
Returns
true if successful.

◆ Unregister()

virtual Bool Murl::Util::MessageDispatch::Unregister ( UInt32  messageId)
virtual

Unregister a message identifier.

Parameters
messageIdThe message identifier to unregister.
Returns
true if successful, false if the message identifier is not registered.

◆ Dispatch()

virtual Bool Murl::Util::MessageDispatch::Dispatch ( Message::AutoPtr message)
virtual

Dispatch a message by message identifier.

Execute the registered MessageCallBack of the corresponding message identifier otherwise the default callback is executed.

Parameters
messageThe message to deliver.
Returns
true if successful, false if message identifier is not registered or the callback execution failed.

◆ ExecuteTimeout()

virtual Bool Murl::Util::MessageDispatch::ExecuteTimeout ( )
virtual

Execute the timeout callback.

Returns
true if successful, false if the timeout callback is not registered or the callback execution failed.

The documentation for this class was generated from the following file:
  • murl_util_message_dispatch.h


Copyright © 2011-2024 Spraylight GmbH.