YARP
Yet Another Robot Platform
Polygon.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 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 "geometry_msgs/Polygon" msg definition:
12 // #A specification of a polygon where the first and last points are assumed to be connected
13 // Point32[] points
14 // Instances of this class can be read and written with YARP ports,
15 // using a ROS-compatible format.
16 
17 #ifndef YARP_ROSMSG_geometry_msgs_Polygon_h
18 #define YARP_ROSMSG_geometry_msgs_Polygon_h
19 
20 #include <yarp/os/Wire.h>
21 #include <yarp/os/Type.h>
22 #include <yarp/os/idl/WireTypes.h>
23 #include <string>
24 #include <vector>
26 
27 namespace yarp {
28 namespace rosmsg {
29 namespace geometry_msgs {
30 
32 {
33 public:
34  std::vector<yarp::rosmsg::geometry_msgs::Point32> points;
35 
36  Polygon() :
37  points()
38  {
39  }
40 
41  void clear()
42  {
43  // *** points ***
44  points.clear();
45  }
46 
47  bool readBare(yarp::os::ConnectionReader& connection) override
48  {
49  // *** points ***
50  int len = connection.expectInt32();
51  points.resize(len);
52  for (int i=0; i<len; i++) {
53  if (!points[i].read(connection)) {
54  return false;
55  }
56  }
57 
58  return !connection.isError();
59  }
60 
61  bool readBottle(yarp::os::ConnectionReader& connection) override
62  {
63  connection.convertTextMode();
64  yarp::os::idl::WireReader reader(connection);
65  if (!reader.readListHeader(1)) {
66  return false;
67  }
68 
69  // *** points ***
70  if (connection.expectInt32() != BOTTLE_TAG_LIST) {
71  return false;
72  }
73  int len = connection.expectInt32();
74  points.resize(len);
75  for (int i=0; i<len; i++) {
76  if (!points[i].read(connection)) {
77  return false;
78  }
79  }
80 
81  return !connection.isError();
82  }
83 
85  bool read(yarp::os::ConnectionReader& connection) override
86  {
87  return (connection.isBareMode() ? readBare(connection)
88  : readBottle(connection));
89  }
90 
91  bool writeBare(yarp::os::ConnectionWriter& connection) const override
92  {
93  // *** points ***
94  connection.appendInt32(points.size());
95  for (size_t i=0; i<points.size(); i++) {
96  if (!points[i].write(connection)) {
97  return false;
98  }
99  }
100 
101  return !connection.isError();
102  }
103 
104  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
105  {
106  connection.appendInt32(BOTTLE_TAG_LIST);
107  connection.appendInt32(1);
108 
109  // *** points ***
110  connection.appendInt32(BOTTLE_TAG_LIST);
111  connection.appendInt32(points.size());
112  for (size_t i=0; i<points.size(); i++) {
113  if (!points[i].write(connection)) {
114  return false;
115  }
116  }
117 
118  connection.convertTextMode();
119  return !connection.isError();
120  }
121 
123  bool write(yarp::os::ConnectionWriter& connection) const override
124  {
125  return (connection.isBareMode() ? writeBare(connection)
126  : writeBottle(connection));
127  }
128 
129  // This class will serialize ROS style or YARP style depending on protocol.
130  // If you need to force a serialization style, use one of these classes:
133 
134  // The name for this message, ROS will need this
135  static constexpr const char* typeName = "geometry_msgs/Polygon";
136 
137  // The checksum for this message, ROS will need this
138  static constexpr const char* typeChecksum = "cd60a26494a087f577976f0329fa120e";
139 
140  // The source text for this message, ROS will need this
141  static constexpr const char* typeText = "\
142 #A specification of a polygon where the first and last points are assumed to be connected\n\
143 Point32[] points\n\
144 \n\
145 ================================================================================\n\
146 MSG: geometry_msgs/Point32\n\
147 # This contains the position of a point in free space(with 32 bits of precision).\n\
148 # It is recommeded to use Point wherever possible instead of Point32. \n\
149 # \n\
150 # This recommendation is to promote interoperability. \n\
151 #\n\
152 # This message is designed to take up less space when sending\n\
153 # lots of points at once, as in the case of a PointCloud. \n\
154 \n\
155 float32 x\n\
156 float32 y\n\
157 float32 z\n\
158 ";
159 
160  yarp::os::Type getType() const override
161  {
163  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
164  typ.addProperty("message_definition", yarp::os::Value(typeText));
165  return typ;
166  }
167 };
168 
169 } // namespace geometry_msgs
170 } // namespace rosmsg
171 } // namespace yarp
172 
173 #endif // YARP_ROSMSG_geometry_msgs_Polygon_h
yarp::rosmsg::geometry_msgs::Polygon
Definition: Polygon.h:32
yarp::rosmsg::geometry_msgs::Polygon::typeText
static constexpr const char * typeText
Definition: Polygon.h:141
WireTypes.h
BOTTLE_TAG_LIST
#define BOTTLE_TAG_LIST
Definition: Bottle.h:30
yarp::rosmsg::geometry_msgs::Polygon::writeBare
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: Polygon.h:91
yarp::rosmsg::geometry_msgs::Polygon::clear
void clear()
Definition: Polygon.h:41
yarp::os::idl::BottleStyle
Definition: BottleStyle.h:22
yarp::os::Type
Definition: Type.h:24
yarp::os::idl::WirePortable::read
virtual bool read(yarp::os::idl::WireReader &reader)
Definition: WirePortable.cpp:14
yarp::rosmsg::geometry_msgs::Polygon::write
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: Polygon.h:123
yarp::os::ConnectionReader::isBareMode
virtual bool isBareMode() const =0
Check if the connection is bare mode.
Wire.h
geometry_msgs
Definition: Accel.h:22
yarp::rosmsg::geometry_msgs::Polygon::readBare
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: Polygon.h:47
yarp::rosmsg::geometry_msgs::Polygon::writeBottle
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: Polygon.h:104
Point32.h
yarp::os::ConnectionWriter::isError
virtual bool isError() const =0
yarp::rosmsg::geometry_msgs::Polygon::read
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: Polygon.h:85
yarp::os::Type::byName
static Type byName(const char *name)
Definition: Type.cpp:174
yarp::os::ConnectionReader::expectInt32
virtual std::int32_t expectInt32()=0
Read a 32-bit integer from the network connection.
yarp::os::Type::addProperty
Type & addProperty(const char *key, const Value &val)
Definition: Type.cpp:137
Type.h
yarp::os::ConnectionWriter
An interface for writing to a network connection.
Definition: ConnectionWriter.h:40
yarp::os::ConnectionReader::isError
virtual bool isError() const =0
yarp::rosmsg::geometry_msgs::Polygon::getType
yarp::os::Type getType() const override
Definition: Polygon.h:160
yarp::rosmsg::geometry_msgs::Polygon::Polygon
Polygon()
Definition: Polygon.h:36
yarp::os::ConnectionReader::convertTextMode
virtual bool convertTextMode()=0
Reads in a standard description in text mode, and converts it to a standard description in binary.
yarp::rosmsg::geometry_msgs::Polygon::bottleStyle
yarp::os::idl::BottleStyle< yarp::rosmsg::geometry_msgs::Polygon > bottleStyle
Definition: Polygon.h:132
yarp::os::idl::WirePortable
A "tamed" Portable, that promises to serialize itself in an IDL-friendly way.
Definition: WirePortable.h:26
yarp::os::ConnectionWriter::isBareMode
virtual bool isBareMode() const =0
Check if the connection is bare mode.
yarp::rosmsg::geometry_msgs::Polygon::rosStyle
yarp::os::idl::BareStyle< yarp::rosmsg::geometry_msgs::Polygon > rosStyle
Definition: Polygon.h:131
yarp::rosmsg::geometry_msgs::Polygon::points
std::vector< yarp::rosmsg::geometry_msgs::Point32 > points
Definition: Polygon.h:34
yarp::os::ConnectionWriter::convertTextMode
virtual bool convertTextMode()=0
Converts a standard description in binary into a textual description, if the connection is in text-mo...
yarp::os::ConnectionWriter::appendInt32
virtual void appendInt32(std::int32_t data)=0
Send a representation of a 32-bit integer to the network connection.
yarp::os::idl::WireReader
IDL-friendly connection reader.
Definition: WireReader.h:33
yarp::rosmsg::geometry_msgs::Polygon::typeChecksum
static constexpr const char * typeChecksum
Definition: Polygon.h:138
yarp::os::ConnectionReader
An interface for reading from a network connection.
Definition: ConnectionReader.h:40
yarp::os::idl::BareStyle
Definition: BareStyle.h:22
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::rosmsg::geometry_msgs::Polygon::typeName
static constexpr const char * typeName
Definition: Polygon.h:135
yarp::rosmsg::geometry_msgs::Polygon::readBottle
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: Polygon.h:61
yarp::os::Value
A single value (typically within a Bottle).
Definition: Value.h:47
yarp::os::idl::WireReader::readListHeader
bool readListHeader()
Definition: WireReader.cpp:470
yarp::os::idl::WirePortable::write
virtual bool write(const yarp::os::idl::WireWriter &writer) const
Definition: WirePortable.cpp:20