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