YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
Map2DPathData.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 (based on compiler 0.14.1-yarped)
7// yarpidl_thrift version 2.0 - 11/11/2026
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
16Map2DPathData::Map2DPathData(const std::vector<yarp::dev::Nav2D::Map2DLocation>& waypoints,
17 const std::string& description) :
18 WirePortable(),
19 waypoints(waypoints),
20 description(description)
21{
22}
23
24// Read structure on a Wire
26{
27 if (!read_waypoints(reader)) {
28 return false;
29 }
30 if (!read_description(reader)) {
31 return false;
32 }
33 if (reader.isError()) {
34 return false;
35 }
36 return true;
37}
38
39// Read structure on a Connection
41{
42 yarp::os::idl::WireReader reader(connection);
43 if (!reader.readListHeader(2)) {
44 return false;
45 }
46 if (!read(reader)) {
47 return false;
48 }
49 return true;
50}
51
52// Write structure on a Wire
54{
55 if (!write_waypoints(writer)) {
56 return false;
57 }
58 if (!write_description(writer)) {
59 return false;
60 }
61 if (writer.isError()) {
62 return false;
63 }
64 return true;
65}
66
67// Write structure on a Connection
69{
70 yarp::os::idl::WireWriter writer(connection);
71 if (!writer.writeListHeader(2)) {
72 return false;
73 }
74 if (!write(writer)) {
75 return false;
76 }
77 return true;
78}
79
80// Convert to a printable string
81std::string Map2DPathData::toString() const
82{
84 if (!yarp::os::Portable::copyPortable(*this, b)) {
85 return {};
86 }
87 return b.toString();
88}
89
90// read waypoints field
91bool Map2DPathData::read_waypoints(yarp::os::idl::WireReader& reader)
92{
93 if (reader.noMore()) {
94 reader.fail();
95 return false;
96 }
97 {
98 size_t _csize;
100 reader.readListBegin(_etype, _csize);
101 // WireReader removes BOTTLE_TAG_LIST from the tag
102 constexpr int expected_tag = ((BOTTLE_TAG_LIST) & (~BOTTLE_TAG_LIST));
103 if constexpr (expected_tag != 0) {
104 if (_csize != 0 && _etype.code != expected_tag) {
105 return false;
106 }
107 }
108 waypoints.resize(_csize);
109 for (size_t _i0 = 0; _i0 < _csize; ++_i0) {
110 if (reader.noMore()) {
111 reader.fail();
112 return false;
113 }
114 if (!reader.readNested(waypoints[_i0])) {
115 reader.fail();
116 return false;
117 }
118 }
119 reader.readListEnd();
120 }
121 return true;
122}
123
124// write waypoints field
125bool Map2DPathData::write_waypoints(const yarp::os::idl::WireWriter& writer) const
126{
127 if (!writer.writeListBegin(BOTTLE_TAG_LIST, waypoints.size())) {
128 return false;
129 }
130 for (const auto& _item : waypoints) {
131 if (!writer.writeNested(_item)) {
132 return false;
133 }
134 }
135 if (!writer.writeListEnd()) {
136 return false;
137 }
138 return true;
139}
140
141// read (nested) waypoints field
142bool Map2DPathData::nested_read_waypoints(yarp::os::idl::WireReader& reader)
143{
144 if (reader.noMore()) {
145 reader.fail();
146 return false;
147 }
148 {
149 size_t _csize;
151 reader.readListBegin(_etype, _csize);
152 // WireReader removes BOTTLE_TAG_LIST from the tag
153 constexpr int expected_tag = ((BOTTLE_TAG_LIST) & (~BOTTLE_TAG_LIST));
154 if constexpr (expected_tag != 0) {
155 if (_csize != 0 && _etype.code != expected_tag) {
156 return false;
157 }
158 }
159 waypoints.resize(_csize);
160 for (size_t _i0 = 0; _i0 < _csize; ++_i0) {
161 if (reader.noMore()) {
162 reader.fail();
163 return false;
164 }
165 if (!reader.readNested(waypoints[_i0])) {
166 reader.fail();
167 return false;
168 }
169 }
170 reader.readListEnd();
171 }
172 return true;
173}
174
175// write (nested) waypoints field
176bool Map2DPathData::nested_write_waypoints(const yarp::os::idl::WireWriter& writer) const
177{
178 if (!writer.writeListBegin(BOTTLE_TAG_LIST, waypoints.size())) {
179 return false;
180 }
181 for (const auto& _item : waypoints) {
182 if (!writer.writeNested(_item)) {
183 return false;
184 }
185 }
186 if (!writer.writeListEnd()) {
187 return false;
188 }
189 return true;
190}
191
192// read description field
193bool Map2DPathData::read_description(yarp::os::idl::WireReader& reader)
194{
195 if (reader.noMore()) {
196 reader.fail();
197 return false;
198 }
199 if (!reader.readString(description)) {
200 reader.fail();
201 return false;
202 }
203 return true;
204}
205
206// write description field
207bool Map2DPathData::write_description(const yarp::os::idl::WireWriter& writer) const
208{
209 if (!writer.writeString(description)) {
210 return false;
211 }
212 return true;
213}
214
215// read (nested) description field
216bool Map2DPathData::nested_read_description(yarp::os::idl::WireReader& reader)
217{
218 if (reader.noMore()) {
219 reader.fail();
220 return false;
221 }
222 if (!reader.readString(description)) {
223 reader.fail();
224 return false;
225 }
226 return true;
227}
228
229// write (nested) description field
230bool Map2DPathData::nested_write_description(const yarp::os::idl::WireWriter& writer) const
231{
232 if (!writer.writeString(description)) {
233 return false;
234 }
235 return true;
236}
237
238} // namespace yarp::dev
#define BOTTLE_TAG_LIST
Definition Bottle.h:29
std::string toString() const
bool write(const yarp::os::idl::WireWriter &writer) const override
std::vector< yarp::dev::Nav2D::Map2DLocation > waypoints
list of waypoints which define the path
std::string description
user defined string
bool read(yarp::os::idl::WireReader &reader) override
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:212
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.