MRPT logo

mrpt::utils::CMRPTMessage Class Reference

A class that contain generic messages, that can be sent and received from a "CClientTCPSocket" object. More...

#include <mrpt/utils/CMRPTMessage.h>

List of all members.

Public Member Functions

void serializeObject (CSerializable *obj)
 A method for serializing a MRPT's object into the content.
void deserializeIntoExistingObject (CSerializable *obj)
 A method that parse the data in the message into an existing object.
void deserializeIntoNewObject (CSerializablePtr &obj)
 A method that parse the data in the message into a new object of (a priori) unknown class.
void setContentFromString (const std::string &str)
 Sets the contents of the message from a string.
void getContentAsString (std::string &str)
 Gets the contents of the message as a string.
void setContentFromPointer (void *ptr)
 Sets the contents of the message from a "void*" (the pointer itself becomes the message) - This is intended for inter-thread comms only.
void * getContentAsPointer () const
 Gets the contents of the message as a "void*" (the pointer itself is the message) - This is intended for inter-thread comms only.
template<class T >
void setContentFromStruct (const T &data)
 Sets the contents of the message from an arbitary structure - This is intended for inter-thread comms only, the message will be not cross-platform.
template<class T >
void getContentAsStruct (T &data) const
 Gets the contents of the message as an arbitary structure - This is intended for inter-thread comms only, the message will be not cross-platform.

Public Attributes

uint32_t type
 An identifier of the message type.
std::vector< unsigned char > content
 The contents of the message (memory is automatically handled by the std::vector object).


Detailed Description

A class that contain generic messages, that can be sent and received from a "CClientTCPSocket" object.

A message consists of a "header" (or type), and a "body" (or content). Apart from arbitrary data, specific methods are provided for easing the serialization of MRPT's "CSerializable" objects. This class is also used for passing data to hardware interfaces (see )

See also:
CClientTCPSocket

Definition at line 47 of file CMRPTMessage.h.


Member Function Documentation

void mrpt::utils::CMRPTMessage::deserializeIntoExistingObject ( CSerializable obj  ) 

A method that parse the data in the message into an existing object.

Note that the class of the object must be known and must match the one of the serialized object. std::exception On corrupt data, unknown serialized objects, unknown serialized object version, non-matching classes,...

void mrpt::utils::CMRPTMessage::deserializeIntoNewObject ( CSerializablePtr obj  ) 

A method that parse the data in the message into a new object of (a priori) unknown class.

The pointer will contain on return a copy of the reconstructed object. Deleting this object when no longer required is the responsability of the user. Note that previous contents of the pointer will be ignored (it should be NULL). std::exception On corrupt data, unknown serialized objects, unknown serialized object version,...

void* mrpt::utils::CMRPTMessage::getContentAsPointer (  )  const

Gets the contents of the message as a "void*" (the pointer itself is the message) - This is intended for inter-thread comms only.

See also:
setContentFromPointer

void mrpt::utils::CMRPTMessage::getContentAsString ( std::string &  str  ) 

Gets the contents of the message as a string.

See also:
setContentFromString

template<class T >
void mrpt::utils::CMRPTMessage::getContentAsStruct ( T &  data  )  const [inline]

Gets the contents of the message as an arbitary structure - This is intended for inter-thread comms only, the message will be not cross-platform.

See also:
setContentFromStruct

Definition at line 113 of file CMRPTMessage.h.

References ASSERT_, MRPT_TRY_END, and MRPT_TRY_START.

void mrpt::utils::CMRPTMessage::serializeObject ( CSerializable obj  ) 

A method for serializing a MRPT's object into the content.

Any modification to data in "content" after this will corrupt the object serialization. Member "type" is unmodified in this method.

void mrpt::utils::CMRPTMessage::setContentFromPointer ( void *  ptr  ) 

Sets the contents of the message from a "void*" (the pointer itself becomes the message) - This is intended for inter-thread comms only.

See also:
getContentAsPointer

void mrpt::utils::CMRPTMessage::setContentFromString ( const std::string &  str  ) 

Sets the contents of the message from a string.

See also:
getContentAsString

template<class T >
void mrpt::utils::CMRPTMessage::setContentFromStruct ( const T &  data  )  [inline]

Sets the contents of the message from an arbitary structure - This is intended for inter-thread comms only, the message will be not cross-platform.

See also:
getContentAsStruct

Definition at line 102 of file CMRPTMessage.h.


Member Data Documentation

std::vector<unsigned char> mrpt::utils::CMRPTMessage::content

The contents of the message (memory is automatically handled by the std::vector object).

Definition at line 56 of file CMRPTMessage.h.

An identifier of the message type.

Definition at line 52 of file CMRPTMessage.h.




Page generated by Doxygen 1.5.9 for MRPT 0.6.5 SVN:exported at Thu May 21 04:14:55 UTC 2009