PrimitiveSerializer.h
Go to the documentation of this file.
1 #pragma once
2 
5 #include <string>
6 
8 {
15  {
16  UNKNOWN = 0,
31  };
32 
38  {
39  private:
40 
46 
47  public:
48 
54  PrimitiveSerializer(const std::string& name, PrimitiveType type)
55  : Serializer(name), _type(type) { }
56 
63  {
64  return _type;
65  }
66 
73  virtual uint32_t GetDefaultLength(const FieldStack& fieldStack) const override;
74 
82  virtual uint32_t CalculateSerializedLength(const swarmio::data::Variant& value, const FieldStack& fieldStack) const override;
83 
91  virtual void Serialize(ros::serialization::OStream& stream, const swarmio::data::Variant& value, const FieldStack& fieldStack) const override;
92 
99  virtual void EmitDefault(ros::serialization::OStream& stream, const FieldStack& fieldStack) const override;
100 
108  virtual swarmio::data::Variant Deserialize(ros::serialization::IStream& stream, const FieldStack& fieldStack) const override;
109 
118  virtual swarmio::data::Variant DeserializeArray(ros::serialization::IStream& stream, uint32_t count, const FieldStack& fieldStack) const override;
119 
125  virtual swarmio::data::discovery::Field GetFieldDescriptor() const override;
126  };
127 }
Serializer for primitive builtin types.
virtual swarmio::data::Variant Deserialize(ros::serialization::IStream &stream, const FieldStack &fieldStack) const override
Deserialize a stream into a variant.
PrimitiveType
Values correspond to builtin types of the ROS msg specification.
virtual void Serialize(ros::serialization::OStream &stream, const swarmio::data::Variant &value, const FieldStack &fieldStack) const override
Serialize a variant onto a stream.
virtual void EmitDefault(ros::serialization::OStream &stream, const FieldStack &fieldStack) const override
Write the default value to the stream.
PrimitiveSerializer(const std::string &name, PrimitiveType type)
Construct a new PrimitiveSerializer object.
PrimitiveType GetType() const
Get underlying data type.
virtual uint32_t GetDefaultLength(const FieldStack &fieldStack) const override
Get the length of the default value.
virtual swarmio::data::discovery::Field GetFieldDescriptor() const override
Build a field descriptor for the underlying type.
virtual uint32_t CalculateSerializedLength(const swarmio::data::Variant &value, const FieldStack &fieldStack) const override
Calculate the length of a serialized message in bytes.
Serializer is the base class for all binary message interpreters.
Definition: Serializer.h:17
virtual swarmio::data::Variant DeserializeArray(ros::serialization::IStream &stream, uint32_t count, const FieldStack &fieldStack) const override
Deserialize a stream into a variant array.


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