YARP
Yet Another Robot Platform
GoalID.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 "actionlib_msgs/GoalID" msg definition:
9 // # The stamp should store the time at which this goal was requested.
10 // # It is used by an action server when it tries to preempt all
11 // # goals that were requested before a certain time
12 // time stamp
13 //
14 // # The id provides a way to associate feedback and
15 // # result message with specific goal requests. The id
16 // # specified must be unique.
17 // string id
18 //
19 // Instances of this class can be read and written with YARP ports,
20 // using a ROS-compatible format.
21 
22 #ifndef YARP_ROSMSG_actionlib_msgs_GoalID_h
23 #define YARP_ROSMSG_actionlib_msgs_GoalID_h
24 
25 #include <yarp/os/Wire.h>
26 #include <yarp/os/Type.h>
27 #include <yarp/os/idl/WireTypes.h>
28 #include <string>
29 #include <vector>
30 #include <yarp/rosmsg/TickTime.h>
31 
32 namespace yarp {
33 namespace rosmsg {
34 namespace actionlib_msgs {
35 
37 {
38 public:
40  std::string id;
41 
42  GoalID() :
43  stamp(),
44  id("")
45  {
46  }
47 
48  void clear()
49  {
50  // *** stamp ***
51  stamp.clear();
52 
53  // *** id ***
54  id = "";
55  }
56 
57  bool readBare(yarp::os::ConnectionReader& connection) override
58  {
59  // *** stamp ***
60  if (!stamp.read(connection)) {
61  return false;
62  }
63 
64  // *** id ***
65  int len = connection.expectInt32();
66  id.resize(len);
67  if (!connection.expectBlock((char*)id.c_str(), len)) {
68  return false;
69  }
70 
71  return !connection.isError();
72  }
73 
74  bool readBottle(yarp::os::ConnectionReader& connection) override
75  {
76  connection.convertTextMode();
77  yarp::os::idl::WireReader reader(connection);
78  if (!reader.readListHeader(2)) {
79  return false;
80  }
81 
82  // *** stamp ***
83  if (!stamp.read(connection)) {
84  return false;
85  }
86 
87  // *** id ***
88  if (!reader.readString(id)) {
89  return false;
90  }
91 
92  return !connection.isError();
93  }
94 
96  bool read(yarp::os::ConnectionReader& connection) override
97  {
98  return (connection.isBareMode() ? readBare(connection)
99  : readBottle(connection));
100  }
101 
102  bool writeBare(yarp::os::ConnectionWriter& connection) const override
103  {
104  // *** stamp ***
105  if (!stamp.write(connection)) {
106  return false;
107  }
108 
109  // *** id ***
110  connection.appendInt32(id.length());
111  connection.appendExternalBlock((char*)id.c_str(), id.length());
112 
113  return !connection.isError();
114  }
115 
116  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
117  {
118  connection.appendInt32(BOTTLE_TAG_LIST);
119  connection.appendInt32(2);
120 
121  // *** stamp ***
122  if (!stamp.write(connection)) {
123  return false;
124  }
125 
126  // *** id ***
127  connection.appendInt32(BOTTLE_TAG_STRING);
128  connection.appendInt32(id.length());
129  connection.appendExternalBlock((char*)id.c_str(), id.length());
130 
131  connection.convertTextMode();
132  return !connection.isError();
133  }
134 
136  bool write(yarp::os::ConnectionWriter& connection) const override
137  {
138  return (connection.isBareMode() ? writeBare(connection)
139  : writeBottle(connection));
140  }
141 
142  // This class will serialize ROS style or YARP style depending on protocol.
143  // If you need to force a serialization style, use one of these classes:
146 
147  // The name for this message, ROS will need this
148  static constexpr const char* typeName = "actionlib_msgs/GoalID";
149 
150  // The checksum for this message, ROS will need this
151  static constexpr const char* typeChecksum = "302881f31927c1df708a2dbab0e80ee8";
152 
153  // The source text for this message, ROS will need this
154  static constexpr const char* typeText = "\
155 # The stamp should store the time at which this goal was requested.\n\
156 # It is used by an action server when it tries to preempt all\n\
157 # goals that were requested before a certain time\n\
158 time stamp\n\
159 \n\
160 # The id provides a way to associate feedback and\n\
161 # result message with specific goal requests. The id\n\
162 # specified must be unique.\n\
163 string id\n\
164 \n\
165 ";
166 
167  yarp::os::Type getType() const override
168  {
170  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
171  typ.addProperty("message_definition", yarp::os::Value(typeText));
172  return typ;
173  }
174 };
175 
176 } // namespace actionlib_msgs
177 } // namespace rosmsg
178 } // namespace yarp
179 
180 #endif // YARP_ROSMSG_actionlib_msgs_GoalID_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.
Definition: TickTime.h:148
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: TickTime.h:113
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: GoalID.h:96
yarp::os::idl::BareStyle< yarp::rosmsg::actionlib_msgs::GoalID > rosStyle
Definition: GoalID.h:144
static constexpr const char * typeName
Definition: GoalID.h:148
yarp::os::Type getType() const override
Definition: GoalID.h:167
static constexpr const char * typeChecksum
Definition: GoalID.h:151
static constexpr const char * typeText
Definition: GoalID.h:154
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: GoalID.h:57
yarp::rosmsg::TickTime stamp
Definition: GoalID.h:39
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: GoalID.h:136
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: GoalID.h:74
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: GoalID.h:102
yarp::os::idl::BottleStyle< yarp::rosmsg::actionlib_msgs::GoalID > bottleStyle
Definition: GoalID.h:145
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: GoalID.h:116
The main, catch-all namespace for YARP.
Definition: dirs.h:16