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