YARP
Yet Another Robot Platform
MultipleAnalogSensorsMetadata.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 
23  thread_local static SensorRPCData s_return_helper;
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("getMetadata", 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'?", "SensorRPCData MultipleAnalogSensorsMetadata::getMetadata()");
68  }
69  bool ok = yarp().write(helper, helper);
71 }
72 
73 // help method
74 std::vector<std::string> MultipleAnalogSensorsMetadata::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("getMetadata");
81  helpString.emplace_back("help");
82  } else {
83  if (functionName == "getMetadata") {
84  helpString.emplace_back("SensorRPCData getMetadata() ");
85  helpString.emplace_back("Read the sensor metadata necessary to configure the MultipleAnalogSensorsClient device. ");
86  }
87  if (functionName == "help") {
88  helpString.emplace_back("std::vector<std::string> help(const std::string& functionName = \"--all\")");
89  helpString.emplace_back("Return list of available commands, or help message for a specific function");
90  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");
91  helpString.emplace_back("@return list of strings (one string per line)");
92  }
93  }
94  if (helpString.empty()) {
95  helpString.emplace_back("Command not found");
96  }
97  return helpString;
98 }
99 
100 // read from ConnectionReader
102 {
103  yarp::os::idl::WireReader reader(connection);
104  reader.expectAccept();
105  if (!reader.readListHeader()) {
106  reader.fail();
107  return false;
108  }
109 
110  std::string tag = reader.readTag();
111  bool direct = (tag == "__direct__");
112  if (direct) {
113  tag = reader.readTag();
114  }
115  while (!reader.isError()) {
116  if (tag == "getMetadata") {
118  yarp::os::idl::WireWriter writer(reader);
119  if (!writer.isNull()) {
120  if (!writer.writeListHeader(10)) {
121  return false;
122  }
124  return false;
125  }
126  }
127  reader.accept();
128  return true;
129  }
130  if (tag == "help") {
131  std::string functionName;
132  if (!reader.readString(functionName)) {
133  functionName = "--all";
134  }
135  auto help_strings = help(functionName);
136  yarp::os::idl::WireWriter writer(reader);
137  if (!writer.isNull()) {
138  if (!writer.writeListHeader(2)) {
139  return false;
140  }
141  if (!writer.writeTag("many", 1, 0)) {
142  return false;
143  }
144  if (!writer.writeListBegin(BOTTLE_TAG_INT32, static_cast<uint32_t>(help_strings.size()))) {
145  return false;
146  }
147  for (const auto& help_string : help_strings) {
148  if (!writer.writeString(help_string)) {
149  return false;
150  }
151  }
152  if (!writer.writeListEnd()) {
153  return false;
154  }
155  }
156  reader.accept();
157  return true;
158  }
159  if (reader.noMore()) {
160  reader.fail();
161  return false;
162  }
163  std::string next_tag = reader.readTag();
164  if (next_tag == "") {
165  break;
166  }
167  tag.append("_").append(next_tag);
168  }
169  return false;
170 }
#define BOTTLE_TAG_INT32
Definition: Bottle.h:21
#define yError(...)
Definition: Log.h:279
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.
virtual std::vector< std::string > help(const std::string &functionName="--all")
virtual SensorRPCData getMetadata()
Read the sensor metadata necessary to configure the MultipleAnalogSensorsClient device.
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