#include <Message.hh>
List of all members.
Detailed Description
Class to represent all messages sent and received by mailboxes and streams.
This class is used to represent all messages sent and received by the communication manager's mailboxes and streams. Primarily a message wraps an array of bytes of a fixed size, and then indicates how much of that array actually containes data. The Message class also provides access to message time stamps, and message sources as well as providing convenience methods for packaging and unpackaging the message data.
Most of the time developers will not be creating or destroying messages, as the creation and destruction of Message instances will be handled by the higher level entities. In general, you should not do it on your own as the mailboxes, mailers, stream sources, and stream sinks have facilities for efficiently managing messages to minimize the number of memory allocations and copies occuring in message processing.
|
Public Member Functions |
| Message (int max_size) |
| ~Message () |
void | clear () |
unsigned char * | getData () const |
int | getSize () const |
void | setSize (int size) |
int | getMaxSize () const |
TimeStamp | getTimeStamp () const |
void | setTimeStamp (TimeStamp t) |
RemoteManager * | getSource () const |
void | setSource (RemoteManager *rem) |
com_id_t | getID () const |
void | setID (com_id_t id) |
void | copy (Message *source) |
unsigned char | type () const |
void | setType (unsigned char t) |
void * | typeData () const |
void | setTypeData (void *d) |
int | isInProcess () const |
void | inProcess (int p) |
int | getInt () const |
double | getDouble () const |
bool | setInt (int i) |
bool | setDouble (double d) |
template<class T> bool | setStruct (T *val) |
template<class T> bool | getStruct (T *val) |
Protected Attributes |
Byte * | _data |
int | _max_size |
int | _size |
TimeStamp | _time |
RemoteManager * | _remote_mgr |
com_id_t | _id |
unsigned char | _type |
void * | _type_data |
int | _in_process |
Constructor & Destructor Documentation
Message::Message |
( |
int |
max_size |
) |
|
|
|
Creates a message with a maximum size of "max_size". |
|
Frees up all memory associated with a message. |
Member Function Documentation
unsigned char* Message::getData |
( |
|
) |
const [inline] |
|
|
This method returns a pointer to the message's block of data. |
double Message::getDouble |
( |
|
) |
const |
|
|
This is a convenience method for extracting a double precision floating point number out of the message block. If the size of the message data is less than the size of a double, the method returns 0. |
int Message::getInt |
( |
|
) |
const |
|
|
This is a convenience method for extracting an integer out of the message block. If the size of the message data is less than the size of an integer, the method returns 0. |
int Message::getMaxSize |
( |
|
) |
const [inline] |
|
|
This method returns the maximum size of the message's block of data. |
int Message::getSize |
( |
|
) |
const [inline] |
|
|
This method returns the number of bytes in the message's block of data. |
|
In the case of a received message, this method returns a reference to the message sender. |
template<class T> |
bool Message::getStruct |
( |
T * |
val |
) |
|
|
|
This is a templated convenience method for copying a structure of type "T" to the message data. If the maximum size of the message is greater than the size of type T, then the structure pointed to by "val" is copied into the message data and the message size is set to the size of the type T, and true is returned. Otherwise false nothing is done and false is returned. |
TimeStamp Message::getTimeStamp |
( |
|
) |
const [inline] |
|
|
In the case of a received message, this method returns the time of receipt. |
bool Message::setDouble |
( |
double |
d |
) |
|
|
|
This is a convenience method for setting the message's data to be the double d. If the maximum size of the message data is less than the size of an integer, the method returns false and does nothing, otherwise the method sets the message data and the message size appropriately and returns true. |
bool Message::setInt |
( |
int |
i |
) |
|
|
|
This is a convenience method for setting the message's data to be the integer i. If the maximum size of the message data is less than the size of an integer, the method returns false and does nothing, otherwise the method sets the message data and the message size appropriately and returns true. |
void Message::setSize |
( |
int |
size |
) |
|
|
|
This method sets the number of bytes in the message's block of data. |
template<class T> |
bool Message::setStruct |
( |
T * |
val |
) |
|
|
|
This is a templated convenience method for extracting a structure of type "T" from the message data. If the size of the message data is greater than the size of type T, then the appropriate number of bytes are copied from the message data to the pointer "val" and true is returned. Otherwise, nothing is done and false is returned. |
RHexLib Reference Documentation