YARP
Yet Another Robot Platform
UInt16.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 "std_msgs/UInt16" msg definition:
9 // uint16 data
10 // Instances of this class can be read and written with YARP ports,
11 // using a ROS-compatible format.
12 
13 #ifndef YARP_ROSMSG_std_msgs_UInt16_h
14 #define YARP_ROSMSG_std_msgs_UInt16_h
15 
16 #include <yarp/os/Wire.h>
17 #include <yarp/os/Type.h>
18 #include <yarp/os/idl/WireTypes.h>
19 #include <string>
20 #include <vector>
21 
22 namespace yarp {
23 namespace rosmsg {
24 namespace std_msgs {
25 
27 {
28 public:
29  std::uint16_t data;
30 
31  UInt16() :
32  data(0)
33  {
34  }
35 
36  void clear()
37  {
38  // *** data ***
39  data = 0;
40  }
41 
42  bool readBare(yarp::os::ConnectionReader& connection) override
43  {
44  // *** data ***
45  data = connection.expectInt16();
46 
47  return !connection.isError();
48  }
49 
50  bool readBottle(yarp::os::ConnectionReader& connection) override
51  {
52  connection.convertTextMode();
53  yarp::os::idl::WireReader reader(connection);
54  if (!reader.readListHeader(1)) {
55  return false;
56  }
57 
58  // *** data ***
59  data = reader.expectInt16();
60 
61  return !connection.isError();
62  }
63 
65  bool read(yarp::os::ConnectionReader& connection) override
66  {
67  return (connection.isBareMode() ? readBare(connection)
68  : readBottle(connection));
69  }
70 
71  bool writeBare(yarp::os::ConnectionWriter& connection) const override
72  {
73  // *** data ***
74  connection.appendInt16(data);
75 
76  return !connection.isError();
77  }
78 
79  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
80  {
81  connection.appendInt32(BOTTLE_TAG_LIST);
82  connection.appendInt32(1);
83 
84  // *** data ***
85  connection.appendInt32(BOTTLE_TAG_INT16);
86  connection.appendInt16(data);
87 
88  connection.convertTextMode();
89  return !connection.isError();
90  }
91 
93  bool write(yarp::os::ConnectionWriter& connection) const override
94  {
95  return (connection.isBareMode() ? writeBare(connection)
96  : writeBottle(connection));
97  }
98 
99  // This class will serialize ROS style or YARP style depending on protocol.
100  // If you need to force a serialization style, use one of these classes:
103 
104  // The name for this message, ROS will need this
105  static constexpr const char* typeName = "std_msgs/UInt16";
106 
107  // The checksum for this message, ROS will need this
108  static constexpr const char* typeChecksum = "1df79edf208b629fe6b81923a544552d";
109 
110  // The source text for this message, ROS will need this
111  static constexpr const char* typeText = "\
112 uint16 data\n\
113 ";
114 
115  yarp::os::Type getType() const override
116  {
118  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
119  typ.addProperty("message_definition", yarp::os::Value(typeText));
120  return typ;
121  }
122 };
123 
124 } // namespace std_msgs
125 } // namespace rosmsg
126 } // namespace yarp
127 
128 #endif // YARP_ROSMSG_std_msgs_UInt16_h
#define BOTTLE_TAG_INT16
Definition: Bottle.h:20
#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 std::int16_t expectInt16()=0
Read a 16-bit integer 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 void appendInt16(std::int16_t data)=0
Send a representation of a 16-bit integer to the network connection.
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: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
std::int16_t expectInt16()
Definition: WireReader.h:86
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: UInt16.h:65
static constexpr const char * typeText
Definition: UInt16.h:111
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: UInt16.h:79
yarp::os::Type getType() const override
Definition: UInt16.h:115
yarp::os::idl::BareStyle< yarp::rosmsg::std_msgs::UInt16 > rosStyle
Definition: UInt16.h:101
static constexpr const char * typeChecksum
Definition: UInt16.h:108
yarp::os::idl::BottleStyle< yarp::rosmsg::std_msgs::UInt16 > bottleStyle
Definition: UInt16.h:102
static constexpr const char * typeName
Definition: UInt16.h:105
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: UInt16.h:42
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: UInt16.h:50
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: UInt16.h:93
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: UInt16.h:71
Definition: Bool.h:19
The main, catch-all namespace for YARP.
Definition: dirs.h:16