Field.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include <swarmio/data/Variant.pb.h>
5 #include <string>
6 #include <sstream>
7 
9 {
15  class Field : public Serializer
16  {
17  protected:
18 
24 
31  void WriteTypeName(std::stringstream& stream, bool forHash) const;
32 
33  public:
34 
41  Field(const std::string& name, const Serializer& serializer)
42  : Serializer(name), _serializer(serializer) { }
43 
51  virtual void WriteDefinition(std::stringstream& stream, bool forHash) const;
52 
58  const Serializer& GetSerializer() const
59  {
60  return _serializer;
61  }
62 
69  virtual uint32_t GetDefaultLength(const FieldStack& fieldStack) const override;
70 
78  virtual uint32_t CalculateSerializedLength(const swarmio::data::Variant& value, const FieldStack& fieldStack) const override;
79 
87  virtual void Serialize(ros::serialization::OStream& stream, const swarmio::data::Variant& value, const FieldStack& fieldStack) const override;
88 
95  virtual void EmitDefault(ros::serialization::OStream& stream, const FieldStack& fieldStack) const override;
96 
104  virtual swarmio::data::Variant Deserialize(ros::serialization::IStream& stream, const FieldStack& fieldStack) const override;
105 
115  virtual swarmio::data::Variant DeserializeArray(ros::serialization::IStream& stream, uint32_t count, const FieldStack& fieldStack) const override;
116 
122  virtual swarmio::data::discovery::Field GetFieldDescriptor() const override;
123  };
124 }
virtual void Serialize(ros::serialization::OStream &stream, const swarmio::data::Variant &value, const FieldStack &fieldStack) const override
Serialize a variant onto a stream.
Definition: Field.cpp:57
const Serializer & GetSerializer() const
Get the associated serializer.
Definition: Field.h:58
virtual swarmio::data::discovery::Field GetFieldDescriptor() const override
Build a field descriptor for the underlying type.
Definition: Field.cpp:87
virtual uint32_t GetDefaultLength(const FieldStack &fieldStack) const override
Get the length of the default value.
Definition: Field.cpp:38
A Field represents an entry in a message reader that can read one of its fields.
Definition: Field.h:15
virtual void WriteDefinition(std::stringstream &stream, bool forHash) const
Write the definition of this field to a string stream.
Definition: Field.cpp:12
void WriteTypeName(std::stringstream &stream, bool forHash) const
Get the type name for the serializer.
Definition: Field.cpp:18
const Serializer & _serializer
Serializer.
Definition: Field.h:23
virtual uint32_t CalculateSerializedLength(const swarmio::data::Variant &value, const FieldStack &fieldStack) const override
Calculate the length of a serialized message in bytes.
Definition: Field.cpp:44
Serializer is the base class for all binary message interpreters.
Definition: Serializer.h:17
Field(const std::string &name, const Serializer &serializer)
Construct a new Field object.
Definition: Field.h:41
virtual swarmio::data::Variant Deserialize(ros::serialization::IStream &stream, const FieldStack &fieldStack) const override
Deserialize a stream into a variant.
Definition: Field.cpp:76
virtual swarmio::data::Variant DeserializeArray(ros::serialization::IStream &stream, uint32_t count, const FieldStack &fieldStack) const override
Deserialize a stream into a variant array - not supported on Fields.
Definition: Field.cpp:82
virtual void EmitDefault(ros::serialization::OStream &stream, const FieldStack &fieldStack) const override
Write the default value to the stream.
Definition: Field.cpp:70


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