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