YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
RemoteControlBoardRemapper_ParamsParser.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: LGPL-2.1-or-later
4 */
5
6
7// Generated by yarpDeviceParamParserGenerator (2.2)
8// This is an automatically generated file. Please do not edit it.
9// It will be re-generated if the cmake flag ALLOW_DEVICE_PARAM_PARSER_GENERATION is ON.
10
11// Generated on: Tue Aug 18 16:11:41 2026
12
13
15#include <yarp/os/LogStream.h>
16#include <yarp/os/Value.h>
17
18namespace {
19 YARP_LOG_COMPONENT(RemoteControlBoardRemapperParamsCOMPONENT, "yarp.device.RemoteControlBoardRemapper")
20}
21
22
26
27
29{
30 std::vector<std::string> params;
31 params.push_back("remoteControlBoards");
32 params.push_back("axesNames");
33 params.push_back("localPortPrefix");
34 params.push_back("verbose");
35 return params;
36}
37
38
39bool RemoteControlBoardRemapper_ParamsParser::getParamValue(const std::string& paramName, std::string& paramValue) const
40{
41 if (paramName =="remoteControlBoards")
42 {
43 std::ostringstream oss;
44 oss << "( ";
45 for (auto x : m_remoteControlBoards)
46 {
47 oss << x << " ";
48 }
49 oss << " )";
50 paramValue = oss.str();
51 return true;
52 }
53 if (paramName =="axesNames")
54 {
55 std::ostringstream oss;
56 oss << "( ";
57 for (auto x : m_axesNames)
58 {
59 oss << x << " ";
60 }
61 oss << " )";
62 paramValue = oss.str();
63 return true;
64 }
65 if (paramName =="localPortPrefix")
66 {
67 paramValue = m_localPortPrefix;
68 return true;
69 }
70 if (paramName =="verbose")
71 {
72 if (m_verbose==true) paramValue = "true";
73 else paramValue = "false";
74 return true;
75 }
76
77 yError() <<"parameter '" << paramName << "' was not found";
78 return false;
79
80}
81
82
84{
85 //This is a sub-optimal solution.
86 //Ideally getConfiguration() should return all parameters but it is currently
87 //returning only user provided parameters (excluding default values)
88 //This behaviour will be fixed in the near future.
89 std::string s_cfg = m_provided_configuration;
90 return s_cfg;
91}
92
94{
95 //Check for --help option
96 if (config.check("help"))
97 {
98 yCInfo(RemoteControlBoardRemapperParamsCOMPONENT) << getDocumentationOfDeviceParams();
99 }
100
103 //Parser of parameter remoteControlBoards
104 {
105 if (config.check("remoteControlBoards"))
106 {
107 {
108 m_remoteControlBoards.clear();
109 yarp::os::Bottle* tempBot = config.find("remoteControlBoards").asList();
110 if (tempBot)
111 {
112 std::string tempBots = tempBot->toString();
113 for (size_t i=0; i<tempBot->size(); i++)
114 {
115 m_remoteControlBoards.push_back(tempBot->get(i).asString());
116 }
117 }
118 else
119 {
120 yCError(RemoteControlBoardRemapperParamsCOMPONENT) <<"parameter 'remoteControlBoards' is not a properly formatted bottle";
121 }
122 }
123 yCInfo(RemoteControlBoardRemapperParamsCOMPONENT) << "Parameter 'remoteControlBoards' using value:" << m_remoteControlBoards;
124 }
125 else
126 {
127 yCError(RemoteControlBoardRemapperParamsCOMPONENT) << "Mandatory parameter 'remoteControlBoards' not found!";
128 yCError(RemoteControlBoardRemapperParamsCOMPONENT) << "Description of the parameter: Ordered list of the axes that are part of the remapped device.";
129 return false;
130 }
131 prop_check.unput("remoteControlBoards");
132 }
133
134 //Parser of parameter axesNames
135 {
136 if (config.check("axesNames"))
137 {
138 {
139 m_axesNames.clear();
140 yarp::os::Bottle* tempBot = config.find("axesNames").asList();
141 if (tempBot)
142 {
143 std::string tempBots = tempBot->toString();
144 for (size_t i=0; i<tempBot->size(); i++)
145 {
146 m_axesNames.push_back(tempBot->get(i).asString());
147 }
148 }
149 else
150 {
151 yCError(RemoteControlBoardRemapperParamsCOMPONENT) <<"parameter 'axesNames' is not a properly formatted bottle";
152 }
153 }
154 yCInfo(RemoteControlBoardRemapperParamsCOMPONENT) << "Parameter 'axesNames' using value:" << m_axesNames;
155 }
156 else
157 {
158 yCError(RemoteControlBoardRemapperParamsCOMPONENT) << "Mandatory parameter 'axesNames' not found!";
159 yCError(RemoteControlBoardRemapperParamsCOMPONENT) << "Description of the parameter: List of remote prefix used by the remote controlboards";
160 return false;
161 }
162 prop_check.unput("axesNames");
163 }
164
165 //Parser of parameter localPortPrefix
166 {
167 if (config.check("localPortPrefix"))
168 {
169 m_localPortPrefix = config.find("localPortPrefix").asString();
170 yCInfo(RemoteControlBoardRemapperParamsCOMPONENT) << "Parameter 'localPortPrefix' using value:" << m_localPortPrefix;
171 }
172 else
173 {
174 yCError(RemoteControlBoardRemapperParamsCOMPONENT) << "Mandatory parameter 'localPortPrefix' not found!";
175 yCError(RemoteControlBoardRemapperParamsCOMPONENT) << "Description of the parameter: All ports opened by this device will start with this prefix";
176 return false;
177 }
178 prop_check.unput("localPortPrefix");
179 }
180
181 //Parser of parameter verbose
182 {
183 if (config.check("verbose"))
184 {
185 m_verbose = config.find("verbose").asBool();
186 yCInfo(RemoteControlBoardRemapperParamsCOMPONENT) << "Parameter 'verbose' using value:" << m_verbose;
187 }
188 else
189 {
190 yCInfo(RemoteControlBoardRemapperParamsCOMPONENT) << "Parameter 'verbose' using DEFAULT value:" << m_verbose;
191 }
192 prop_check.unput("verbose");
193 }
194
195 /*
196 //This code check if the user set some parameter which are not check by the parser
197 //If the parser is set in strict mode, this will generate an error
198 if (prop_check.size() > 0)
199 {
200 bool extra_params_found = false;
201 for (auto it=prop_check.begin(); it!=prop_check.end(); it++)
202 {
203 if (m_parser_is_strict)
204 {
205 yCError(RemoteControlBoardRemapperParamsCOMPONENT) << "User asking for parameter: "<<it->name <<" which is unknown to this parser!";
206 extra_params_found = true;
207 }
208 else
209 {
210 yCWarning(RemoteControlBoardRemapperParamsCOMPONENT) << "User asking for parameter: "<< it->name <<" which is unknown to this parser!";
211 }
212 }
213
214 if (m_parser_is_strict && extra_params_found)
215 {
216 return false;
217 }
218 }
219 */
220 return true;
221}
222
223
225{
226 std::string doc;
227 doc = doc + std::string("\n=============================================\n");
228 doc = doc + std::string("This is the help for device: RemoteControlBoardRemapper\n");
229 doc = doc + std::string("\n");
230 doc = doc + std::string("This is the list of the parameters accepted by the device:\n");
231 doc = doc + std::string("'remoteControlBoards': Ordered list of the axes that are part of the remapped device.\n");
232 doc = doc + std::string("'axesNames': List of remote prefix used by the remote controlboards\n");
233 doc = doc + std::string("'localPortPrefix': All ports opened by this device will start with this prefix\n");
234 doc = doc + std::string("'verbose': print additional output if enabled\n");
235 doc = doc + std::string("\n");
236 doc = doc + std::string("Here are some examples of invocation command with yarpdev, with all params:\n");
237 doc = doc + " yarpdev --device remotecontrolboardremapper --remoteControlBoards <mandatory_value> --axesNames <mandatory_value> --localPortPrefix <mandatory_value> --verbose false\n";
238 doc = doc + std::string("Using only mandatory params:\n");
239 doc = doc + " yarpdev --device remotecontrolboardremapper --remoteControlBoards <mandatory_value> --axesNames <mandatory_value> --localPortPrefix <mandatory_value>\n";
240 doc = doc + std::string("=============================================\n\n"); return doc;
241}
#define yError(...)
Definition Log.h:361
std::vector< std::string > getListOfParams() const override
Return a list of all params used by the device.
bool getParamValue(const std::string &paramName, std::string &paramValue) const override
Return the value (represented as a string) of the requested parameter.
std::string getDocumentationOfDeviceParams() const override
Get the documentation of the DeviceDriver's parameters.
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
std::string getConfiguration() const override
Return the configuration of the device.
A simple collection of objects that can be described and transmitted in a portable way.
Definition Bottle.h:64
size_type size() const
Gets the number of elements in the bottle.
Definition Bottle.cpp:252
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
Definition Bottle.cpp:247
std::string toString() const override
Gives a human-readable textual representation of the bottle.
Definition Bottle.cpp:212
A class for storing options and configuration information.
Definition Property.h:32
void unput(const std::string &key)
Remove the association from the given key to a value, if present.
A base class for nested structures that can be searched.
Definition Searchable.h:31
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
virtual std::string toString() const =0
Return a standard text representation of the content of the object.
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
virtual std::string asString() const
Get string value.
Definition Value.cpp:240
#define yCInfo(component,...)
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)