YARP
Yet Another Robot Platform
MenuEntry.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 "visualization_msgs/MenuEntry" msg definition:
9 // # MenuEntry message.
10 //
11 // # Each InteractiveMarker message has an array of MenuEntry messages.
12 // # A collection of MenuEntries together describe a
13 // # menu/submenu/subsubmenu/etc tree, though they are stored in a flat
14 // # array. The tree structure is represented by giving each menu entry
15 // # an ID number and a "parent_id" field. Top-level entries are the
16 // # ones with parent_id = 0. Menu entries are ordered within their
17 // # level the same way they are ordered in the containing array. Parent
18 // # entries must appear before their children.
19 //
20 // # Example:
21 // # - id = 3
22 // # parent_id = 0
23 // # title = "fun"
24 // # - id = 2
25 // # parent_id = 0
26 // # title = "robot"
27 // # - id = 4
28 // # parent_id = 2
29 // # title = "pr2"
30 // # - id = 5
31 // # parent_id = 2
32 // # title = "turtle"
33 // #
34 // # Gives a menu tree like this:
35 // # - fun
36 // # - robot
37 // # - pr2
38 // # - turtle
39 //
40 // # ID is a number for each menu entry. Must be unique within the
41 // # control, and should never be 0.
42 // uint32 id
43 //
44 // # ID of the parent of this menu entry, if it is a submenu. If this
45 // # menu entry is a top-level entry, set parent_id to 0.
46 // uint32 parent_id
47 //
48 // # menu / entry title
49 // string title
50 //
51 // # Arguments to command indicated by command_type (below)
52 // string command
53 //
54 // # Command_type stores the type of response desired when this menu
55 // # entry is clicked.
56 // # FEEDBACK: send an InteractiveMarkerFeedback message with menu_entry_id set to this entry's id.
57 // # ROSRUN: execute "rosrun" with arguments given in the command field (above).
58 // # ROSLAUNCH: execute "roslaunch" with arguments given in the command field (above).
59 // uint8 FEEDBACK=0
60 // uint8 ROSRUN=1
61 // uint8 ROSLAUNCH=2
62 // uint8 command_type
63 // Instances of this class can be read and written with YARP ports,
64 // using a ROS-compatible format.
65 
66 #ifndef YARP_ROSMSG_visualization_msgs_MenuEntry_h
67 #define YARP_ROSMSG_visualization_msgs_MenuEntry_h
68 
69 #include <yarp/os/Wire.h>
70 #include <yarp/os/Type.h>
71 #include <yarp/os/idl/WireTypes.h>
72 #include <string>
73 #include <vector>
74 
75 namespace yarp {
76 namespace rosmsg {
77 namespace visualization_msgs {
78 
80 {
81 public:
82  std::uint32_t id;
83  std::uint32_t parent_id;
84  std::string title;
85  std::string command;
86  static const std::uint8_t FEEDBACK = 0;
87  static const std::uint8_t ROSRUN = 1;
88  static const std::uint8_t ROSLAUNCH = 2;
89  std::uint8_t command_type;
90 
92  id(0),
93  parent_id(0),
94  title(""),
95  command(""),
96  command_type(0)
97  {
98  }
99 
100  void clear()
101  {
102  // *** id ***
103  id = 0;
104 
105  // *** parent_id ***
106  parent_id = 0;
107 
108  // *** title ***
109  title = "";
110 
111  // *** command ***
112  command = "";
113 
114  // *** FEEDBACK ***
115 
116  // *** ROSRUN ***
117 
118  // *** ROSLAUNCH ***
119 
120  // *** command_type ***
121  command_type = 0;
122  }
123 
124  bool readBare(yarp::os::ConnectionReader& connection) override
125  {
126  // *** id ***
127  id = connection.expectInt32();
128 
129  // *** parent_id ***
130  parent_id = connection.expectInt32();
131 
132  // *** title ***
133  int len = connection.expectInt32();
134  title.resize(len);
135  if (!connection.expectBlock((char*)title.c_str(), len)) {
136  return false;
137  }
138 
139  // *** command ***
140  len = connection.expectInt32();
141  command.resize(len);
142  if (!connection.expectBlock((char*)command.c_str(), len)) {
143  return false;
144  }
145 
146  // *** command_type ***
147  command_type = connection.expectInt8();
148 
149  return !connection.isError();
150  }
151 
152  bool readBottle(yarp::os::ConnectionReader& connection) override
153  {
154  connection.convertTextMode();
155  yarp::os::idl::WireReader reader(connection);
156  if (!reader.readListHeader(8)) {
157  return false;
158  }
159 
160  // *** id ***
161  id = reader.expectInt32();
162 
163  // *** parent_id ***
164  parent_id = reader.expectInt32();
165 
166  // *** title ***
167  if (!reader.readString(title)) {
168  return false;
169  }
170 
171  // *** command ***
172  if (!reader.readString(command)) {
173  return false;
174  }
175 
176  // *** command_type ***
177  command_type = reader.expectInt8();
178 
179  return !connection.isError();
180  }
181 
183  bool read(yarp::os::ConnectionReader& connection) override
184  {
185  return (connection.isBareMode() ? readBare(connection)
186  : readBottle(connection));
187  }
188 
189  bool writeBare(yarp::os::ConnectionWriter& connection) const override
190  {
191  // *** id ***
192  connection.appendInt32(id);
193 
194  // *** parent_id ***
195  connection.appendInt32(parent_id);
196 
197  // *** title ***
198  connection.appendInt32(title.length());
199  connection.appendExternalBlock((char*)title.c_str(), title.length());
200 
201  // *** command ***
202  connection.appendInt32(command.length());
203  connection.appendExternalBlock((char*)command.c_str(), command.length());
204 
205  // *** command_type ***
206  connection.appendInt8(command_type);
207 
208  return !connection.isError();
209  }
210 
211  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
212  {
213  connection.appendInt32(BOTTLE_TAG_LIST);
214  connection.appendInt32(8);
215 
216  // *** id ***
217  connection.appendInt32(BOTTLE_TAG_INT32);
218  connection.appendInt32(id);
219 
220  // *** parent_id ***
221  connection.appendInt32(BOTTLE_TAG_INT32);
222  connection.appendInt32(parent_id);
223 
224  // *** title ***
225  connection.appendInt32(BOTTLE_TAG_STRING);
226  connection.appendInt32(title.length());
227  connection.appendExternalBlock((char*)title.c_str(), title.length());
228 
229  // *** command ***
230  connection.appendInt32(BOTTLE_TAG_STRING);
231  connection.appendInt32(command.length());
232  connection.appendExternalBlock((char*)command.c_str(), command.length());
233 
234  // *** command_type ***
235  connection.appendInt32(BOTTLE_TAG_INT8);
236  connection.appendInt8(command_type);
237 
238  connection.convertTextMode();
239  return !connection.isError();
240  }
241 
243  bool write(yarp::os::ConnectionWriter& connection) const override
244  {
245  return (connection.isBareMode() ? writeBare(connection)
246  : writeBottle(connection));
247  }
248 
249  // This class will serialize ROS style or YARP style depending on protocol.
250  // If you need to force a serialization style, use one of these classes:
253 
254  // The name for this message, ROS will need this
255  static constexpr const char* typeName = "visualization_msgs/MenuEntry";
256 
257  // The checksum for this message, ROS will need this
258  static constexpr const char* typeChecksum = "b90ec63024573de83b57aa93eb39be2d";
259 
260  // The source text for this message, ROS will need this
261  static constexpr const char* typeText = "\
262 # MenuEntry message.\n\
263 \n\
264 # Each InteractiveMarker message has an array of MenuEntry messages.\n\
265 # A collection of MenuEntries together describe a\n\
266 # menu/submenu/subsubmenu/etc tree, though they are stored in a flat\n\
267 # array. The tree structure is represented by giving each menu entry\n\
268 # an ID number and a \"parent_id\" field. Top-level entries are the\n\
269 # ones with parent_id = 0. Menu entries are ordered within their\n\
270 # level the same way they are ordered in the containing array. Parent\n\
271 # entries must appear before their children.\n\
272 \n\
273 # Example:\n\
274 # - id = 3\n\
275 # parent_id = 0\n\
276 # title = \"fun\"\n\
277 # - id = 2\n\
278 # parent_id = 0\n\
279 # title = \"robot\"\n\
280 # - id = 4\n\
281 # parent_id = 2\n\
282 # title = \"pr2\"\n\
283 # - id = 5\n\
284 # parent_id = 2\n\
285 # title = \"turtle\"\n\
286 #\n\
287 # Gives a menu tree like this:\n\
288 # - fun\n\
289 # - robot\n\
290 # - pr2\n\
291 # - turtle\n\
292 \n\
293 # ID is a number for each menu entry. Must be unique within the\n\
294 # control, and should never be 0.\n\
295 uint32 id\n\
296 \n\
297 # ID of the parent of this menu entry, if it is a submenu. If this\n\
298 # menu entry is a top-level entry, set parent_id to 0.\n\
299 uint32 parent_id\n\
300 \n\
301 # menu / entry title\n\
302 string title\n\
303 \n\
304 # Arguments to command indicated by command_type (below)\n\
305 string command\n\
306 \n\
307 # Command_type stores the type of response desired when this menu\n\
308 # entry is clicked.\n\
309 # FEEDBACK: send an InteractiveMarkerFeedback message with menu_entry_id set to this entry's id.\n\
310 # ROSRUN: execute \"rosrun\" with arguments given in the command field (above).\n\
311 # ROSLAUNCH: execute \"roslaunch\" with arguments given in the command field (above).\n\
312 uint8 FEEDBACK=0\n\
313 uint8 ROSRUN=1\n\
314 uint8 ROSLAUNCH=2\n\
315 uint8 command_type\n\
316 ";
317 
318  yarp::os::Type getType() const override
319  {
321  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
322  typ.addProperty("message_definition", yarp::os::Value(typeText));
323  return typ;
324  }
325 };
326 
327 } // namespace visualization_msgs
328 } // namespace rosmsg
329 } // namespace yarp
330 
331 #endif // YARP_ROSMSG_visualization_msgs_MenuEntry_h
#define BOTTLE_TAG_INT8
Definition: Bottle.h:19
#define BOTTLE_TAG_INT32
Definition: Bottle.h:21
#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
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: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
std::int8_t expectInt8()
Definition: WireReader.h:80
std::int32_t expectInt32()
Definition: WireReader.h:92
yarp::os::idl::BottleStyle< yarp::rosmsg::visualization_msgs::MenuEntry > bottleStyle
Definition: MenuEntry.h:252
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: MenuEntry.h:183
static const std::uint8_t ROSLAUNCH
Definition: MenuEntry.h:88
static constexpr const char * typeName
Definition: MenuEntry.h:255
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: MenuEntry.h:211
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: MenuEntry.h:124
yarp::os::Type getType() const override
Definition: MenuEntry.h:318
yarp::os::idl::BareStyle< yarp::rosmsg::visualization_msgs::MenuEntry > rosStyle
Definition: MenuEntry.h:251
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: MenuEntry.h:189
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: MenuEntry.h:243
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: MenuEntry.h:152
static constexpr const char * typeChecksum
Definition: MenuEntry.h:258
static const std::uint8_t FEEDBACK
Definition: MenuEntry.h:86
static const std::uint8_t ROSRUN
Definition: MenuEntry.h:87
static constexpr const char * typeText
Definition: MenuEntry.h:261
The main, catch-all namespace for YARP.
Definition: dirs.h:16