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