YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
Map2DAreaData.cpp
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// Autogenerated by Thrift Compiler (0.14.1-yarped)
7//
8// This is an automatically generated file.
9// It could get re-generated if the ALLOW_IDL_GENERATION flag is on.
10
12
13namespace yarp::dev {
14
15// Constructor with field values
16Map2DAreaData::Map2DAreaData(const std::string& map_id,
17 const std::vector<yarp::math::Vec2D<double>>& points,
18 const std::string& description) :
19 WirePortable(),
20 map_id(map_id),
21 points(points),
22 description(description)
23{
24}
25
26// Read structure on a Wire
28{
29 if (!read_map_id(reader)) {
30 return false;
31 }
32 if (!read_points(reader)) {
33 return false;
34 }
35 if (!read_description(reader)) {
36 return false;
37 }
38 if (reader.isError()) {
39 return false;
40 }
41 return true;
42}
43
44// Read structure on a Connection
46{
47 yarp::os::idl::WireReader reader(connection);
48 if (!reader.readListHeader(3)) {
49 return false;
50 }
51 if (!read(reader)) {
52 return false;
53 }
54 return true;
55}
56
57// Write structure on a Wire
59{
60 if (!write_map_id(writer)) {
61 return false;
62 }
63 if (!write_points(writer)) {
64 return false;
65 }
66 if (!write_description(writer)) {
67 return false;
68 }
69 if (writer.isError()) {
70 return false;
71 }
72 return true;
73}
74
75// Write structure on a Connection
77{
78 yarp::os::idl::WireWriter writer(connection);
79 if (!writer.writeListHeader(3)) {
80 return false;
81 }
82 if (!write(writer)) {
83 return false;
84 }
85 return true;
86}
87
88// Convert to a printable string
89std::string Map2DAreaData::toString() const
90{
92 if (!yarp::os::Portable::copyPortable(*this, b)) {
93 return {};
94 }
95 return b.toString();
96}
97
98// read map_id field
99bool Map2DAreaData::read_map_id(yarp::os::idl::WireReader& reader)
100{
101 if (reader.noMore()) {
102 reader.fail();
103 return false;
104 }
105 if (!reader.readString(map_id)) {
106 reader.fail();
107 return false;
108 }
109 return true;
110}
111
112// write map_id field
113bool Map2DAreaData::write_map_id(const yarp::os::idl::WireWriter& writer) const
114{
115 if (!writer.writeString(map_id)) {
116 return false;
117 }
118 return true;
119}
120
121// read (nested) map_id field
122bool Map2DAreaData::nested_read_map_id(yarp::os::idl::WireReader& reader)
123{
124 if (reader.noMore()) {
125 reader.fail();
126 return false;
127 }
128 if (!reader.readString(map_id)) {
129 reader.fail();
130 return false;
131 }
132 return true;
133}
134
135// write (nested) map_id field
136bool Map2DAreaData::nested_write_map_id(const yarp::os::idl::WireWriter& writer) const
137{
138 if (!writer.writeString(map_id)) {
139 return false;
140 }
141 return true;
142}
143
144// read points field
145bool Map2DAreaData::read_points(yarp::os::idl::WireReader& reader)
146{
147 if (reader.noMore()) {
148 reader.fail();
149 return false;
150 }
151 size_t _csize;
153 reader.readListBegin(_etype, _csize);
154 // WireReader removes BOTTLE_TAG_LIST from the tag
155 constexpr int expected_tag = ((BOTTLE_TAG_LIST) & (~BOTTLE_TAG_LIST));
156 if constexpr (expected_tag != 0) {
157 if (_csize != 0 && _etype.code != expected_tag) {
158 return false;
159 }
160 }
161 points.resize(_csize);
162 for (size_t _i = 0; _i < _csize; ++_i) {
163 if (reader.noMore()) {
164 reader.fail();
165 return false;
166 }
167 if (!reader.readNested(points[_i])) {
168 reader.fail();
169 return false;
170 }
171 }
172 reader.readListEnd();
173 return true;
174}
175
176// write points field
177bool Map2DAreaData::write_points(const yarp::os::idl::WireWriter& writer) const
178{
179 if (!writer.writeListBegin(BOTTLE_TAG_LIST, points.size())) {
180 return false;
181 }
182 for (const auto& _item : points) {
183 if (!writer.writeNested(_item)) {
184 return false;
185 }
186 }
187 if (!writer.writeListEnd()) {
188 return false;
189 }
190 return true;
191}
192
193// read (nested) points field
194bool Map2DAreaData::nested_read_points(yarp::os::idl::WireReader& reader)
195{
196 if (reader.noMore()) {
197 reader.fail();
198 return false;
199 }
200 size_t _csize;
202 reader.readListBegin(_etype, _csize);
203 // WireReader removes BOTTLE_TAG_LIST from the tag
204 constexpr int expected_tag = ((BOTTLE_TAG_LIST) & (~BOTTLE_TAG_LIST));
205 if constexpr (expected_tag != 0) {
206 if (_csize != 0 && _etype.code != expected_tag) {
207 return false;
208 }
209 }
210 points.resize(_csize);
211 for (size_t _i = 0; _i < _csize; ++_i) {
212 if (reader.noMore()) {
213 reader.fail();
214 return false;
215 }
216 if (!reader.readNested(points[_i])) {
217 reader.fail();
218 return false;
219 }
220 }
221 reader.readListEnd();
222 return true;
223}
224
225// write (nested) points field
226bool Map2DAreaData::nested_write_points(const yarp::os::idl::WireWriter& writer) const
227{
228 if (!writer.writeListBegin(BOTTLE_TAG_LIST, points.size())) {
229 return false;
230 }
231 for (const auto& _item : points) {
232 if (!writer.writeNested(_item)) {
233 return false;
234 }
235 }
236 if (!writer.writeListEnd()) {
237 return false;
238 }
239 return true;
240}
241
242// read description field
243bool Map2DAreaData::read_description(yarp::os::idl::WireReader& reader)
244{
245 if (reader.noMore()) {
246 reader.fail();
247 return false;
248 }
249 if (!reader.readString(description)) {
250 reader.fail();
251 return false;
252 }
253 return true;
254}
255
256// write description field
257bool Map2DAreaData::write_description(const yarp::os::idl::WireWriter& writer) const
258{
259 if (!writer.writeString(description)) {
260 return false;
261 }
262 return true;
263}
264
265// read (nested) description field
266bool Map2DAreaData::nested_read_description(yarp::os::idl::WireReader& reader)
267{
268 if (reader.noMore()) {
269 reader.fail();
270 return false;
271 }
272 if (!reader.readString(description)) {
273 reader.fail();
274 return false;
275 }
276 return true;
277}
278
279// write (nested) description field
280bool Map2DAreaData::nested_write_description(const yarp::os::idl::WireWriter& writer) const
281{
282 if (!writer.writeString(description)) {
283 return false;
284 }
285 return true;
286}
287
288} // namespace yarp::dev
#define BOTTLE_TAG_LIST
Definition Bottle.h:28
bool read(yarp::os::idl::WireReader &reader) override
bool write(const yarp::os::idl::WireWriter &writer) const override
std::string description
user defined string
std::string map_id
name of the map
std::string toString() const
std::vector< yarp::math::Vec2D< double > > points
list of points which define the vertices of the area
A simple collection of objects that can be described and transmitted in a portable way.
Definition Bottle.h:64
std::string toString() const override
Gives a human-readable textual representation of the bottle.
Definition Bottle.cpp:211
An interface for reading from a network connection.
An interface for writing to a network connection.
static bool copyPortable(const PortWriter &writer, PortReader &reader)
Copy one portable to another, via writing and reading.
Definition Portable.cpp:16
IDL-friendly connection reader.
Definition WireReader.h:27
bool readNested(WirePortable &obj)
bool readString(std::string &str, bool *is_vocab=nullptr)
void readListBegin(yarp::os::idl::WireState &nstate, size_t &len)
IDL-friendly state.
Definition WireState.h:17
IDL-friendly connection writer.
Definition WireWriter.h:28
bool writeListHeader(int len) const
bool writeString(const std::string &str, bool skip_tag=false) const
bool writeNested(const WirePortable &obj) const
bool writeListBegin(int tag, size_t len) const
For streams capable of holding different kinds of content, check what they actually have.