YARP
Yet Another Robot Platform
PointField.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2018 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
9 // This is an automatically generated file.
10 
11 // Generated from the following "sensor_msgs/PointField" msg definition:
12 // # This message holds the description of one point entry in the
13 // # PointCloud2 message format.
14 // uint8 INT8 = 1
15 // uint8 UINT8 = 2
16 // uint8 INT16 = 3
17 // uint8 UINT16 = 4
18 // uint8 INT32 = 5
19 // uint8 UINT32 = 6
20 // uint8 FLOAT32 = 7
21 // uint8 FLOAT64 = 8
22 //
23 // string name # Name of field
24 // uint32 offset # Offset from start of point struct
25 // uint8 datatype # Datatype enumeration, see above
26 // uint32 count # How many elements in the field
27 // Instances of this class can be read and written with YARP ports,
28 // using a ROS-compatible format.
29 
30 #ifndef YARP_ROSMSG_sensor_msgs_PointField_h
31 #define YARP_ROSMSG_sensor_msgs_PointField_h
32 
33 #include <yarp/os/Wire.h>
34 #include <yarp/os/Type.h>
35 #include <yarp/os/idl/WireTypes.h>
36 #include <string>
37 #include <vector>
38 
39 namespace yarp {
40 namespace rosmsg {
41 namespace sensor_msgs {
42 
44 {
45 public:
46  static const std::uint8_t INT8 = 1;
47  static const std::uint8_t UINT8 = 2;
48  static const std::uint8_t INT16 = 3;
49  static const std::uint8_t UINT16 = 4;
50  static const std::uint8_t INT32 = 5;
51  static const std::uint8_t UINT32 = 6;
52  static const std::uint8_t FLOAT32 = 7;
53  static const std::uint8_t FLOAT64 = 8;
54  std::string name;
55  std::uint32_t offset;
56  std::uint8_t datatype;
57  std::uint32_t count;
58 
60  name(""),
61  offset(0),
62  datatype(0),
63  count(0)
64  {
65  }
66 
67  void clear()
68  {
69  // *** INT8 ***
70 
71  // *** UINT8 ***
72 
73  // *** INT16 ***
74 
75  // *** UINT16 ***
76 
77  // *** INT32 ***
78 
79  // *** UINT32 ***
80 
81  // *** FLOAT32 ***
82 
83  // *** FLOAT64 ***
84 
85  // *** name ***
86  name = "";
87 
88  // *** offset ***
89  offset = 0;
90 
91  // *** datatype ***
92  datatype = 0;
93 
94  // *** count ***
95  count = 0;
96  }
97 
98  bool readBare(yarp::os::ConnectionReader& connection) override
99  {
100  // *** name ***
101  int len = connection.expectInt32();
102  name.resize(len);
103  if (!connection.expectBlock((char*)name.c_str(), len)) {
104  return false;
105  }
106 
107  // *** offset ***
108  offset = connection.expectInt32();
109 
110  // *** datatype ***
111  datatype = connection.expectInt8();
112 
113  // *** count ***
114  count = connection.expectInt32();
115 
116  return !connection.isError();
117  }
118 
119  bool readBottle(yarp::os::ConnectionReader& connection) override
120  {
121  connection.convertTextMode();
122  yarp::os::idl::WireReader reader(connection);
123  if (!reader.readListHeader(12)) {
124  return false;
125  }
126 
127  // *** name ***
128  if (!reader.readString(name)) {
129  return false;
130  }
131 
132  // *** offset ***
133  offset = reader.expectInt32();
134 
135  // *** datatype ***
136  datatype = reader.expectInt8();
137 
138  // *** count ***
139  count = reader.expectInt32();
140 
141  return !connection.isError();
142  }
143 
145  bool read(yarp::os::ConnectionReader& connection) override
146  {
147  return (connection.isBareMode() ? readBare(connection)
148  : readBottle(connection));
149  }
150 
151  bool writeBare(yarp::os::ConnectionWriter& connection) const override
152  {
153  // *** name ***
154  connection.appendInt32(name.length());
155  connection.appendExternalBlock((char*)name.c_str(), name.length());
156 
157  // *** offset ***
158  connection.appendInt32(offset);
159 
160  // *** datatype ***
161  connection.appendInt8(datatype);
162 
163  // *** count ***
164  connection.appendInt32(count);
165 
166  return !connection.isError();
167  }
168 
169  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
170  {
171  connection.appendInt32(BOTTLE_TAG_LIST);
172  connection.appendInt32(12);
173 
174  // *** name ***
175  connection.appendInt32(BOTTLE_TAG_STRING);
176  connection.appendInt32(name.length());
177  connection.appendExternalBlock((char*)name.c_str(), name.length());
178 
179  // *** offset ***
180  connection.appendInt32(BOTTLE_TAG_INT32);
181  connection.appendInt32(offset);
182 
183  // *** datatype ***
184  connection.appendInt32(BOTTLE_TAG_INT8);
185  connection.appendInt8(datatype);
186 
187  // *** count ***
188  connection.appendInt32(BOTTLE_TAG_INT32);
189  connection.appendInt32(count);
190 
191  connection.convertTextMode();
192  return !connection.isError();
193  }
194 
196  bool write(yarp::os::ConnectionWriter& connection) const override
197  {
198  return (connection.isBareMode() ? writeBare(connection)
199  : writeBottle(connection));
200  }
201 
202  // This class will serialize ROS style or YARP style depending on protocol.
203  // If you need to force a serialization style, use one of these classes:
206 
207  // Give source text for class, ROS will need this
208  static std::string typeText()
209  {
210  return std::string("\
211 # This message holds the description of one point entry in the\n\
212 # PointCloud2 message format.\n\
213 uint8 INT8 = 1\n\
214 uint8 UINT8 = 2\n\
215 uint8 INT16 = 3\n\
216 uint8 UINT16 = 4\n\
217 uint8 INT32 = 5\n\
218 uint8 UINT32 = 6\n\
219 uint8 FLOAT32 = 7\n\
220 uint8 FLOAT64 = 8\n\
221 \n\
222 string name # Name of field\n\
223 uint32 offset # Offset from start of point struct\n\
224 uint8 datatype # Datatype enumeration, see above\n\
225 uint32 count # How many elements in the field\n\
226 ");
227  }
228 
229  std::string getTypeText() const
230  {
232  }
233 
234  // Name the class, ROS will need this
235  yarp::os::Type getType() const override
236  {
237  yarp::os::Type typ = yarp::os::Type::byName("sensor_msgs/PointField", "sensor_msgs/PointField");
238  typ.addProperty("md5sum", yarp::os::Value("268eacb2962780ceac86cbd17e328150"));
239  typ.addProperty("message_definition", yarp::os::Value(getTypeText()));
240  return typ;
241  }
242 };
243 
244 } // namespace sensor_msgs
245 } // namespace rosmsg
246 } // namespace yarp
247 
248 #endif // YARP_ROSMSG_sensor_msgs_PointField_h
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: PointField.h:196
virtual void appendExternalBlock(const char *data, size_t len)=0
Send a block of data to the network connection, without making a copy.
#define BOTTLE_TAG_STRING
Definition: Bottle.h:28
#define BOTTLE_TAG_INT32
Definition: Bottle.h:23
virtual bool expectBlock(char *data, size_t len)=0
Read a block of data from the network connection.
virtual std::int8_t expectInt8()=0
Read a 8-bit integer from the network connection.
static const std::uint8_t UINT8
Definition: PointField.h:47
#define BOTTLE_TAG_INT8
Definition: Bottle.h:21
static Type byName(const char *name)
Definition: Type.cpp:165
Type & addProperty(const char *key, const Value &val)
Definition: Type.cpp:127
std::int8_t expectInt8()
Definition: WireReader.h:85
static const std::uint8_t INT32
Definition: PointField.h:50
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: PointField.h:119
virtual bool isError() const =0
The main, catch-all namespace for YARP.
Definition: numeric.h:47
yarp::os::idl::BareStyle< yarp::rosmsg::sensor_msgs::PointField > rosStyle
Definition: PointField.h:204
virtual bool convertTextMode()=0
Reads in a standard description in text mode, and converts it to a standard description in binary...
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: PointField.h:145
static const std::uint8_t FLOAT64
Definition: PointField.h:53
virtual bool isBareMode() const =0
Check if the connection is bare mode.
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: PointField.h:151
std::int32_t expectInt32()
Definition: WireReader.h:95
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: PointField.h:98
static const std::uint8_t INT16
Definition: PointField.h:48
An interface for writing to a network connection.
virtual bool write(const yarp::os::idl::WireWriter &writer) const
virtual void appendInt32(std::int32_t data)=0
Send a representation of a 32-bit integer to the network connection.
virtual bool read(yarp::os::idl::WireReader &reader)
virtual bool isError() const =0
static const std::uint8_t INT8
Definition: PointField.h:46
A "tamed" Portable, that promises to serialize itself in an IDL-friendly way.
Definition: WirePortable.h:30
virtual std::int32_t expectInt32()=0
Read a 32-bit integer from the network connection.
An interface for reading from a network connection.
yarp::os::Type getType() const override
Definition: PointField.h:235
yarp::os::idl::BottleStyle< yarp::rosmsg::sensor_msgs::PointField > bottleStyle
Definition: PointField.h:205
static const std::uint8_t UINT16
Definition: PointField.h:49
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: PointField.h:169
static const std::uint8_t FLOAT32
Definition: PointField.h:52
A single value (typically within a Bottle).
Definition: Value.h:40
bool readString(std::string &str, bool *is_vocab=nullptr)
Definition: WireReader.cpp:330
virtual bool isBareMode() const =0
Check if the connection is bare mode.
virtual bool convertTextMode()=0
Converts a standard description in binary into a textual description, if the connection is in text-mo...
#define BOTTLE_TAG_LIST
Definition: Bottle.h:30
IDL-friendly connection reader.
Definition: WireReader.h:37
virtual void appendInt8(std::int8_t data)=0
Send a representation of a 8-bit integer to the network connection.
static const std::uint8_t UINT32
Definition: PointField.h:51