Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
swarmros::introspection::MessageSerializer Class Reference

Serializer for full-fledged message types. More...

#include <MessageSerializer.h>

Inheritance diagram for swarmros::introspection::MessageSerializer:
Inheritance graph
[legend]

Public Member Functions

virtual uint32_t CalculateSerializedLength (const swarmio::data::Variant &value, const FieldStack &fieldStack) const override
 Calculate the length of a serialized message in bytes. More...
 
uint32_t CalculateSerializedLength (const swarmio::data::Variant &value, unsigned skipCount, const FieldStack &fieldStack) const
 Calculate the length of a serialized message in bytes from a variant, with or without its header. More...
 
uint32_t CalculateSerializedLength (const swarmio::data::Map &value, unsigned skipCount, const FieldStack &fieldStack) const
 Calculate the length of a serialized message in bytes from a map, with or without its header. More...
 
virtual swarmio::data::Variant Deserialize (ros::serialization::IStream &stream, const FieldStack &fieldStack) const override
 Deserialize a stream into a variant. More...
 
swarmio::data::Variant Deserialize (ros::serialization::IStream &stream, unsigned skipCount, const FieldStack &fieldStack) const
 Deserialize a stream into a variant, with or without its header. More...
 
void Deserialize (ros::serialization::IStream &stream, swarmio::data::Map &map, unsigned skipCount, const FieldStack &fieldStack) const
 Deserialize a stream into a map, with or without its header. More...
 
virtual swarmio::data::Variant DeserializeArray (ros::serialization::IStream &stream, uint32_t count, const FieldStack &fieldStack) const override
 Deserialize a stream into a variant array. More...
 
virtual void EmitDefault (ros::serialization::OStream &stream, const FieldStack &fieldStack) const override
 Write the default value to the stream. More...
 
void EnumerateFields (std::function< bool(unsigned, const Field &)> enumerator) const
 Enumerate the fields of the message with a function. More...
 
const std::string & GetCanonicalDefinition () const
 Get the canonical definition of the message. More...
 
virtual uint32_t GetDefaultLength (const FieldStack &fieldStack) const override
 Get the length of the default value. More...
 
virtual swarmio::data::discovery::Field GetFieldDescriptor () const override
 Build a field descriptor for the underlying type. More...
 
virtual const std::string & GetFullName () const override
 Get the fully qualified name for the type behind the serializer. More...
 
const std::string & GetHash () const
 Get the MD5 hash of the message definition file. More...
 
const std::string & GetPackage () const
 Get package name. More...
 
swarmio::data::discovery::Schema GetSchemaDescriptor (unsigned skipCount) const
 Build a field descriptor for the underlying type, with or without its header. More...
 
bool HasHeader () const
 Checks whether the message fits the requirements of a message with a header. More...
 
 MessageSerializer (const std::string &package, const std::string &name, const std::string &path)
 Construct a new MessageSerializer object. More...
 
virtual void Serialize (ros::serialization::OStream &stream, const swarmio::data::Variant &value, const FieldStack &fieldStack) const override
 Serialize a variant onto a stream. More...
 
void Serialize (ros::serialization::OStream &stream, const swarmio::data::Variant &value, unsigned skipCount, const FieldStack &fieldStack) const
 Serialize a variant onto a stream, with or without its header. More...
 
void Serialize (ros::serialization::OStream &stream, const swarmio::data::Map &value, unsigned skipCount, const FieldStack &fieldStack) const
 Serialize a map onto a stream, with or without its header. More...
 
- Public Member Functions inherited from swarmros::introspection::Serializer
const std::string & GetName () const
 Get the non-qualified name for the type behind the serializer. More...
 
virtual ~Serializer ()
 Destructor. More...
 

Static Public Member Functions

static const MessageSerializerMessageSerializerForType (const std::string &type, const std::string &parentPackage)
 Look up or build a reader for a message type. More...
 

Private Member Functions

std::string BuildCanonicalDefinition ()
 Build a canonical definition for the message. More...
 
std::string CalculateHash ()
 Calculate the MD5 hash used to identify the message type. More...
 

Private Attributes

std::string _canonicalDefinition
 Canonical definition of the message. More...
 
std::list< ConstantField_constants
 Constant fields. More...
 
std::list< std::unique_ptr< Field > > _fields
 Variable fields. More...
 
std::string _fullName
 Full name. More...
 
std::string _hash
 MD5 hash of the message. More...
 
bool _hasHeader
 Whether the message begins with the standard header. More...
 
std::string _package
 Package name. More...
 
const Field_shortcut
 For certain messages, the normal field processing is skipped and a single field is used to deserialize the entire message. More...
 

Static Private Attributes

static std::map< std::string, std::unique_ptr< MessageSerializer > > _messageSerializers
 Map of message serializers. More...
 

Additional Inherited Members

- Protected Member Functions inherited from swarmros::introspection::Serializer
 Serializer (const std::string &name)
 Construct a new Serializer object. More...
 
