Generic message type. More...
#include <Message.h>
Public Member Functions | |
void | deserialize (MessageVariant &variant) const |
Attempt to deserialize this message into a variant. More... | |
std::vector< uint8_t > & | getData () |
Retrieve the message data (non-const version) More... | |
const std::vector< uint8_t > & | getData () const |
Retrieve the message data (const version) More... | |
const MessageHeader & | getHeader () const |
Retrieve the message header. More... | |
size_t | getSize () const |
Retrieve the message size. More... | |
const MessageType & | getType () const |
Retrieve the message type. More... | |
Message () | |
Default constructor. More... | |
template<typename T > | |
Message (const T &message, const MessageHeader &header=MessageHeader()) | |
Constructor (templated version taking a message. More... | |
Message (const Message &src) | |
Copy constructor. More... | |
template<typename T > | |
void | morph () |
Morph the message. More... | |
template<typename Stream > | |
void | read (Stream &stream) |
Read serialized message contents from stream. More... | |
void | serialize (const MessageVariant &variant) |
Attempt to serialize this message from a variant. More... | |
void | setData (const std::vector< uint8_t > &data) |
Set the message data. More... | |
void | setHeader (const MessageHeader &header) |
Set the message header. More... | |
void | setSize (size_t size) |
Set the message size. More... | |
void | setType (const MessageType &type) |
Set the message type. More... | |
template<typename T > | |
boost::shared_ptr< T > | toMessage () const |
Attempt to convert the message to a strong-typed message. More... | |
boost::shared_ptr< variant_msgs::Variant > | toVariantMessage () const |
Attempt to convert the message to a variant message. More... | |
template<typename Stream > | |
void | write (Stream &stream) const |
Write serialized message contents to stream. More... | |
~Message () | |
Destructor. More... | |
Protected Attributes | |
std::vector< uint8_t > | data |
The data of this message. More... | |
MessageHeader | header |
The header of this message. More... | |
MessageType | type |
The type of this message. More... | |
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.
variant_topic_tools::Message::Message | ( | ) |
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.
variant_topic_tools::Message::~Message | ( | ) |
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.
|
protected |
|
protected |
|
protected |