YARP
Yet Another Robot Platform
Point.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/Point" msg definition:
9 // # This contains the position of a point in free space
10 // float64 x
11 // float64 y
12 // float64 z
13 // Instances of this class can be read and written with YARP ports,
14 // using a ROS-compatible format.
15 
16 #ifndef YARP_ROSMSG_geometry_msgs_Point_h
17 #define YARP_ROSMSG_geometry_msgs_Point_h
18 
19 #include <yarp/os/Wire.h>
20 #include <yarp/os/Type.h>
22 #include <string>
23 #include <vector>
24 
25 namespace yarp {
26 namespace rosmsg {
27 namespace geometry_msgs {
28 
30 {
31 public:
35 
36  Point() :
37  x(0.0),
38  y(0.0),
39  z(0.0)
40  {
41  }
42 
43  void clear()
44  {
45  // *** x ***
46  x = 0.0;
47 
48  // *** y ***
49  y = 0.0;
50 
51  // *** z ***
52  z = 0.0;
53  }
54 
55  bool readBare(yarp::os::ConnectionReader& connection) override
56  {
57  // *** x ***
58  x = connection.expectFloat64();
59 
60  // *** y ***
61  y = connection.expectFloat64();
62 
63  // *** z ***
64  z = connection.expectFloat64();
65 
66  return !connection.isError();
67  }
68 
69  bool readBottle(yarp::os::ConnectionReader& connection) override
70  {
71  connection.convertTextMode();
72  yarp::os::idl::WireReader reader(connection);
73  if (!reader.readListHeader(3)) {
74  return false;
75  }
76 
77  // *** x ***
78  x = reader.expectFloat64();
79 
80  // *** y ***
81  y = reader.expectFloat64();
82 
83  // *** z ***
84  z = reader.expectFloat64();
85 
86  return !connection.isError();
87  }
88 
90  bool read(yarp::os::ConnectionReader& connection) override
91  {
92  return (connection.isBareMode() ? readBare(connection)
93  : readBottle(connection));
94  }
95 
96  bool writeBare(yarp::os::ConnectionWriter& connection) const override
97  {
98  // *** x ***
99  connection.appendFloat64(x);
100 
101  // *** y ***
102  connection.appendFloat64(y);
103 
104  // *** z ***
105  connection.appendFloat64(z);
106 
107  return !connection.isError();
108  }
109 
110  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
111  {
112  connection.appendInt32(BOTTLE_TAG_LIST);
113  connection.appendInt32(3);
114 
115  // *** x ***
116  connection.appendInt32(BOTTLE_TAG_FLOAT64);
117  connection.appendFloat64(x);
118 
119  // *** y ***
120  connection.appendInt32(BOTTLE_TAG_FLOAT64);
121  connection.appendFloat64(y);
122 
123  // *** z ***
124  connection.appendInt32(BOTTLE_TAG_FLOAT64);
125  connection.appendFloat64(z);
126 
127  connection.convertTextMode();
128  return !connection.isError();
129  }
130 
132  bool write(yarp::os::ConnectionWriter& connection) const override
133  {
134  return (connection.isBareMode() ? writeBare(connection)
135  : writeBottle(connection));
136  }
137 
138  // This class will serialize ROS style or YARP style depending on protocol.
139  // If you need to force a serialization style, use one of these classes:
142 
143  // The name for this message, ROS will need this
144  static constexpr const char* typeName = "geometry_msgs/Point";
145 
146  // The checksum for this message, ROS will need this
147  static constexpr const char* typeChecksum = "4a842b65f413084dc2b10fb484ea7f17";
148 
149  // The source text for this message, ROS will need this
150  static constexpr const char* typeText = "\
151 # This contains the position of a point in free space\n\
152 float64 x\n\
153 float64 y\n\
154 float64 z\n\
155 ";
156 
157  yarp::os::Type getType() const override
158  {
160  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
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_Point_h
#define BOTTLE_TAG_FLOAT64
Definition: Bottle.h:25
#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 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
virtual yarp::conf::float64_t expectFloat64()=0
Read a 64-bit floating point number from the network connection.
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.
virtual void appendFloat64(yarp::conf::float64_t data)=0
Send a representation of a 64-bit floating point number 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:45
A "tamed" Portable, that promises to serialize itself in an IDL-friendly way.
Definition: WirePortable.h:23
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:30
yarp::conf::float64_t expectFloat64()
Definition: WireReader.h:113
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: Point.h:55
static constexpr const char * typeChecksum
Definition: Point.h:147
yarp::conf::float64_t y
Definition: Point.h:33
static constexpr const char * typeName
Definition: Point.h:144
yarp::os::idl::BareStyle< yarp::rosmsg::geometry_msgs::Point > rosStyle
Definition: Point.h:140
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: Point.h:132
yarp::conf::float64_t x
Definition: Point.h:32
static constexpr const char * typeText
Definition: Point.h:150
yarp::os::Type getType() const override
Definition: Point.h:157
yarp::conf::float64_t z
Definition: Point.h:34
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: Point.h:69
yarp::os::idl::BottleStyle< yarp::rosmsg::geometry_msgs::Point > bottleStyle
Definition: Point.h:141
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: Point.h:110
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: Point.h:90
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: Point.h:96
double float64_t
Definition: numeric.h:77
The main, catch-all namespace for YARP.
Definition: dirs.h:16