- Static Protected Member Functions inherited from swarmros::introspection::Serializer
static const SerializerSerializerForType (const std::string &type, const std::string &parentPackage)
 Look up or build a reader for a message type. More...
 

Detailed Description

Serializer for full-fledged message types.

Definition at line 15 of file MessageSerializer.h.

Constructor & Destructor Documentation

MessageSerializer::MessageSerializer ( const std::string &  package,
const std::string &  name,
const std::string &  path 
)

Construct a new MessageSerializer object.

Parameters
packagePackage name
nameMessage name
pathPath to message definition file

Definition at line 95 of file MessageSerializer.cpp.

Member Function Documentation

std::string MessageSerializer::BuildCanonicalDefinition ( )
private

Build a canonical definition for the message.

Returns
std::string

Definition at line 225 of file MessageSerializer.cpp.

std::string MessageSerializer::CalculateHash ( )
private

Calculate the MD5 hash used to identify the message type.

Returns
std::string

Definition at line 239 of file MessageSerializer.cpp.

uint32_t MessageSerializer::CalculateSerializedLength ( const swarmio::data::Variant &  value,
const FieldStack fieldStack 
) const
overridevirtual

Calculate the length of a serialized message in bytes.

Parameters
valueValue
fieldStackStack of fields to determine location
Returns
uint32_t

Implements swarmros::introspection::Serializer.

Definition at line 289 of file MessageSerializer.cpp.

uint32_t MessageSerializer::CalculateSerializedLength ( const swarmio::data::Variant &  value,
unsigned  skipCount,
const FieldStack fieldStack 
) const

Calculate the length of a serialized message in bytes from a variant, with or without its header.

Parameters
valueValue
skipCountNumber of fields to skip
fieldStackStack of fields to determine location
Returns
uint32_t

Definition at line 294 of file MessageSerializer.cpp.

uint32_t MessageSerializer::CalculateSerializedLength ( const swarmio::data::Map &  value,
unsigned  skipCount,
const FieldStack fieldStack 
) const

Calculate the length of a serialized message in bytes from a map, with or without its header.

Parameters
valueValue
skipCountNumber of fields to skip
fieldStackStack of fields to determine location
Returns
uint32_t

Definition at line 324 of file MessageSerializer.cpp.

swarmio::data::Variant MessageSerializer::Deserialize ( ros::serialization::IStream stream,
const FieldStack fieldStack 
) const
overridevirtual

Deserialize a stream into a variant.

Parameters
streamInput stream
fieldStackStack of fields to determine location
Returns
swarmio::data::Variant

Implements swarmros::introspection::Serializer.

Definition at line 456 of file MessageSerializer.cpp.

swarmio::data::Variant MessageSerializer::Deserialize ( ros::serialization::IStream stream,
unsigned  skipCount,
const FieldStack fieldStack 
) const

Deserialize a stream into a variant, with or without its header.

Parameters
streamInput stream
fieldStackStack of fields to determine location
skipCountNumber of fields to skip
Returns
swarmio::data::Variant

Definition at line 461 of file MessageSerializer.cpp.

void MessageSerializer::Deserialize ( ros::serialization::IStream stream,
swarmio::data::Map &  map,
unsigned  skipCount,
const FieldStack fieldStack 
) const

Deserialize a stream into a map, with or without its header.

Parameters
streamInput stream
mapMap to fill values with
fieldStackStack of fields to determine location
skipCountNumber of fields to skip

Definition at line 477 of file MessageSerializer.cpp.

swarmio::data::Variant MessageSerializer::DeserializeArray ( ros::serialization::IStream stream,
uint32_t  count,
const FieldStack fieldStack 
) const
overridevirtual

Deserialize a stream into a variant array.

Parameters
streamInput stream
countItem count
fieldStackStack of fields to determine location
Returns
swarmio::data::Variant

Implements swarmros::introspection::Serializer.

Definition at line 436 of file MessageSerializer.cpp.

void MessageSerializer::EmitDefault ( ros::serialization::OStream stream,
const FieldStack fieldStack 
) const
overridevirtual

Write the default value to the stream.

Parameters
streamOutput stream
fieldStackStack of fields to determine location

Implements swarmros::introspection::Serializer.

Definition at line 427 of file MessageSerializer.cpp.

void MessageSerializer::EnumerateFields ( std::function< bool(unsigned, const Field &)>  enumerator) const

Enumerate the fields of the message with a function.

Parameters
enumeratorEnumerator function

Definition at line 538 of file MessageSerializer.cpp.

const std::string& swarmros::introspection::MessageSerializer::GetCanonicalDefinition ( ) const
inline

Get the canonical definition of the message.

Returns
const std::string&

Definition at line 146 of file MessageSerializer.h.

uint32_t MessageSerializer::GetDefaultLength ( const FieldStack fieldStack) const
overridevirtual

