YARP
Yet Another Robot Platform
AddDiagnostics.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/AddDiagnostics" msg definition:
9 // # This service is used as part of the process for loading analyzers at runtime,
10 // # and should be used by a loader script or program, not as a standalone service.
11 // # Information about dynamic addition of analyzers can be found at
12 // # http://wiki.ros.org/diagnostics/Tutorials/Adding%20Analyzers%20at%20Runtime
13 //
14 // # The load_namespace parameter defines the namespace where parameters for the
15 // # initialization of analyzers in the diagnostic aggregator have been loaded. The
16 // # value should be a global name (i.e. /my/name/space), not a relative
17 // # (my/name/space) or private (~my/name/space) name. Analyzers will not be added
18 // # if a non-global name is used. The call will also fail if the namespace
19 // # contains parameters that follow a namespace structure that does not conform to
20 // # that expected by the analyzer definitions. See
21 // # http://wiki.ros.org/diagnostics/Tutorials/Configuring%20Diagnostic%20Aggregators
22 // # and http://wiki.ros.org/diagnostics/Tutorials/Using%20the%20GenericAnalyzer
23 // # for examples of the structure of yaml files which are expected to have been
24 // # loaded into the namespace.
25 // string load_namespace
26 // ---
27 //
28 // # True if diagnostic aggregator was updated with new diagnostics, False
29 // # otherwise. A false return value means that either there is a bond in the
30 // # aggregator which already used the requested namespace, or the initialization
31 // # of analyzers failed.
32 // bool success
33 //
34 // # Message with additional information about the success or failure
35 // string message
36 // Instances of this class can be read and written with YARP ports,
37 // using a ROS-compatible format.
38 
39 #ifndef YARP_ROSMSG_diagnostic_msgs_AddDiagnostics_h
40 #define YARP_ROSMSG_diagnostic_msgs_AddDiagnostics_h
41 
42 #include <yarp/os/Wire.h>
43 #include <yarp/os/Type.h>
44 #include <yarp/os/idl/WireTypes.h>
45 #include <string>
46 #include <vector>
47 
48 namespace yarp {
49 namespace rosmsg {
50 namespace diagnostic_msgs {
51 
53 {
54 public:
55  std::string load_namespace;
56 
58  load_namespace("")
59  {
60  }
61 
62  void clear()
63  {
64  // *** load_namespace ***
65  load_namespace = "";
66  }
67 
68  bool readBare(yarp::os::ConnectionReader& connection) override
69  {
70  // *** load_namespace ***
71  int len = connection.expectInt32();
72  load_namespace.resize(len);
73  if (!connection.expectBlock((char*)load_namespace.c_str(), len)) {
74  return false;
75  }
76 
77  return !connection.isError();
78  }
79 
80  bool readBottle(yarp::os::ConnectionReader& connection) override
81  {
82  connection.convertTextMode();
83  yarp::os::idl::WireReader reader(connection);
84  if (!reader.readListHeader(1)) {
85  return false;
86  }
87 
88  // *** load_namespace ***
89  if (!reader.readString(load_namespace)) {
90  return false;
91  }
92 
93  return !connection.isError();
94  }
95 
97  bool read(yarp::os::ConnectionReader& connection) override
98  {
99  return (connection.isBareMode() ? readBare(connection)
100  : readBottle(connection));
101  }
102 
103  bool writeBare(yarp::os::ConnectionWriter& connection) const override
104  {
105  // *** load_namespace ***
106  connection.appendInt32(load_namespace.length());
107  connection.appendExternalBlock((char*)load_namespace.c_str(), load_namespace.length());
108 
109  return !connection.isError();
110  }
111 
112  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
113  {
114  connection.appendInt32(BOTTLE_TAG_LIST);
115  connection.appendInt32(1);
116 
117  // *** load_namespace ***
118  connection.appendInt32(BOTTLE_TAG_STRING);
119  connection.appendInt32(load_namespace.length());
120  connection.appendExternalBlock((char*)load_namespace.c_str(), load_namespace.length());
121 
122  connection.convertTextMode();
123  return !connection.isError();
124  }
125 
127  bool write(yarp::os::ConnectionWriter& connection) const override
128  {
129  return (connection.isBareMode() ? writeBare(connection)
130  : writeBottle(connection));
131  }
132 
133  // This class will serialize ROS style or YARP style depending on protocol.
134  // If you need to force a serialization style, use one of these classes:
137 
138  // The name for this message, ROS will need this
139  static constexpr const char* typeName = "diagnostic_msgs/AddDiagnostics";
140 
141  // The checksum for this message, ROS will need this
142  static constexpr const char* typeChecksum = "c26cf6e164288fbc6050d74f838bcdf0";
143 
144  // The source text for this message, ROS will need this
145  static constexpr const char* typeText = "\
146 # This service is used as part of the process for loading analyzers at runtime,\n\
147 # and should be used by a loader script or program, not as a standalone service.\n\
148 # Information about dynamic addition of analyzers can be found at\n\
149 # http://wiki.ros.org/diagnostics/Tutorials/Adding%20Analyzers%20at%20Runtime\n\
150 \n\
151 # The load_namespace parameter defines the namespace where parameters for the\n\
152 # initialization of analyzers in the diagnostic aggregator have been loaded. The\n\
153 # value should be a global name (i.e. /my/name/space), not a relative\n\
154 # (my/name/space) or private (~my/name/space) name. Analyzers will not be added\n\
155 # if a non-global name is used. The call will also fail if the namespace\n\
156 # contains parameters that follow a namespace structure that does not conform to\n\
157 # that expected by the analyzer definitions. See\n\
158 # http://wiki.ros.org/diagnostics/Tutorials/Configuring%20Diagnostic%20Aggregators\n\
159 # and http://wiki.ros.org/diagnostics/Tutorials/Using%20the%20GenericAnalyzer\n\
160 # for examples of the structure of yaml files which are expected to have been\n\
161 # loaded into the namespace.\n\
162 string load_namespace\n\
163 ---\n\
164 \n\
165 # True if diagnostic aggregator was updated with new diagnostics, False\n\
166 # otherwise. A false return value means that either there is a bond in the\n\
167 # aggregator which already used the requested namespace, or the initialization\n\
168 # of analyzers failed.\n\
169 bool success\n\
170 \n\
171 # Message with additional information about the success or failure\n\
172 string message\n\
173 ";
174 
175  yarp::os::Type getType() const override
176  {
178  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
179  typ.addProperty("message_definition", yarp::os::Value(typeText));
180  return typ;
181  }
182 };
183 
184 } // namespace diagnostic_msgs
185 } // namespace rosmsg
186 } // namespace yarp
187 
188 #endif // YARP_ROSMSG_diagnostic_msgs_AddDiagnostics_h
#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 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
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
static constexpr const char * typeText
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
static constexpr const char * typeName
bool readBottle(yarp::os::ConnectionReader &connection) override
yarp::os::Type getType() const override
static constexpr const char * typeChecksum
bool writeBare(yarp::os::ConnectionWriter &connection) const override
bool readBare(yarp::os::ConnectionReader &connection) override
yarp::os::idl::BottleStyle< yarp::rosmsg::diagnostic_msgs::AddDiagnostics > bottleStyle
yarp::os::idl::BareStyle< yarp::rosmsg::diagnostic_msgs::AddDiagnostics > rosStyle
The main, catch-all namespace for YARP.
Definition: dirs.h:16