YARP
Yet Another Robot Platform
MultiArrayDimension.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 "std_msgs/MultiArrayDimension" msg definition:
9 // string label # label of given dimension
10 // uint32 size # size of given dimension (in type units)
11 // uint32 stride # stride of given dimension// Instances of this class can be read and written with YARP ports,
12 // using a ROS-compatible format.
13 
14 #ifndef YARP_ROSMSG_std_msgs_MultiArrayDimension_h
15 #define YARP_ROSMSG_std_msgs_MultiArrayDimension_h
16 
17 #include <yarp/os/Wire.h>
18 #include <yarp/os/Type.h>
19 #include <yarp/os/idl/WireTypes.h>
20 #include <string>
21 #include <vector>
22 
23 namespace yarp {
24 namespace rosmsg {
25 namespace std_msgs {
26 
28 {
29 public:
30  std::string label;
31  std::uint32_t size;
32  std::uint32_t stride;
33 
35  label(""),
36  size(0),
37  stride(0)
38  {
39  }
40 
41  void clear()
42  {
43  // *** label ***
44  label = "";
45 
46  // *** size ***
47  size = 0;
48 
49  // *** stride ***
50  stride = 0;
51  }
52 
53  bool readBare(yarp::os::ConnectionReader& connection) override
54  {
55  // *** label ***
56  int len = connection.expectInt32();
57  label.resize(len);
58  if (!connection.expectBlock((char*)label.c_str(), len)) {
59  return false;
60  }
61 
62  // *** size ***
63  size = connection.expectInt32();
64 
65  // *** stride ***
66  stride = connection.expectInt32();
67 
68  return !connection.isError();
69  }
70 
71  bool readBottle(yarp::os::ConnectionReader& connection) override
72  {
73  connection.convertTextMode();
74  yarp::os::idl::WireReader reader(connection);
75  if (!reader.readListHeader(3)) {
76  return false;
77  }
78 
79  // *** label ***
80  if (!reader.readString(label)) {
81  return false;
82  }
83 
84  // *** size ***
85  size = reader.expectInt32();
86 
87  // *** stride ***
88  stride = reader.expectInt32();
89 
90  return !connection.isError();
91  }
92 
94  bool read(yarp::os::ConnectionReader& connection) override
95  {
96  return (connection.isBareMode() ? readBare(connection)
97  : readBottle(connection));
98  }
99 
100  bool writeBare(yarp::os::ConnectionWriter& connection) const override
101  {
102  // *** label ***
103  connection.appendInt32(label.length());
104  connection.appendExternalBlock((char*)label.c_str(), label.length());
105 
106  // *** size ***
107  connection.appendInt32(size);
108 
109  // *** stride ***
110  connection.appendInt32(stride);
111 
112  return !connection.isError();
113  }
114 
115  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
116  {
117  connection.appendInt32(BOTTLE_TAG_LIST);
118  connection.appendInt32(3);
119 
120  // *** label ***
121  connection.appendInt32(BOTTLE_TAG_STRING);
122  connection.appendInt32(label.length());
123  connection.appendExternalBlock((char*)label.c_str(), label.length());
124 
125  // *** size ***
126  connection.appendInt32(BOTTLE_TAG_INT32);
127  connection.appendInt32(size);
128 
129  // *** stride ***
130  connection.appendInt32(BOTTLE_TAG_INT32);
131  connection.appendInt32(stride);
132 
133  connection.convertTextMode();
134  return !connection.isError();
135  }
136 
138  bool write(yarp::os::ConnectionWriter& connection) const override
139  {
140  return (connection.isBareMode() ? writeBare(connection)
141  : writeBottle(connection));
142  }
143 
144  // This class will serialize ROS style or YARP style depending on protocol.
145  // If you need to force a serialization style, use one of these classes:
148 
149  // The name for this message, ROS will need this
150  static constexpr const char* typeName = "std_msgs/MultiArrayDimension";
151 
152  // The checksum for this message, ROS will need this
153  static constexpr const char* typeChecksum = "4cd0c83a8683deae40ecdac60e53bfa8";
154 
155  // The source text for this message, ROS will need this
156  static constexpr const char* typeText = "\
157 string label # label of given dimension\n\
158 uint32 size # size of given dimension (in type units)\n\
159 uint32 stride # stride of given dimension\n\
160 ";
161 
162  yarp::os::Type getType() const override
163  {
165  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
166  typ.addProperty("message_definition", yarp::os::Value(typeText));
167  return typ;
168  }
169 };
170 
171 } // namespace std_msgs
172 } // namespace rosmsg
173 } // namespace yarp
174 
175 #endif // YARP_ROSMSG_std_msgs_MultiArrayDimension_h
#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
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
std::int32_t expectInt32()
Definition: WireReader.h:92
bool readBare(yarp::os::ConnectionReader &connection) override
bool readBottle(yarp::os::ConnectionReader &connection) override
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
yarp::os::idl::BareStyle< yarp::rosmsg::std_msgs::MultiArrayDimension > rosStyle
yarp::os::idl::BottleStyle< yarp::rosmsg::std_msgs::MultiArrayDimension > bottleStyle
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool writeBare(yarp::os::ConnectionWriter &connection) const override
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: Bool.h:19
The main, catch-all namespace for YARP.
Definition: dirs.h:16