# Message Class Reference

A message container class. More...

`#include <yatengine.h>`

Inheritance diagram for Message:

List of all members.

## Public Member Functions

| Message (const char *name, const char *retval=0)
| Message (const Message &original)
| ~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)
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

## Detailed Description

A message container class.

This class holds the messages that are moved around in the engine.

## Constructor & Destructor Documentation

Message | ( | const char * | name,
|  | const char * | retval = `0` |
| ) |  |  |

Creates a new message.

Parameters:

  | name | Name of the message - must not be NULL or empty
  | retval | Default return value

Message | ( | const Message & | original | ) |

Copy constructor. Note that user data and notification are not copied.

Parameters:

  | original | Message we are copying from

~Message | ( |  | ) |

Destruct the message and dereferences any user data

## Member Function Documentation

virtual void* getObject | ( | const String & | name | ) | const`[virtual]`

Get a pointer to a derived class given that class name

Parameters:

  | name | Name of the class we are asking for

Returns:
  Pointer to the requested class or NULL if this object doesn't implement it

Reimplemented from NamedList.

String& retValue | ( |  | ) | `[inline]`

Retrive a reference to the value returned by the message.

Returns:
  A reference to the value the message will return

const String& retValue | ( |  | ) | const`[inline]`

Retrive a const reference to the value returned by the message.

Returns:
  A reference to the value the message will return

RefObject* userData | ( |  | ) | const`[inline]`

Retrive the object associated with the message

Returns:
  Pointer to arbitrary user RefObject

void userData | ( | RefObject * | data | ) |

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.

Parameters:

  | 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

Parameters:

  | name | Name of the class we are asking for

Returns:
  Pointer to the requested class or NULL if user object id NULL or doesn't implement it

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()

Parameters:

  | notify | True to have the message call the notifier

Time& msgTime | ( |  | ) | `[inline]`

Retrive a reference to the creation time of the message.

Returns:
  A reference to the Time when the message was created

const Time& msgTime | ( |  | ) | const`[inline]`

Retrive a const reference to the creation time of the message.

Returns:
  A reference to the Time when the message was created

Message& operator= | ( | const char * | value | ) | `[inline]`

Name assignment operator

Reimplemented from String.

String encode | ( | const char * | id | ) | const

Encode the message into a string adequate for sending for processing to an external communication interface

Parameters:

  | id | Unique identifier to add to the string

String encode | ( | bool | received,
|  | const char * | id |
| ) |  |  | const

Encode the message into a string adequate for sending as answer to an external communication interface

Parameters:

  | received | True if message was processed locally
  | id | Unique identifier to add to the string

int decode | ( | const char * | str,
|  | String & | id |
| ) |  |  |

Decode a string from an external communication interface for processing in the engine. The message is modified accordingly.

Parameters:

  | str | String to decode
  | id | A String object in which the identifier is stored

Returns:
  -2 for success, -1 if the string was not a text form of a message, index of first erroneous character if failed

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.

Parameters:

  | str | String to decode
  | received | Pointer to variable to store the dispatch return value
  | id | The identifier expected

Returns:
  -2 for success, -1 if the string was not the expected answer, index of first erroneous character if failed

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

Parameters:

  | accepted | True if one handler accepted the message

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

- yatengine.h