YARP
Yet Another Robot Platform
AddDiagnosticsReply.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 "diagnostic_msgs/AddDiagnosticsReply" msg definition:
9 // Instances of this class can be read and written with YARP ports,
10 // using a ROS-compatible format.
11 
12 #ifndef YARP_ROSMSG_diagnostic_msgs_AddDiagnosticsReply_h
13 #define YARP_ROSMSG_diagnostic_msgs_AddDiagnosticsReply_h
14 
15 #include <yarp/os/Wire.h>
16 #include <yarp/os/Type.h>
17 #include <yarp/os/idl/WireTypes.h>
18 #include <string>
19 #include <vector>
20 
21 namespace yarp {
22 namespace rosmsg {
23 namespace diagnostic_msgs {
24 
26 {
27 public:
28  bool success;
29  std::string message;
30 
32  success(false),
33  message("")
34  {
35  }
36 
37  void clear()
38  {
39  // *** success ***
40  success = false;
41 
42  // *** message ***
43  message = "";
44  }
45 
46  bool readBare(yarp::os::ConnectionReader& connection) override
47  {
48  // *** success ***
49  if (!connection.expectBlock((char*)&success, 1)) {
50  return false;
51  }
52 
53  // *** message ***
54  int len = connection.expectInt32();
55  message.resize(len);
56  if (!connection.expectBlock((char*)message.c_str(), len)) {
57  return false;
58  }
59 
60  return !connection.isError();
61  }
62 
63  bool readBottle(yarp::os::ConnectionReader& connection) override
64  {
65  connection.convertTextMode();
66  yarp::os::idl::WireReader reader(connection);
67  if (!reader.readListHeader(2)) {
68  return false;
69  }
70 
71  // *** success ***
72  success = reader.expectInt8();
73 
74  // *** message ***
75  if (!reader.readString(message)) {
76  return false;
77  }
78 
79  return !connection.isError();
80  }
81 
83  bool read(yarp::os::ConnectionReader& connection) override
84  {
85  return (connection.isBareMode() ? readBare(connection)
86  : readBottle(connection));
87  }
88 
89  bool writeBare(yarp::os::ConnectionWriter& connection) const override
90  {
91  // *** success ***
92  connection.appendBlock((char*)&success, 1);
93 
94  // *** message ***
95  connection.appendInt32(message.length());
96  connection.appendExternalBlock((char*)message.c_str(), message.length());
97 
98  return !connection.isError();
99  }
100 
101  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
102  {
103  connection.appendInt32(BOTTLE_TAG_LIST);
104  connection.appendInt32(2);
105 
106  // *** success ***
107  connection.appendInt32(BOTTLE_TAG_INT8);
108  connection.appendInt8(success);
109 
110  // *** message ***
111  connection.appendInt32(BOTTLE_TAG_STRING);
112  connection.appendInt32(message.length());
113  connection.appendExternalBlock((char*)message.c_str(), message.length());
114 
115  connection.convertTextMode();
116  return !connection.isError();
117  }
118 
120  bool write(yarp::os::ConnectionWriter& connection) const override
121  {
122  return (connection.isBareMode() ? writeBare(connection)
123  : writeBottle(connection));
124  }
125 
126  // This class will serialize ROS style or YARP style depending on protocol.
127  // If you need to force a serialization style, use one of these classes:
130 
131  // The name for this message, ROS will need this
132  static constexpr const char* typeName = "diagnostic_msgs/AddDiagnosticsReply";
133 
134  // The checksum for this message, ROS will need this
135  static constexpr const char* typeChecksum = "937c9679a518e3a18d831e57125ea522";
136 
137  // The source text for this message, ROS will need this
138  static constexpr const char* typeText = "\
139 \n\
140 ";
141 
142  yarp::os::Type getType() const override
143  {
145  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
146  typ.addProperty("message_definition", yarp::os::Value(typeText));
147  return typ;
148  }
149 };
150 
151 } // namespace diagnostic_msgs
152 } // namespace rosmsg
153 } // namespace yarp
154 
155 #endif // YARP_ROSMSG_diagnostic_msgs_AddDiagnosticsReply_h
#define BOTTLE_TAG_INT8
Definition: Bottle.h:19
#define BOTTLE_TAG_STRING
Definition: Bottle.h:26
#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 std::int32_t expectInt32()=0
Read a 32-bit integer from the network connection.
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 void appendExternalBlock(const char *data, size_t len)=0
Send a block of data to the network connection, without making a copy.
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
bool readString(std::string &str, bool *is_vocab=nullptr)
Definition: WireReader.cpp:382
std::int8_t expectInt8()
Definition: WireReader.h:80
yarp::os::idl::BottleStyle< yarp::rosmsg::diagnostic_msgs::AddDiagnosticsReply > bottleStyle
bool readBare(yarp::os::ConnectionReader &connection) override
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool readBottle(yarp::os::ConnectionReader &connection) override
yarp::os::idl::BareStyle< yarp::rosmsg::diagnostic_msgs::AddDiagnosticsReply > rosStyle
bool writeBare(yarp::os::ConnectionWriter &connection) const override
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
The main, catch-all namespace for YARP.
Definition: dirs.h:16