YARP
Yet Another Robot Platform
UInt8MultiArray.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/UInt8MultiArray" msg definition:
12 // # Please look at the MultiArrayLayout message definition for
13 // # documentation on all multiarrays.
14 //
15 // MultiArrayLayout layout # specification of data layout
16 // uint8[] data # array of data
17 //
18 // Instances of this class can be read and written with YARP ports,
19 // using a ROS-compatible format.
20 
21 #ifndef YARP_ROSMSG_std_msgs_UInt8MultiArray_h
22 #define YARP_ROSMSG_std_msgs_UInt8MultiArray_h
23 
24 #include <yarp/os/Wire.h>
25 #include <yarp/os/Type.h>
26 #include <yarp/os/idl/WireTypes.h>
27 #include <string>
28 #include <vector>
30 
31 namespace yarp {
32 namespace rosmsg {
33 namespace std_msgs {
34 
36 {
37 public:
39  std::vector<std::uint8_t> data;
40 
42  layout(),
43  data()
44  {
45  }
46 
47  void clear()
48  {
49  // *** layout ***
50  layout.clear();
51 
52  // *** data ***
53  data.clear();
54  }
55 
56  bool readBare(yarp::os::ConnectionReader& connection) override
57  {
58  // *** layout ***
59  if (!layout.read(connection)) {
60  return false;
61  }
62 
63  // *** data ***
64  int len = connection.expectInt32();
65  data.resize(len);
66  if (len > 0 && !connection.expectBlock((char*)&data[0], sizeof(std::uint8_t)*len)) {
67  return false;
68  }
69 
70  return !connection.isError();
71  }
72 
73  bool readBottle(yarp::os::ConnectionReader& connection) override
74  {
75  connection.convertTextMode();
76  yarp::os::idl::WireReader reader(connection);
77  if (!reader.readListHeader(2)) {
78  return false;
79  }
80 
81  // *** layout ***
82  if (!layout.read(connection)) {
83  return false;
84  }
85 
86  // *** data ***
87  if (connection.expectInt32() != (BOTTLE_TAG_LIST|BOTTLE_TAG_INT8)) {
88  return false;
89  }
90  int len = connection.expectInt32();
91  data.resize(len);
92  for (int i=0; i<len; i++) {
93  data[i] = (std::uint8_t)connection.expectInt8();
94  }
95 
96  return !connection.isError();
97  }
98 
100  bool read(yarp::os::ConnectionReader& connection) override
101  {
102  return (connection.isBareMode() ? readBare(connection)
103  : readBottle(connection));
104  }
105 
106  bool writeBare(yarp::os::ConnectionWriter& connection) const override
107  {
108  // *** layout ***
109  if (!layout.write(connection)) {
110  return false;
111  }
112 
113  // *** data ***
114  connection.appendInt32(data.size());
115  if (data.size()>0) {
116  connection.appendExternalBlock((char*)&data[0], sizeof(std::uint8_t)*data.size());
117  }
118 
119  return !connection.isError();
120  }
121 
122  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
123  {
124  connection.appendInt32(BOTTLE_TAG_LIST);
125  connection.appendInt32(2);
126 
127  // *** layout ***
128  if (!layout.write(connection)) {
129  return false;
130  }
131 
132  // *** data ***
134  connection.appendInt32(data.size());
135  for (size_t i=0; i<data.size(); i++) {
136  connection.appendInt8(data[i]);
137  }
138 
139  connection.convertTextMode();
140  return !connection.isError();
141  }
142 
144  bool write(yarp::os::ConnectionWriter& connection) const override
145  {
146  return (connection.isBareMode() ? writeBare(connection)
147  : writeBottle(connection));
148  }
149 
150  // This class will serialize ROS style or YARP style depending on protocol.
151  // If you need to force a serialization style, use one of these classes:
154 
155  // The name for this message, ROS will need this
156  static constexpr const char* typeName = "std_msgs/UInt8MultiArray";
157 
158  // The checksum for this message, ROS will need this
159  static constexpr const char* typeChecksum = "82373f1612381bb6ee473b5cd6f5d89c";
160 
161  // The source text for this message, ROS will need this
162  static constexpr const char* typeText = "\
163 # Please look at the MultiArrayLayout message definition for\n\
164 # documentation on all multiarrays.\n\
165 \n\
166 MultiArrayLayout layout # specification of data layout\n\
167 uint8[] data # array of data\n\
168 \n\
169 \n\
170 ================================================================================\n\
171 MSG: std_msgs/MultiArrayLayout\n\
172 # The multiarray declares a generic multi-dimensional array of a\n\
173 # particular data type. Dimensions are ordered from outer most\n\
174 # to inner most.\n\
175 \n\
176 MultiArrayDimension[] dim # Array of dimension properties\n\
177 uint32 data_offset # padding elements at front of data\n\
178 \n\
179 # Accessors should ALWAYS be written in terms of dimension stride\n\
180 # and specified outer-most dimension first.\n\
181 # \n\
182 # multiarray(i,j,k) = data[data_offset + dim_stride[1]*i + dim_stride[2]*j + k]\n\
183 #\n\
184 # A standard, 3-channel 640x480 image with interleaved color channels\n\
185 # would be specified as:\n\
186 #\n\
187 # dim[0].label = \"height\"\n\
188 # dim[0].size = 480\n\
189 # dim[0].stride = 3*640*480 = 921600 (note dim[0] stride is just size of image)\n\
190 # dim[1].label = \"width\"\n\
191 # dim[1].size = 640\n\
192 # dim[1].stride = 3*640 = 1920\n\
193 # dim[2].label = \"channel\"\n\
194 # dim[2].size = 3\n\
195 # dim[2].stride = 3\n\
196 #\n\
197 # multiarray(i,j,k) refers to the ith row, jth column, and kth channel.\n\
198 \n\
199 ================================================================================\n\
200 MSG: std_msgs/MultiArrayDimension\n\
201 string label # label of given dimension\n\
202 uint32 size # size of given dimension (in type units)\n\
203 uint32 stride # stride of given dimension\n\
204 ";
205 
206  yarp::os::Type getType() const override
207  {
209  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
210  typ.addProperty("message_definition", yarp::os::Value(typeText));
211  return typ;
212  }
213 };
214 
215 } // namespace std_msgs
216 } // namespace rosmsg
217 } // namespace yarp
218 
219 #endif // YARP_ROSMSG_std_msgs_UInt8MultiArray_h
yarp::rosmsg::std_msgs::UInt8MultiArray::UInt8MultiArray
UInt8MultiArray()
Definition: UInt8MultiArray.h:41
yarp::rosmsg::std_msgs::UInt8MultiArray::data
std::vector< std::uint8_t > data
Definition: UInt8MultiArray.h:39
yarp::rosmsg::std_msgs::UInt8MultiArray::read
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: UInt8MultiArray.h:100
yarp::rosmsg::std_msgs::UInt8MultiArray::clear
void clear()
Definition: UInt8MultiArray.h:47
yarp::rosmsg::std_msgs::MultiArrayLayout::read
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: MultiArrayLayout.h:120
WireTypes.h
BOTTLE_TAG_LIST
#define BOTTLE_TAG_LIST
Definition: Bottle.h:30
yarp::rosmsg::std_msgs::UInt8MultiArray::layout
yarp::rosmsg::std_msgs::MultiArrayLayout layout
Definition: UInt8MultiArray.h:38
yarp::os::idl::BottleStyle
Definition: BottleStyle.h:22
yarp::os::Type
Definition: Type.h:24
MultiArrayLayout.h
yarp::os::idl::WirePortable::read
virtual bool read(yarp::os::idl::WireReader &reader)
Definition: WirePortable.cpp:14
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::rosmsg::std_msgs::UInt8MultiArray::typeText
static constexpr const char * typeText
Definition: UInt8MultiArray.h:162
yarp::os::ConnectionReader::isBareMode
virtual bool isBareMode() const =0
Check if the connection is bare mode.
Wire.h
BOTTLE_TAG_INT8
#define BOTTLE_TAG_INT8
Definition: Bottle.h:21
yarp::rosmsg::std_msgs::UInt8MultiArray::readBare
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: UInt8MultiArray.h:56
yarp::rosmsg::std_msgs::UInt8MultiArray::typeName
static constexpr const char * typeName
Definition: UInt8MultiArray.h:156
yarp::os::ConnectionReader::expectInt8
virtual std::int8_t expectInt8()=0
Read a 8-bit integer from the network connection.
yarp::rosmsg::std_msgs::UInt8MultiArray::writeBottle
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: UInt8MultiArray.h:122
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::rosmsg::std_msgs::UInt8MultiArray::rosStyle
yarp::os::idl::BareStyle< yarp::rosmsg::std_msgs::UInt8MultiArray > rosStyle
Definition: UInt8MultiArray.h:152
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::UInt8MultiArray
Definition: UInt8MultiArray.h:36
yarp::rosmsg::std_msgs::UInt8MultiArray::typeChecksum
static constexpr const char * typeChecksum
Definition: UInt8MultiArray.h:159
yarp::rosmsg::std_msgs::MultiArrayLayout::clear
void clear()
Definition: MultiArrayLayout.h:67
yarp::os::idl::WirePortable
A "tamed" Portable, that promises to serialize itself in an IDL-friendly way.
Definition: WirePortable.h:26
yarp::rosmsg::std_msgs::UInt8MultiArray::bottleStyle
yarp::os::idl::BottleStyle< yarp::rosmsg::std_msgs::UInt8MultiArray > bottleStyle
Definition: UInt8MultiArray.h:153
yarp::os::ConnectionWriter::isBareMode
virtual bool isBareMode() const =0
Check if the connection is bare mode.
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::rosmsg::std_msgs::MultiArrayLayout
Definition: MultiArrayLayout.h:56
yarp::os::idl::BareStyle
Definition: BareStyle.h:22
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::rosmsg::std_msgs::UInt8MultiArray::writeBare
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: UInt8MultiArray.h:106
yarp::rosmsg::std_msgs::UInt8MultiArray::write
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: UInt8MultiArray.h:144
yarp::rosmsg::std_msgs::UInt8MultiArray::readBottle
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: UInt8MultiArray.h:73
yarp::rosmsg::std_msgs::MultiArrayLayout::write
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: MultiArrayLayout.h:165
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::UInt8MultiArray::getType
yarp::os::Type getType() const override
Definition: UInt8MultiArray.h:206
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::os::idl::WireReader::readListHeader
bool readListHeader()
Definition: WireReader.cpp:470
yarp::os::idl::WirePortable::write
virtual bool write(const yarp::os::idl::WireWriter &writer) const
Definition: WirePortable.cpp:20