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 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
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 size_t _csize;
99 reader.readListBegin(_etype, _csize);
100 // WireReader removes BOTTLE_TAG_LIST from the tag
101 constexpr int expected_tag = ((BOTTLE_TAG_LIST) & (~BOTTLE_TAG_LIST));
102 if constexpr (expected_tag != 0) {
103 if (_csize != 0 && _etype.code != expected_tag) {
104 return false;
105 }
106 }
107 waypoints.resize(_csize);
108 for (size_t _i = 0; _i < _csize; ++_i) {
109 if (reader.noMore()) {
110 reader.fail();
111 return false;
112 }
113 if (!reader.readNested(waypoints[_i])) {
114 reader.fail();
115 return false;
116 }
117 }
118 reader.readListEnd();
119 return true;
120}
121
122// write waypoints field
123bool Map2DPathData::write_waypoints(const yarp::os::idl::WireWriter& writer) const
124{
125 if (!writer.writeListBegin(BOTTLE_TAG_LIST, waypoints.size())) {
126 return false;
127 }
128 for (const auto& _item : waypoints) {
129 if (!writer.writeNested(_item)) {
130 return false;
131 }
132 }
133 if (!writer.writeListEnd()) {
134 return false;
135 }
136 return true;
137}
138
139// read (nested) waypoints field
140bool Map2DPathData::nested_read_waypoints(yarp::os::idl::WireReader& reader)
141{
142 if (reader.noMore()) {
143 reader.fail();
144 return false;
145 }
146 size_t _csize;
148 reader.readListBegin(_etype, _csize);
149 // WireReader removes BOTTLE_TAG_LIST from the tag
150 constexpr int expected_tag = ((BOTTLE_TAG_LIST) & (~BOTTLE_TAG_LIST));
151 if constexpr (expected_tag != 0) {
152 if (_csize != 0 && _etype.code != expected_tag) {
153 return false;
154 }
155 }
156 waypoints.resize(_csize);
157 for (size_t _i = 0; _i < _csize; ++_i) {
158 if (reader.noMore()) {
159 reader.fail();
160 return false;
161 }
162 if (!reader.readNested(waypoints[_i])) {
163 reader.fail();
164 return false;
165 }
166 }
167 reader.readListEnd();
168 return true;
169}
170
171// write (nested) waypoints field
172bool Map2DPathData::nested_write_waypoints(const yarp::os::idl::WireWriter& writer) const
173{
174 if (!writer.writeListBegin(BOTTLE_TAG_LIST, waypoints.size())) {
175 return false;
176 }
177 for (const auto& _item : waypoints) {
178 if (!writer.writeNested(_item)) {
179 return false;
180 }
181 }
182 if (!writer.writeListEnd()) {
183 return false;
184 }
185 return true;
186}
187
188// read description field
189bool Map2DPathData::read_description(yarp::os::idl::WireReader& reader)
190{
191 if (reader.noMore()) {
192 reader.fail();
193 return false;
194 }
195 if (!reader.readString(description)) {
196 reader.fail();
197 return false;
198 }
199 return true;
200}
201
202// write description field
203bool Map2DPathData::write_description(const yarp::os::idl::WireWriter& writer) const
204{
205 if (!writer.writeString(description)) {
206 return false;
207 }
208 return true;
209}
210
211// read (nested) description field
212bool Map2DPathData::nested_read_description(yarp::os::idl::WireReader& reader)
213{
214 if (reader.noMore()) {
215 reader.fail();
216 return false;
217 }
218 if (!reader.readString(description)) {
219 reader.fail();
220 return false;
221 }
222 return true;
223}
224
225// write (nested) description field
226bool Map2DPathData::nested_write_description(const yarp::os::idl::WireWriter& writer) const
227{
228 if (!writer.writeString(description)) {
229 return false;
230 }
231 return true;
232}
233
234} // namespace yarp::dev
#define BOTTLE_TAG_LIST
Definition Bottle.h:28
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: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.