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