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