YARP
Yet Another Robot Platform
Bool.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/Bool" msg definition:
9 // bool 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_Bool_h
14 #define YARP_ROSMSG_std_msgs_Bool_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  bool data;
30 
31  Bool() :
32  data(false)
33  {
34  }
35 
36  void clear()
37  {
38  // *** data ***
39  data = false;
40  }
41 
42  bool readBare(yarp::os::ConnectionReader& connection) override
43  {
44  // *** data ***
45  if (!connection.expectBlock((char*)&data, 1)) {
46  return false;
47  }
48 
49  return !connection.isError();
50  }
51 
52  bool readBottle(yarp::os::ConnectionReader& connection) override
53  {
54  connection.convertTextMode();
55  yarp::os::idl::WireReader reader(connection);
56  if (!reader.readListHeader(1)) {
57  return false;
58  }
59 
60  // *** data ***
61  data = reader.expectInt8();
62 
63  return !connection.isError();
64  }
65 
67  bool read(yarp::os::ConnectionReader& connection) override
68  {
69  return (connection.isBareMode() ? readBare(connection)
70  : readBottle(connection));
71  }
72 
73  bool writeBare(yarp::os::ConnectionWriter& connection) const override
74  {
75  // *** data ***
76  connection.appendBlock((char*)&data, 1);
77 
78  return !connection.isError();
79  }
80 
81  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
82  {
83  connection.appendInt32(BOTTLE_TAG_LIST);
84  connection.appendInt32(1);
85 
86  // *** data ***
87  connection.appendInt32(BOTTLE_TAG_INT8);
88  connection.appendInt8(data);
89 
90  connection.convertTextMode();
91  return !connection.isError();
92  }
93 
95  bool write(yarp::os::ConnectionWriter& connection) const override
96  {
97  return (connection.isBareMode() ? writeBare(connection)
98  : writeBottle(connection));
99  }
100 
101  // This class will serialize ROS style or YARP style depending on protocol.
102  // If you need to force a serialization style, use one of these classes:
105 
106  // The name for this message, ROS will need this
107  static constexpr const char* typeName = "std_msgs/Bool";
108 
109  // The checksum for this message, ROS will need this
110  static constexpr const char* typeChecksum = "8b94c1b53db61fb6aed406028ad6332a";
111 
112  // The source text for this message, ROS will need this
113  static constexpr const char* typeText = "\
114 bool data\n\
115 ";
116 
117  yarp::os::Type getType() const override
118  {
120  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
121  typ.addProperty("message_definition", yarp::os::Value(typeText));
122  return typ;
123  }
124 };
125 
126 } // namespace std_msgs
127 } // namespace rosmsg
128 } // namespace yarp
129 
130 #endif // YARP_ROSMSG_std_msgs_Bool_h
#define BOTTLE_TAG_INT8
Definition: Bottle.h:19
#define BOTTLE_TAG_LIST
Definition: Bottle.h:28
An interface for reading from a network connection.
virtual bool expectBlock(char *data, size_t len)=0
Read a block of data from the 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
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 appendInt8(std::int8_t data)=0
Send a representation of a 8-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.
virtual void appendBlock(const char *data, size_t len)=0
Send a block of data 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::int8_t expectInt8()
Definition: WireReader.h:80
static constexpr const char * typeChecksum
Definition: Bool.h:110
yarp::os::Type getType() const override
Definition: Bool.h:117
static constexpr const char * typeName
Definition: Bool.h:107
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: Bool.h:73
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: Bool.h:52
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: Bool.h:81
yarp::os::idl::BareStyle< yarp::rosmsg::std_msgs::Bool > rosStyle
Definition: Bool.h:103
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: Bool.h:67
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: Bool.h:95
static constexpr const char * typeText
Definition: Bool.h:113
yarp::os::idl::BottleStyle< yarp::rosmsg::std_msgs::Bool > bottleStyle
Definition: Bool.h:104
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: Bool.h:42
Definition: Bool.h:19
The main, catch-all namespace for YARP.
Definition: dirs.h:16