Generic message type. More...
#include <Message.h>
Public Member Functions | |
void | deserialize (MessageVariant &variant) const |
Attempt to deserialize this message into a variant. | |
std::vector< uint8_t > & | getData () |
Retrieve the message data (non-const version) | |
const std::vector< uint8_t > & | getData () const |
Retrieve the message data (const version) | |
const MessageHeader & | getHeader () const |
Retrieve the message header. | |
size_t | getSize () const |
Retrieve the message size. | |
const MessageType & | getType () const |
Retrieve the message type. | |
Message () | |
Default constructor. | |
template<typename T > | |
Message (const T &message, const MessageHeader &header=MessageHeader()) | |
Constructor (templated version taking a message. | |
Message (const Message &src) | |
Copy constructor. | |
template<typename T > | |
void | morph () |
Morph the message. | |
template<typename Stream > | |
void | read (Stream &stream) |
Read serialized message contents from stream. | |
void | serialize (const MessageVariant &variant) |
Attempt to serialize this message from a variant. | |
void | setData (const std::vector< uint8_t > &data) |
Set the message data. | |
void | setHeader (const MessageHeader &header) |
Set the message header. | |
void | setSize (size_t size) |
Set the message size. | |
void | setType (const MessageType &type) |
Set the message type. | |
template<typename T > | |
boost::shared_ptr< T > | toMessage () const |
Attempt to convert the message to a strong-typed message. | |
boost::shared_ptr < variant_msgs::Variant > | toVariantMessage () const |
Attempt to convert the message to a variant message. | |
template<typename Stream > | |
void | write (Stream &stream) const |
Write serialized message contents to stream. | |
~Message () | |
Destructor. | |
Protected Attributes | |
std::vector< uint8_t > | data |
The data of this message. | |
MessageHeader | header |
The header of this message. | |
MessageType | type |
The type of this message. |
Generic message type.
This generic message type can be used to subscribe to any topic. It is heavily inspired by the ShapeShifter message type provided in the topic_tools package.
Default constructor.
Definition at line 31 of file Message.cpp.
variant_topic_tools::Message::Message | ( | const T & | message, |
const MessageHeader & | header = MessageHeader() |
||
) |
Constructor (templated version taking a message.
variant_topic_tools::Message::Message | ( | const Message & | src | ) |
Copy constructor.
Definition at line 34 of file Message.cpp.
Destructor.
Definition at line 40 of file Message.cpp.
void variant_topic_tools::Message::deserialize | ( | MessageVariant & | variant | ) | const |
Attempt to deserialize this message into a variant.
Definition at line 109 of file Message.cpp.
std::vector< uint8_t > & variant_topic_tools::Message::getData | ( | ) |
Retrieve the message data (non-const version)
Definition at line 75 of file Message.cpp.
const std::vector< uint8_t > & variant_topic_tools::Message::getData | ( | ) | const |
Retrieve the message data (const version)
Definition at line 79 of file Message.cpp.
const MessageHeader & variant_topic_tools::Message::getHeader | ( | ) | const |
Retrieve the message header.
Definition at line 55 of file Message.cpp.
size_t variant_topic_tools::Message::getSize | ( | ) | const |
Retrieve the message size.
Definition at line 87 of file Message.cpp.
const MessageType & variant_topic_tools::Message::getType | ( | ) | const |
Retrieve the message type.
Definition at line 67 of file Message.cpp.
void variant_topic_tools::Message::morph | ( | ) |
Morph the message.
void variant_topic_tools::Message::read | ( | Stream & | stream | ) |
Read serialized message contents from stream.
void variant_topic_tools::Message::serialize | ( | const MessageVariant & | variant | ) |
Attempt to serialize this message from a variant.
Definition at line 95 of file Message.cpp.
void variant_topic_tools::Message::setData | ( | const std::vector< uint8_t > & | data | ) |
Set the message data.
Definition at line 71 of file Message.cpp.
void variant_topic_tools::Message::setHeader | ( | const MessageHeader & | header | ) |
Set the message header.
Definition at line 47 of file Message.cpp.
void variant_topic_tools::Message::setSize | ( | size_t | size | ) |
Set the message size.
Definition at line 83 of file Message.cpp.
void variant_topic_tools::Message::setType | ( | const MessageType & | type | ) |
Set the message type.
Definition at line 59 of file Message.cpp.
boost::shared_ptr<T> variant_topic_tools::Message::toMessage | ( | ) | const |
Attempt to convert the message to a strong-typed message.
boost::shared_ptr< variant_msgs::Variant > variant_topic_tools::Message::toVariantMessage | ( | ) | const |
Attempt to convert the message to a variant message.
Definition at line 126 of file Message.cpp.
void variant_topic_tools::Message::write | ( | Stream & | stream | ) | const |
Write serialized message contents to stream.
std::vector<uint8_t> variant_topic_tools::Message::data [protected] |
MessageHeader variant_topic_tools::Message::header [protected] |
MessageType variant_topic_tools::Message::type [protected] |