YARP
Yet Another Robot Platform
FrameTransformStorageGetRPC.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:
20  bool write(yarp::os::ConnectionWriter& connection) const override;
21  bool read(yarp::os::ConnectionReader& connection) override;
22 
24 };
25 
27 
29 {
30 }
31 
33 {
34  yarp::os::idl::WireWriter writer(connection);
35  if (!writer.writeListHeader(1)) {
36  return false;
37  }
38  if (!writer.writeTag("getTransformsRPC", 1, 1)) {
39  return false;
40  }
41  return true;
42 }
43 
45 {
46  yarp::os::idl::WireReader reader(connection);
47  if (!reader.readListReturn()) {
48  return false;
49  }
50  if (!reader.read(s_return_helper)) {
51  reader.fail();
52  return false;
53  }
54  return true;
55 }
56 
57 // Constructor
59 {
60  yarp().setOwner(*this);
61 }
62 
64 {
66  if (!yarp().canWrite()) {
67  yError("Missing server method '%s'?", "return_getAllTransforms FrameTransformStorageGetRPC::getTransformsRPC()");
68  }
69  bool ok = yarp().write(helper, helper);
71 }
72 
73 // help method
74 std::vector<std::string> FrameTransformStorageGetRPC::help(const std::string& functionName)
75 {
76  bool showAll = (functionName == "--all");
77  std::vector<std::string> helpString;
78  if (showAll) {
79  helpString.emplace_back("*** Available commands:");
80  helpString.emplace_back("getTransformsRPC");
81  helpString.emplace_back("help");
82  } else {
83  if (functionName == "getTransformsRPC") {
84  helpString.emplace_back("return_getAllTransforms getTransformsRPC() ");
85  }
86  if (functionName == "help") {
87  helpString.emplace_back("std::vector<std::string> help(const std::string& functionName = \"--all\")");
88  helpString.emplace_back("Return list of available commands, or help message for a specific function");
89  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");
90  helpString.emplace_back("@return list of strings (one string per line)");
91  }
92  }
93  if (helpString.empty()) {
94  helpString.emplace_back("Command not found");
95  }
96  return helpString;
97 }
98 
99 // read from ConnectionReader
101 {
102  yarp::os::idl::WireReader reader(connection);
103  reader.expectAccept();
104  if (!reader.readListHeader()) {
105  reader.fail();
106  return false;
107  }
108 
109  std::string tag = reader.readTag();
110  bool direct = (tag == "__direct__");
111  if (direct) {
112  tag = reader.readTag();
113  }
114  while (!reader.isError()) {
115  if (tag == "getTransformsRPC") {
117  yarp::os::idl::WireWriter writer(reader);
118  if (!writer.isNull()) {
119  if (!writer.writeListHeader(2)) {
120  return false;
121  }
123  return false;
124  }
125  }
126  reader.accept();
127  return true;
128  }
129  if (tag == "help") {
130  std::string functionName;
131  if (!reader.readString(functionName)) {
132  functionName = "--all";
133  }
134  auto help_strings = help(functionName);
135  yarp::os::idl::WireWriter writer(reader);
136  if (!writer.isNull()) {
137  if (!writer.writeListHeader(2)) {
138  return false;
139  }
140  if (!writer.writeTag("many", 1, 0)) {
141  return false;
142  }
143  if (!writer.writeListBegin(BOTTLE_TAG_INT32, static_cast<uint32_t>(help_strings.size()))) {
144  return false;
145  }
146  for (const auto& help_string : help_strings) {
147  if (!writer.writeString(help_string)) {
148  return false;
149  }
150  }
151  if (!writer.writeListEnd()) {
152  return false;
153  }
154  }
155  reader.accept();
156  return true;
157  }
158  if (reader.noMore()) {
159  reader.fail();
160  return false;
161  }
162  std::string next_tag = reader.readTag();
163  if (next_tag == "") {
164  break;
165  }
166  tag.append("_").append(next_tag);
167  }
168  return false;
169 }
#define BOTTLE_TAG_INT32
Definition: Bottle.h:21
#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.
static thread_local return_getAllTransforms s_return_helper
virtual return_getAllTransforms getTransformsRPC()
virtual std::vector< std::string > help(const std::string &functionName="--all")
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 readString(std::string &str, bool *is_vocab=nullptr)
Definition: WireReader.cpp:382
bool read(WirePortable &obj)
Definition: WireReader.cpp:78
IDL-friendly connection writer.
Definition: WireWriter.h:30
bool write(const WirePortable &obj) const
Definition: WireWriter.cpp:52
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