range_and_reflectance_measurement.h
Go to the documentation of this file.
1 
26 #ifndef OMRON_OS32C_DRIVER_RANGE_AND_REFLECTANCE_MEASUREMENT_H
27 #define OMRON_OS32C_DRIVER_RANGE_AND_REFLECTANCE_MEASUREMENT_H
28 
29 #include <string>
30 #include <vector>
31 
37 
38 using std::vector;
42 
43 namespace omron_os32c_driver {
44 
51 {
52 public:
54  vector<EIP_UINT> range_data;
55  vector<EIP_UINT> reflectance_data;
56 
60  virtual size_t getLength() const
61  {
62  return header.getLength() + range_data.size() * sizeof(EIP_UINT) + reflectance_data.size() * sizeof(EIP_UINT);
63  }
64 
71  virtual Writer& serialize(Writer& writer) const
72  {
73  header.serialize(writer);
74  writer.writeBytes(&range_data[0], range_data.size() * sizeof(EIP_UINT));
75  writer.writeBytes(&reflectance_data[0], reflectance_data.size() * sizeof(EIP_UINT));
76  return writer;
77  }
78 
82  virtual Reader& deserialize(Reader& reader, size_t length)
83  {
84  deserialize(reader);
85  return reader;
86  }
87 
94  virtual Reader& deserialize(Reader& reader)
95  {
96  header.deserialize(reader);
97  range_data.resize(header.num_beams);
98  reflectance_data.resize(header.num_beams);
99  reader.readBytes(&range_data[0], range_data.size() * sizeof(EIP_UINT));
100  reader.readBytes(&reflectance_data[0], reflectance_data.size() * sizeof(EIP_UINT));
101  return reader;
102  }
103 };
104 
105 } // namespace omron_os32c_driver
106 
107 #endif // OS32C_RANGE_AND_REFLECTANCE_MEASUREMENT_H
virtual Reader & deserialize(Reader &reader, size_t length)
uint16_t EIP_UINT
virtual Writer & serialize(Writer &writer) const
virtual void writeBytes(const void *p, size_t n)=0
virtual Reader & deserialize(Reader &reader, size_t length)
virtual void readBytes(void *buf, size_t n)=0


omron_os32c_driver
Author(s): Kareem Shehata
autogenerated on Fri Nov 27 2020 03:06:12