Get the length of the default value.

Parameters
fieldStackStack of fields to determine location
Returns
uint32_t

Implements swarmros::introspection::Serializer.

Definition at line 314 of file MessageSerializer.cpp.

swarmio::data::discovery::Field MessageSerializer::GetFieldDescriptor ( ) const
overridevirtual

Build a field descriptor for the underlying type.

Returns
swarmio::data::discovery::Field

Implements swarmros::introspection::Serializer.

Definition at line 498 of file MessageSerializer.cpp.

virtual const std::string& swarmros::introspection::MessageSerializer::GetFullName ( ) const
inlineoverridevirtual

Get the fully qualified name for the type behind the serializer.

Returns
const std::string&

Reimplemented from swarmros::introspection::Serializer.

Definition at line 126 of file MessageSerializer.h.

const std::string& swarmros::introspection::MessageSerializer::GetHash ( ) const
inline

Get the MD5 hash of the message definition file.

Returns
const std::string&

Definition at line 136 of file MessageSerializer.h.

const std::string& swarmros::introspection::MessageSerializer::GetPackage ( ) const
inline

Get package name.

Returns
const std::string&

Definition at line 115 of file MessageSerializer.h.

swarmio::data::discovery::Schema MessageSerializer::GetSchemaDescriptor ( unsigned  skipCount) const

Build a field descriptor for the underlying type, with or without its header.

Parameters
skipCountNumber of fields to skip
Returns
swarmio::data::discovery::Schema

Definition at line 513 of file MessageSerializer.cpp.

bool swarmros::introspection::MessageSerializer::HasHeader ( ) const
inline

Checks whether the message fits the requirements of a message with a header.

Returns
True if the message has a header

Definition at line 157 of file MessageSerializer.h.

const MessageSerializer & MessageSerializer::MessageSerializerForType ( const std::string &  type,
const std::string &  parentPackage 
)
static

Look up or build a reader for a message type.

Parameters
typeMessage type
parentPackagePackage where the type was referenced
Returns
const Serializer&

Definition at line 32 of file MessageSerializer.cpp.

void MessageSerializer::Serialize ( ros::serialization::OStream stream,
const swarmio::data::Variant &  value,
const FieldStack fieldStack 
) const
overridevirtual

Serialize a variant onto a stream.

Parameters
streamOutput stream
valueValue to serialize
fieldStackStack of fields to determine location

Implements swarmros::introspection::Serializer.

Definition at line 356 of file MessageSerializer.cpp.

void MessageSerializer::Serialize ( ros::serialization::OStream stream,
const swarmio::data::Variant &  value,
unsigned  skipCount,
const FieldStack fieldStack 
) const

Serialize a variant onto a stream, with or without its header.

Parameters
streamOutput stream
valueValue to serialize
skipCountNumber of fields to skip
fieldStackStack of fields to determine location

Definition at line 376 of file MessageSerializer.cpp.

void MessageSerializer::Serialize ( ros::serialization::OStream stream,
const swarmio::data::Map &  value,
unsigned  skipCount,
const FieldStack fieldStack 
) const

Serialize a map onto a stream, with or without its header.

Parameters
streamOutput stream
valueValue to serialize
skipCountNumber of fields to skip
fieldStackStack of fields to determine location

Definition at line 398 of file MessageSerializer.cpp.

Member Data Documentation

std::string swarmros::introspection::MessageSerializer::_canonicalDefinition
private

Canonical definition of the message.

Definition at line 68 of file MessageSerializer.h.

std::list<ConstantField> swarmros::introspection::MessageSerializer::_constants
private

Constant fields.

Definition at line 35 of file MessageSerializer.h.

std::list<std::unique_ptr<Field> > swarmros::introspection::MessageSerializer::_fields
private

Variable fields.

Definition at line 29 of file MessageSerializer.h.

std::string swarmros::introspection::MessageSerializer::_fullName
private

Full name.

Definition at line 62 of file MessageSerializer.h.

std::string swarmros::introspection::MessageSerializer::_hash
private

MD5 hash of the message.

Definition at line 74 of file MessageSerializer.h.

bool swarmros::introspection::MessageSerializer::_hasHeader
private

Whether the message begins with the standard header.

Definition at line 42 of file MessageSerializer.h.

std::map< std::string, std::unique_ptr< MessageSerializer > > MessageSerializer::_messageSerializers
staticprivate

Map of message serializers.

Definition at line 23 of file MessageSerializer.h.

std::string swarmros::introspection::MessageSerializer::_package
private

Package name.

Definition at line 56 of file MessageSerializer.h.

const Field* swarmros::introspection::MessageSerializer::_shortcut
private

For certain messages, the normal field processing is skipped and a single field is used to deserialize the entire message.

Definition at line 50 of file MessageSerializer.h.


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


swarmros
Author(s):
autogenerated on Fri Apr 3 2020 03:42:48