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
yarp::rosmsg::diagnostic_msgs::SelfTestReply::writeBottle
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: SelfTestReply.h:137
yarp::os::idl::WireReader::readString
bool readString(std::string &str, bool *is_vocab=nullptr)
Definition: WireReader.cpp:339
yarp::rosmsg::diagnostic_msgs::SelfTestReply::SelfTestReply
SelfTestReply()
Definition: SelfTestReply.h:36
yarp::rosmsg::diagnostic_msgs::SelfTestReply::passed
std::uint8_t passed
Definition: SelfTestReply.h:33
yarp::rosmsg::diagnostic_msgs::SelfTestReply::bottleStyle
yarp::os::idl::BottleStyle< yarp::rosmsg::diagnostic_msgs::SelfTestReply > bottleStyle
Definition: SelfTestReply.h:174
WireTypes.h
BOTTLE_TAG_LIST
#define BOTTLE_TAG_LIST
Definition: Bottle.h:30
yarp::rosmsg::diagnostic_msgs::SelfTestReply::writeBare
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: SelfTestReply.h:117
yarp::os::idl::BottleStyle
Definition: BottleStyle.h:22
yarp::os::Type
Definition: Type.h:24
yarp::rosmsg::diagnostic_msgs::SelfTestReply::clear
void clear()
Definition: SelfTestReply.h:43
yarp::os::idl::WirePortable::read
virtual bool read(yarp::os::idl::WireReader &reader)
Definition: WirePortable.cpp:14
yarp::os::ConnectionWriter::appendInt8
virtual void appendInt8(std::int8_t data)=0
Send a representation of a 8-bit integer to the network connection.
yarp::os::ConnectionReader::isBareMode
virtual bool isBareMode() const =0
Check if the connection is bare mode.
BOTTLE_TAG_STRING
#define BOTTLE_TAG_STRING
Definition: Bottle.h:28
Wire.h
BOTTLE_TAG_INT8
#define BOTTLE_TAG_INT8
Definition: Bottle.h:21
yarp::rosmsg::diagnostic_msgs::SelfTestReply::status
std::vector< yarp::rosmsg::diagnostic_msgs::DiagnosticStatus > status
Definition: SelfTestReply.h:34
yarp::rosmsg::diagnostic_msgs::SelfTestReply::write
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: SelfTestReply.h:165
yarp::os::ConnectionReader::expectInt8
virtual std::int8_t expectInt8()=0
Read a 8-bit integer from the network connection.
yarp::rosmsg::diagnostic_msgs::SelfTestReply::getType
yarp::os::Type getType() const override
Definition: SelfTestReply.h:209
yarp::os::ConnectionWriter::isError
virtual bool isError() const =0
yarp::os::Type::byName
static Type byName(const char *name)
Definition: Type.cpp:174
yarp::os::ConnectionReader::expectInt32
virtual std::int32_t expectInt32()=0
Read a 32-bit integer from the network connection.
yarp::os::Type::addProperty
Type & addProperty(const char *key, const Value &val)
Definition: Type.cpp:137
Type.h
yarp::os::ConnectionWriter
An interface for writing to a network connection.
Definition: ConnectionWriter.h:40
yarp::rosmsg::diagnostic_msgs::SelfTestReply::id
std::string id
Definition: SelfTestReply.h:32
yarp::rosmsg::diagnostic_msgs::SelfTestReply::read
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: SelfTestReply.h:111
yarp::os::ConnectionReader::isError
virtual bool isError() const =0
yarp::rosmsg::diagnostic_msgs::SelfTestReply::typeChecksum
static constexpr const char * typeChecksum
Definition: SelfTestReply.h:180
yarp::rosmsg::diagnostic_msgs::SelfTestReply::rosStyle
yarp::os::idl::BareStyle< yarp::rosmsg::diagnostic_msgs::SelfTestReply > rosStyle
Definition: SelfTestReply.h:173
yarp::os::ConnectionReader::convertTextMode
virtual bool convertTextMode()=0
Reads in a standard description in text mode, and converts it to a standard description in binary.
yarp::rosmsg::diagnostic_msgs::SelfTestReply::typeText
static constexpr const char * typeText
Definition: SelfTestReply.h:183
yarp::rosmsg::diagnostic_msgs::SelfTestReply::typeName
static constexpr const char * typeName
Definition: SelfTestReply.h:177
yarp::os::idl::WirePortable
A "tamed" Portable, that promises to serialize itself in an IDL-friendly way.
Definition: WirePortable.h:26
yarp::os::ConnectionWriter::isBareMode
virtual bool isBareMode() const =0
Check if the connection is bare mode.
yarp::os::ConnectionWriter::convertTextMode
virtual bool convertTextMode()=0
Converts a standard description in binary into a textual description, if the connection is in text-mo...
yarp::os::ConnectionWriter::appendInt32
virtual void appendInt32(std::int32_t data)=0
Send a representation of a 32-bit integer to the network connection.
yarp::os::idl::WireReader
IDL-friendly connection reader.
Definition: WireReader.h:33
yarp::os::ConnectionReader
An interface for reading from a network connection.
Definition: ConnectionReader.h:40
yarp::os::idl::BareStyle
Definition: BareStyle.h:22
diagnostic_msgs
Definition: AddDiagnostics.h:22
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
DiagnosticStatus.h
yarp::os::idl::WireReader::expectInt8
std::int8_t expectInt8()
Definition: WireReader.h:87
yarp::os::ConnectionWriter::appendExternalBlock
virtual void appendExternalBlock(const char *data, size_t len)=0
Send a block of data to the network connection, without making a copy.
yarp::os::ConnectionReader::expectBlock
virtual bool expectBlock(char *data, size_t len)=0
Read a block of data from the network connection.
yarp::os::Value
A single value (typically within a Bottle).
Definition: Value.h:47
yarp::rosmsg::diagnostic_msgs::SelfTestReply::readBottle
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: SelfTestReply.h:79
yarp::rosmsg::diagnostic_msgs::SelfTestReply::readBare
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: SelfTestReply.h:55
yarp::rosmsg::diagnostic_msgs::SelfTestReply
Definition: SelfTestReply.h:30
yarp::os::idl::WireReader::readListHeader
bool readListHeader()
Definition: WireReader.cpp:470
yarp::os::idl::WirePortable::write
virtual bool write(const yarp::os::idl::WireWriter &writer) const
Definition: WirePortable.cpp:20