Public Member Functions | Protected Attributes | List of all members
variant_topic_tools::Message Class Reference

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 MessageHeadergetHeader () const
 Retrieve the message header. More...
 
size_t getSize () const
 Retrieve the message size. More...
 
const MessageTypegetType () 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...
 

Detailed Description

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.

Definition at line 43 of file Message.h.

Constructor & Destructor Documentation

variant_topic_tools::Message::Message ( )

Default constructor.

Definition at line 31 of file Message.cpp.

template<typename T >
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.

Member Function Documentation

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.

template<typename T >
void variant_topic_tools::Message::morph ( )

Morph the message.

template<typename Stream >
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.

Note
This will modify the message type from the fields of the specified 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.

Note
This will modify the message header from the members of the specified type.

Definition at line 59 of file Message.cpp.

template<typename T >
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.

template<typename Stream >
void variant_topic_tools::Message::write ( Stream &  stream) const

Write serialized message contents to stream.

Member Data Documentation

std::vector<uint8_t> variant_topic_tools::Message::data
protected

The data of this message.

Definition at line 143 of file Message.h.

MessageHeader variant_topic_tools::Message::header
protected

The header of this message.

Definition at line 135 of file Message.h.

MessageType variant_topic_tools::Message::type
protected

The type of this message.

Definition at line 139 of file Message.h.


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


variant_topic_tools
Author(s): Ralf Kaestner
autogenerated on Sat Jan 9 2021 03:56:50