Serializer for full-fledged message types. More...
#include <MessageSerializer.h>

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 MessageSerializer & | MessageSerializerForType (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 Serializer & | SerializerForType (const std::string &type, const std::string &parentPackage) |
| Look up or build a reader for a message type. More... | |
Serializer for full-fledged message types.
Definition at line 15 of file MessageSerializer.h.
| MessageSerializer::MessageSerializer | ( | const std::string & | package, |
| const std::string & | name, | ||
| const std::string & | path | ||
| ) |
Construct a new MessageSerializer object.
| package | Package name |
| name | Message name |
| path | Path to message definition file |
Definition at line 95 of file MessageSerializer.cpp.
|
private |
Build a canonical definition for the message.
Definition at line 225 of file MessageSerializer.cpp.
|
private |
Calculate the MD5 hash used to identify the message type.
Definition at line 239 of file MessageSerializer.cpp.
|
overridevirtual |
Calculate the length of a serialized message in bytes.
| value | Value |
| fieldStack | Stack of fields to determine location |
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.
| value | Value |
| skipCount | Number of fields to skip |
| fieldStack | Stack of fields to determine location |
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.
| value | Value |
| skipCount | Number of fields to skip |
| fieldStack | Stack of fields to determine location |
Definition at line 324 of file MessageSerializer.cpp.
|
overridevirtual |
Deserialize a stream into a variant.
| stream | Input stream |
| fieldStack | Stack of fields to determine location |
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.
| stream | Input stream |
| fieldStack | Stack of fields to determine location |
| skipCount | Number of fields to skip |
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.
| stream | Input stream |
| map | Map to fill values with |
| fieldStack | Stack of fields to determine location |
| skipCount | Number of fields to skip |
Definition at line 477 of file MessageSerializer.cpp.
|
overridevirtual |
Deserialize a stream into a variant array.
| stream | Input stream |
| count | Item count |
| fieldStack | Stack of fields to determine location |
Implements swarmros::introspection::Serializer.
Definition at line 436 of file MessageSerializer.cpp.
|
overridevirtual |
Write the default value to the stream.
| stream | Output stream |
| fieldStack | Stack 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.
| enumerator | Enumerator function |
Definition at line 538 of file MessageSerializer.cpp.
|
inline |
Get the canonical definition of the message.
Definition at line 146 of file MessageSerializer.h.
|
overridevirtual |
Get the length of the default value.
| fieldStack | Stack of fields to determine location |
Implements swarmros::introspection::Serializer.
Definition at line 314 of file MessageSerializer.cpp.
|
overridevirtual |
Build a field descriptor for the underlying type.
Implements swarmros::introspection::Serializer.
Definition at line 498 of file MessageSerializer.cpp.
|
inlineoverridevirtual |
Get the fully qualified name for the type behind the serializer.
Reimplemented from swarmros::introspection::Serializer.
Definition at line 126 of file MessageSerializer.h.
|
inline |
Get the MD5 hash of the message definition file.
Definition at line 136 of file MessageSerializer.h.
|
inline |
| swarmio::data::discovery::Schema MessageSerializer::GetSchemaDescriptor | ( | unsigned | skipCount | ) | const |
Build a field descriptor for the underlying type, with or without its header.
| skipCount | Number of fields to skip |
Definition at line 513 of file MessageSerializer.cpp.
|
inline |
Checks whether the message fits the requirements of a message with a header.
Definition at line 157 of file MessageSerializer.h.
|
static |
Look up or build a reader for a message type.
| type | Message type |
| parentPackage | Package where the type was referenced |
Definition at line 32 of file MessageSerializer.cpp.
|
overridevirtual |
Serialize a variant onto a stream.
| stream | Output stream |
| value | Value to serialize |
| fieldStack | Stack 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.
| stream | Output stream |
| value | Value to serialize |
| skipCount | Number of fields to skip |
| fieldStack | Stack 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.
| stream | Output stream |
| value | Value to serialize |
| skipCount | Number of fields to skip |
| fieldStack | Stack of fields to determine location |
Definition at line 398 of file MessageSerializer.cpp.
|
private |
Canonical definition of the message.
Definition at line 68 of file MessageSerializer.h.
|
private |
Constant fields.
Definition at line 35 of file MessageSerializer.h.
|
private |
Variable fields.
Definition at line 29 of file MessageSerializer.h.
|
private |
Full name.
Definition at line 62 of file MessageSerializer.h.
|
private |
MD5 hash of the message.
Definition at line 74 of file MessageSerializer.h.
|
private |
Whether the message begins with the standard header.
Definition at line 42 of file MessageSerializer.h.
|
staticprivate |
Map of message serializers.
Definition at line 23 of file MessageSerializer.h.
|
private |
Package name.
Definition at line 56 of file MessageSerializer.h.
|
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.