YARP
Yet Another Robot Platform
FrameTransformStorageSetRPC.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 
13 #include <yarp/os/idl/WireTypes.h>
14 
16  public yarp::os::Portable
17 {
18 public:
19  explicit FrameTransformStorageSetRPC_setTransformsRPC_helper(const std::vector<yarp::math::FrameTransform>& transforms);
20  bool write(yarp::os::ConnectionWriter& connection) const override;
21  bool read(yarp::os::ConnectionReader& connection) override;
22 
23  std::vector<yarp::math::FrameTransform> m_transforms;
24 
25  thread_local static bool s_return_helper;
26 };
27 
29 
31  m_transforms{transforms}
32 {
33  s_return_helper = {};
34 }
35 
37 {
38  yarp::os::idl::WireWriter writer(connection);
39  if (!writer.writeListHeader(2)) {
40  return false;
41  }
42  if (!writer.writeTag("setTransformsRPC", 1, 1)) {
43  return false;
44  }
45  if (!writer.writeListBegin(BOTTLE_TAG_LIST, static_cast<uint32_t>(m_transforms.size()))) {
46  return false;
47  }
48  for (const auto& _item12 : m_transforms) {
49  if (!writer.writeNested(_item12)) {
50  return false;
51  }
52  }
53  if (!writer.writeListEnd()) {
54  return false;
55  }
56  return true;
57 }
58 
60 {
61  yarp::os::idl::WireReader reader(connection);
62  if (!reader.readListReturn()) {
63  return false;
64  }
65  if (!reader.readBool(s_return_helper)) {
66  reader.fail();
67  return false;
68  }
69  return true;
70 }
71 
73  public yarp::os::Portable
74 {
75 public:
77  bool write(yarp::os::ConnectionWriter& connection) const override;
78  bool read(yarp::os::ConnectionReader& connection) override;
79 
81 
82  thread_local static bool s_return_helper;
83 };
84 
86 
88  m_transform{transform}
89 {
90  s_return_helper = {};
91 }
92 
94 {
95  yarp::os::idl::WireWriter writer(connection);
96  if (!writer.writeListHeader(2)) {
97  return false;
98  }
99  if (!writer.writeTag("setTransformRPC", 1, 1)) {
100  return false;
101  }
102  if (!writer.write(m_transform)) {
103  return false;
104  }
105  return true;
106 }
107 
109 {
110  yarp::os::idl::WireReader reader(connection);
111  if (!reader.readListReturn()) {
112  return false;
113  }
114  if (!reader.readBool(s_return_helper)) {
115  reader.fail();
116  return false;
117  }
118  return true;
119 }
120 
122  public yarp::os::Portable
123 {
124 public:
125  explicit FrameTransformStorageSetRPC_deleteTransformRPC_helper(const std::string& src, const std::string& dst);
126  bool write(yarp::os::ConnectionWriter& connection) const override;
127  bool read(yarp::os::ConnectionReader& connection) override;
128 
129  std::string m_src;
130  std::string m_dst;
131 
132  thread_local static bool s_return_helper;
133 };
134 
136 
138  m_src{src},
139  m_dst{dst}
140 {
141  s_return_helper = {};
142 }
143 
145 {
146  yarp::os::idl::WireWriter writer(connection);
147  if (!writer.writeListHeader(3)) {
148  return false;
149  }
150  if (!writer.writeTag("deleteTransformRPC", 1, 1)) {
151  return false;
152  }
153  if (!writer.writeString(m_src)) {
154  return false;
155  }
156  if (!writer.writeString(m_dst)) {
157  return false;
158  }
159  return true;
160 }
161 
163 {
164  yarp::os::idl::WireReader reader(connection);
165  if (!reader.readListReturn()) {
166  return false;
167  }
168  if (!reader.readBool(s_return_helper)) {
169  reader.fail();
170  return false;
171  }
172  return true;
173 }
174 
176  public yarp::os::Portable
177 {
178 public:
180  bool write(yarp::os::ConnectionWriter& connection) const override;
181  bool read(yarp::os::ConnectionReader& connection) override;
182 
183  thread_local static bool s_return_helper;
184 };
185 
187 
189 {
190  s_return_helper = {};
191 }
192 
194 {
195  yarp::os::idl::WireWriter writer(connection);
196  if (!writer.writeListHeader(1)) {
197  return false;
198  }
199  if (!writer.writeTag("clearAllRPC", 1, 1)) {
200  return false;
201  }
202  return true;
203 }
204 
206 {
207  yarp::os::idl::WireReader reader(connection);
208  if (!reader.readListReturn()) {
209  return false;
210  }
211  if (!reader.readBool(s_return_helper)) {
212  reader.fail();
213  return false;
214  }
215  return true;
216 }
217 
218 // Constructor
220 {
221  yarp().setOwner(*this);
222 }
223 
224 bool FrameTransformStorageSetRPC::setTransformsRPC(const std::vector<yarp::math::FrameTransform>& transforms)
225 {
227  if (!yarp().canWrite()) {
228  yError("Missing server method '%s'?", "bool FrameTransformStorageSetRPC::setTransformsRPC(const std::vector<yarp::math::FrameTransform>& transforms)");
229  }
230  bool ok = yarp().write(helper, helper);
232 }
233 
235 {
237  if (!yarp().canWrite()) {
238  yError("Missing server method '%s'?", "bool FrameTransformStorageSetRPC::setTransformRPC(const yarp::math::FrameTransform& transform)");
239  }
240  bool ok = yarp().write(helper, helper);
242 }
243 
244 bool FrameTransformStorageSetRPC::deleteTransformRPC(const std::string& src, const std::string& dst)
245 {
247  if (!yarp().canWrite()) {
248  yError("Missing server method '%s'?", "bool FrameTransformStorageSetRPC::deleteTransformRPC(const std::string& src, const std::string& dst)");
249  }
250  bool ok = yarp().write(helper, helper);
252 }
253 
255 {
257  if (!yarp().canWrite()) {
258  yError("Missing server method '%s'?", "bool FrameTransformStorageSetRPC::clearAllRPC()");
259  }
260  bool ok = yarp().write(helper, helper);
262 }
263 
264 // help method
265 std::vector<std::string> FrameTransformStorageSetRPC::help(const std::string& functionName)
266 {
267  bool showAll = (functionName == "--all");
268  std::vector<std::string> helpString;
269  if (showAll) {
270  helpString.emplace_back("*** Available commands:");
271  helpString.emplace_back("setTransformsRPC");
272  helpString.emplace_back("setTransformRPC");
273  helpString.emplace_back("deleteTransformRPC");
274  helpString.emplace_back("clearAllRPC");
275  helpString.emplace_back("help");
276  } else {
277  if (functionName == "setTransformsRPC") {
278  helpString.emplace_back("bool setTransformsRPC(const std::vector<yarp::math::FrameTransform>& transforms) ");
279  }
280  if (functionName == "setTransformRPC") {
281  helpString.emplace_back("bool setTransformRPC(const yarp::math::FrameTransform& transform) ");
282  }
283  if (functionName == "deleteTransformRPC") {
284  helpString.emplace_back("bool deleteTransformRPC(const std::string& src, const std::string& dst) ");
285  }
286  if (functionName == "clearAllRPC") {
287  helpString.emplace_back("bool clearAllRPC() ");
288  }
289  if (functionName == "help") {
290  helpString.emplace_back("std::vector<std::string> help(const std::string& functionName = \"--all\")");
291  helpString.emplace_back("Return list of available commands, or help message for a specific function");
292  helpString.emplace_back("@param functionName name of command for which to get a detailed description. If none or '--all' is provided, print list of available commands");
293  helpString.emplace_back("@return list of strings (one string per line)");
294  }
295  }
296  if (helpString.empty()) {
297  helpString.emplace_back("Command not found");
298  }
299  return helpString;
300 }
301 
302 // read from ConnectionReader
304 {
305  yarp::os::idl::WireReader reader(connection);
306  reader.expectAccept();
307  if (!reader.readListHeader()) {
308  reader.fail();
309  return false;
310  }
311 
312  std::string tag = reader.readTag();
313  bool direct = (tag == "__direct__");
314  if (direct) {
315  tag = reader.readTag();
316  }
317  while (!reader.isError()) {
318  if (tag == "setTransformsRPC") {
319  std::vector<yarp::math::FrameTransform> transforms;
320  transforms.clear();
321  uint32_t _size13;
322  yarp::os::idl::WireState _etype16;
323  reader.readListBegin(_etype16, _size13);
324  transforms.resize(_size13);
325  for (size_t _i17 = 0; _i17 < _size13; ++_i17) {
326  if (!reader.readNested(transforms[_i17])) {
327  reader.fail();
328  return false;
329  }
330  }
331  reader.readListEnd();
333  yarp::os::idl::WireWriter writer(reader);
334  if (!writer.isNull()) {
335  if (!writer.writeListHeader(1)) {
336  return false;
337  }
339  return false;
340  }
341  }
342  reader.accept();
343  return true;
344  }
345  if (tag == "setTransformRPC") {
346  yarp::math::FrameTransform transform;
347  if (!reader.read(transform)) {
348  reader.fail();
349  return false;
350  }
352  yarp::os::idl::WireWriter writer(reader);
353  if (!writer.isNull()) {
354  if (!writer.writeListHeader(1)) {
355  return false;
356  }
358  return false;
359  }
360  }
361  reader.accept();
362  return true;
363  }
364  if (tag == "deleteTransformRPC") {
365  std::string src;
366  std::string dst;
367  if (!reader.readString(src)) {
368  reader.fail();
369  return false;
370  }
371  if (!reader.readString(dst)) {
372  reader.fail();
373  return false;
374  }
376  yarp::os::idl::WireWriter writer(reader);
377  if (!writer.isNull()) {
378  if (!writer.writeListHeader(1)) {
379  return false;
380  }
382  return false;
383  }
384  }
385  reader.accept();
386  return true;
387  }
388  if (tag == "clearAllRPC") {
390  yarp::os::idl::WireWriter writer(reader);
391  if (!writer.isNull()) {
392  if (!writer.writeListHeader(1)) {
393  return false;
394  }
396  return false;
397  }
398  }
399  reader.accept();
400  return true;
401  }
402  if (tag == "help") {
403  std::string functionName;
404  if (!reader.readString(functionName)) {
405  functionName = "--all";
406  }
407  auto help_strings = help(functionName);
408  yarp::os::idl::WireWriter writer(reader);
409  if (!writer.isNull()) {
410  if (!writer.writeListHeader(2)) {
411  return false;
412  }
413  if (!writer.writeTag("many", 1, 0)) {
414  return false;
415  }
416  if (!writer.writeListBegin(BOTTLE_TAG_INT32, static_cast<uint32_t>(help_strings.size()))) {
417  return false;
418  }
419  for (const auto& help_string : help_strings) {
420  if (!writer.writeString(help_string)) {
421  return false;
422  }
423  }
424  if (!writer.writeListEnd()) {
425  return false;
426  }
427  }
428  reader.accept();
429  return true;
430  }
431  if (reader.noMore()) {
432  reader.fail();
433  return false;
434  }
435  std::string next_tag = reader.readTag();
436  if (next_tag == "") {
437  break;
438  }
439  tag.append("_").append(next_tag);
440  }
441  return false;
442 }
#define BOTTLE_TAG_INT32
Definition: Bottle.h:21
#define BOTTLE_TAG_LIST
Definition: Bottle.h:28
#define yError(...)
Definition: Log.h:279
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
FrameTransformStorageSetRPC_deleteTransformRPC_helper(const std::string &src, const std::string &dst)
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
FrameTransformStorageSetRPC_setTransformRPC_helper(const yarp::math::FrameTransform &transform)
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
FrameTransformStorageSetRPC_setTransformsRPC_helper(const std::vector< yarp::math::FrameTransform > &transforms)
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
std::vector< yarp::math::FrameTransform > m_transforms
virtual bool setTransformsRPC(const std::vector< yarp::math::FrameTransform > &transforms)
virtual std::vector< std::string > help(const std::string &functionName="--all")
virtual bool setTransformRPC(const yarp::math::FrameTransform &transform)
virtual bool deleteTransformRPC(const std::string &src, const std::string &dst)
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
An interface for reading from a network connection.
An interface for writing to a network connection.
This is a base class for objects that can be both read from and be written to the YARP network.
Definition: Portable.h:26
yarp::os::WireLink & yarp()
Get YARP state associated with this object.
Definition: Wire.h:29
IDL-friendly connection reader.
Definition: WireReader.h:30
bool readNested(WirePortable &obj)
Definition: WireReader.cpp:88
bool readString(std::string &str, bool *is_vocab=nullptr)
Definition: WireReader.cpp:382
void readListBegin(yarp::os::idl::WireState &nstate, std::uint32_t &len)
Definition: WireReader.cpp:632
bool read(WirePortable &obj)
Definition: WireReader.cpp:78
IDL-friendly state.
Definition: WireState.h:19
IDL-friendly connection writer.
Definition: WireWriter.h:30
bool write(const WirePortable &obj) const
Definition: WireWriter.cpp:52
bool writeBool(bool x) const
Definition: WireWriter.cpp:72
bool writeListHeader(int len) const
Definition: WireWriter.cpp:206
bool writeTag(const char *tag, int split, int len) const
Definition: WireWriter.cpp:164
bool writeListBegin(int tag, std::uint32_t len) const
Definition: WireWriter.cpp:227
bool writeString(const std::string &tag) const
Definition: WireWriter.cpp:189
bool writeNested(const WirePortable &obj) const
Definition: WireWriter.cpp:62