YARP
Yet Another Robot Platform
SelfTestReply.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/SelfTestReply" 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_SelfTestReply_h
13 #define YARP_ROSMSG_diagnostic_msgs_SelfTestReply_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>
21 
22 namespace yarp {
23 namespace rosmsg {
24 namespace diagnostic_msgs {
25 
27 {
28 public:
29  std::string id;
30  std::uint8_t passed;
31  std::vector<yarp::rosmsg::diagnostic_msgs::DiagnosticStatus> status;
32 
34  id(""),
35  passed(0),
36  status()
37  {
38  }
39 
40  void clear()
41  {
42  // *** id ***
43  id = "";
44 
45  // *** passed ***
46  passed = 0;
47 
48  // *** status ***
49  status.clear();
50  }
51 
52  bool readBare(yarp::os::ConnectionReader& connection) override
53  {
54  // *** id ***
55  int len = connection.expectInt32();
56  id.resize(len);
57  if (!connection.expectBlock((char*)id.c_str(), len)) {
58  return false;
59  }
60 
61  // *** passed ***
62  passed = connection.expectInt8();
63 
64  // *** status ***
65  len = connection.expectInt32();
66  status.resize(len);
67  for (int i=0; i<len; i++) {
68  if (!status[i].read(connection)) {
69  return false;
70  }
71  }
72 
73  return !connection.isError();
74  }
75 
76  bool readBottle(yarp::os::ConnectionReader& connection) override
77  {
78  connection.convertTextMode();
79  yarp::os::idl::WireReader reader(connection);
80  if (!reader.readListHeader(3)) {
81  return false;
82  }
83 
84  // *** id ***
85  if (!reader.readString(id)) {
86  return false;
87  }
88 
89  // *** passed ***
90  passed = reader.expectInt8();
91 
92  // *** status ***
93  if (connection.expectInt32() != BOTTLE_TAG_LIST) {
94  return false;
95  }
96  int len = connection.expectInt32();
97  status.resize(len);
98  for (int i=0; i<len; i++) {
99  if (!status[i].read(connection)) {
100  return false;
101  }
102  }
103 
104  return !connection.isError();
105  }
106 
108  bool read(yarp::os::ConnectionReader& connection) override
109  {
110  return (connection.isBareMode() ? readBare(connection)
111  : readBottle(connection));
112  }
113 
114  bool writeBare(yarp::os::ConnectionWriter& connection) const override
115  {
116  // *** id ***
117  connection.appendInt32(id.length());
118  connection.appendExternalBlock((char*)id.c_str(), id.length());
119 
120  // *** passed ***
121  connection.appendInt8(passed);
122 
123  // *** status ***
124  connection.appendInt32(status.size());
125  for (size_t i=0; i<status.size(); i++) {
126  if (!status[i].write(connection)) {
127  return false;
128  }
129  }
130 
131  return !connection.isError();
132  }
133 
134  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
135  {
136  connection.appendInt32(BOTTLE_TAG_LIST);
137  connection.appendInt32(3);
138 
139  // *** id ***
140  connection.appendInt32(BOTTLE_TAG_STRING);
141  connection.appendInt32(id.length());
142  connection.appendExternalBlock((char*)id.c_str(), id.length());
143 
144  // *** passed ***
145  connection.appendInt32(BOTTLE_TAG_INT8);
146  connection.appendInt8(passed);
147 
148  // *** status ***
149  connection.appendInt32(BOTTLE_TAG_LIST);
150  connection.appendInt32(status.size());
151  for (size_t i=0; i<status.size(); i++) {
152  if (!status[i].write(connection)) {
153  return false;
154  }
155  }
156 
157  connection.convertTextMode();
158  return !connection.isError();
159  }
160 
162  bool write(yarp::os::ConnectionWriter& connection) const override
163  {
164  return (connection.isBareMode() ? writeBare(connection)
165  : writeBottle(connection));
166  }
167 
168  // This class will serialize ROS style or YARP style depending on protocol.
169  // If you need to force a serialization style, use one of these classes:
172 
173  // The name for this message, ROS will need this
174  static constexpr const char* typeName = "diagnostic_msgs/SelfTestReply";
175 
176  // The checksum for this message, ROS will need this
177  static constexpr const char* typeChecksum = "ac21b1bab7ab17546986536c22eb34e9";
178 
179  // The source text for this message, ROS will need this
180  static constexpr const char* typeText = "\
181 \n\
182 ================================================================================\n\
183 MSG: diagnostic_msgs/DiagnosticStatus\n\
184 # This message holds the status of an individual component of the robot.\n\
185 # \n\
186 \n\
187 # Possible levels of operations\n\
188 byte OK=0\n\
189 byte WARN=1\n\
190 byte ERROR=2\n\
191 byte STALE=3\n\
192 \n\
193 byte level # level of operation enumerated above \n\
194 string name # a description of the test/component reporting\n\
195 string message # a description of the status\n\
196 string hardware_id # a hardware unique string\n\
197 KeyValue[] values # an array of values associated with the status\n\
198 \n\
199 \n\
200 ================================================================================\n\
201 MSG: diagnostic_msgs/KeyValue\n\
202 string key # what to label this value when viewing\n\
203 string value # a value to track over time\n\
204 ";
205 
206  yarp::os::Type getType() const override
207  {
209  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
210  typ.addProperty("message_definition", yarp::os::Value(typeText));
211  return typ;
212  }
213 };
214 
215 } // namespace diagnostic_msgs
216 } // namespace rosmsg
217 } // namespace yarp
218 
219 #endif // YARP_ROSMSG_diagnostic_msgs_SelfTestReply_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
virtual std::int8_t expectInt8()=0
Read a 8-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 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.
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
static constexpr const char * typeName
bool writeBare(yarp::os::ConnectionWriter &connection) const override
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: SelfTestReply.h:52
yarp::os::idl::BareStyle< yarp::rosmsg::diagnostic_msgs::SelfTestReply > rosStyle
yarp::os::idl::BottleStyle< yarp::rosmsg::diagnostic_msgs::SelfTestReply > bottleStyle
yarp::os::Type getType() const override
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
static constexpr const char * typeText
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: SelfTestReply.h:76
static constexpr const char * typeChecksum
std::vector< yarp::rosmsg::diagnostic_msgs::DiagnosticStatus > status
Definition: SelfTestReply.h:31
The main, catch-all namespace for YARP.
Definition: dirs.h:16