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