Yate
|
A message container class. More...
#include <yatengine.h>
Public Member Functions | |
Message (const char *name, const char *retval=0, bool broadcast=false) | |
Message (const Message &original) | |
Message (const Message &original, bool broadcast) | |
~Message () | |
virtual void * | getObject (const String &name) const |
String & | retValue () |
const String & | retValue () const |
RefObject * | userData () const |
void | userData (RefObject *data) |
void * | userObject (const String &name) const |
void | setNotify (bool notify=true) |
bool | broadcast () const |
Time & | msgTime () |
const Time & | msgTime () const |
Message & | operator= (const char *value) |
String | encode (const char *id) const |
String | encode (bool received, const char *id) const |
int | decode (const char *str, String &id) |
int | decode (const char *str, bool &received, const char *id) |
Protected Member Functions | |
virtual void | dispatched (bool accepted) |
Friends | |
class | MessageDispatcher |
A message container class.
This class holds the messages that are moved around in the engine.
Message | ( | const char * | name, |
const char * | retval = 0 , |
||
bool | broadcast = false |
||
) | [explicit] |
Creates a new message.
name | Name of the message - must not be NULL or empty |
retval | Default return value |
broadcast | Broadcast flag, true if handling the mesage must not stop it |
Copy constructor. Note that user data and notification are not copied
original | Message we are copying from |
Copy constructor that can alter the broadcast flag. Note that user data and notification are not copied
original | Message we are copying from |
broadcast | Broadcast flag, true if handling the mesage must not stop it |
~Message | ( | ) |
Destruct the message and dereferences any user data
bool broadcast | ( | ) | const [inline] |
Retrieve the broadcast flag
Decode a string from an external communication interface for processing in the engine. The message is modified accordingly.
int decode | ( | const char * | str, |
bool & | received, | ||
const char * | id | ||
) |
Decode a string from an external communication interface that is an answer to a specific external processing request.
str | String to decode |
received | Pointer to variable to store the dispatch return value |
id | The identifier expected |
virtual void dispatched | ( | bool | accepted | ) | [protected, virtual] |
Notify the message it has been dispatched. The default behaviour is to call the dispatched() method of the user data if it implements MessageNotifier
accepted | True if one handler accepted the message |
Encode the message into a string adequate for sending for processing to an external communication interface
id | Unique identifier to add to the string |
Encode the message into a string adequate for sending as answer to an external communication interface
received | True if message was processed locally |
id | Unique identifier to add to the string |
Get a pointer to a derived class given that class name
name | Name of the class we are asking for |
Reimplemented from NamedList.
Retrieve a reference to the creation time of the message.
Retrieve a const reference to the creation time of the message.
Message& operator= | ( | const char * | value | ) | [inline] |
Retrieve a reference to the value returned by the message.
Retrieve a const reference to the value returned by the message.
void setNotify | ( | bool | notify = true | ) | [inline] |
Enable or disable notification of any MessageNotifier that was set as user data. This method must be called after userData()
notify | True to have the message call the notifier |
Retrieve the object associated with the message
Set obscure data associated with the message. The user data is reference counted to avoid stray pointers. Note that setting new user data will disable any notification.
data | Pointer to arbitrary user data |
void* userObject | ( | const String & | name | ) | const [inline] |
Get a pointer to a derived class of user data given that class name
name | Name of the class we are asking for |