YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
ControlBoardRemapper_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(ControlBoardRemapperParamsCOMPONENT, "yarp.device.ControlBoardRemapper")
20}
21
22
26
27
29{
30 std::vector<std::string> params;
31 params.push_back("axesNames");
32 params.push_back("networkNames");
33 params.push_back("verbose");
34 return params;
35}
36
37
38bool ControlBoardRemapper_ParamsParser::getParamValue(const std::string& paramName, std::string& paramValue) const
39{
40 if (paramName =="axesNames")
41 {
42 std::ostringstream oss;
43 oss << "( ";
44 for (auto x : m_axesNames)
45 {
46 oss << x << " ";
47 }
48 oss << " )";
49 paramValue = oss.str();
50 return true;
51 }
52 if (paramName =="networkNames")
53 {
54 std::ostringstream oss;
55 oss << "( ";
56 for (auto x : m_networkNames)
57 {
58 oss << x << " ";
59 }
60 oss << " )";
61 paramValue = oss.str();
62 return true;
63 }
64 if (paramName =="verbose")
65 {
66 if (m_verbose==true) paramValue = "true";
67 else paramValue = "false";
68 return true;
69 }
70
71 yError() <<"parameter '" << paramName << "' was not found";
72 return false;
73
74}
75
76
78{
79 //This is a sub-optimal solution.
80 //Ideally getConfiguration() should return all parameters but it is currently
81 //returning only user provided parameters (excluding default values)
82 //This behaviour will be fixed in the near future.
83 std::string s_cfg = m_provided_configuration;
84 return s_cfg;
85}
86
88{
89 //Check for --help option
90 if (config.check("help"))
91 {
92 yCInfo(ControlBoardRemapperParamsCOMPONENT) << getDocumentationOfDeviceParams();
93 }
94
97 //Parser of parameter axesNames
98 {
99 if (config.check("axesNames"))
100 {
101 {
102 m_axesNames.clear();
103 yarp::os::Bottle* tempBot = config.find("axesNames").asList();
104 if (tempBot)
105 {
106 std::string tempBots = tempBot->toString();
107 for (size_t i=0; i<tempBot->size(); i++)
108 {
109 m_axesNames.push_back(tempBot->get(i).asString());
110 }
111 }
112 else
113 {
114 yCError(ControlBoardRemapperParamsCOMPONENT) <<"parameter 'axesNames' is not a properly formatted bottle";
115 }
116 }
117 yCInfo(ControlBoardRemapperParamsCOMPONENT) << "Parameter 'axesNames' using value:" << m_axesNames;
118 }
119 else
120 {
121 yCInfo(ControlBoardRemapperParamsCOMPONENT) << "Parameter 'axesNames' using DEFAULT value:" << m_axesNames;
122 }
123 prop_check.unput("axesNames");
124 }
125
126 //Parser of parameter networkNames
127 {
128 if (config.check("networkNames"))
129 {
130 {
131 m_networkNames.clear();
132 yarp::os::Bottle* tempBot = config.find("networkNames").asList();
133 if (tempBot)
134 {
135 std::string tempBots = tempBot->toString();
136 for (size_t i=0; i<tempBot->size(); i++)
137 {
138 m_networkNames.push_back(tempBot->get(i).asString());
139 }
140 }
141 else
142 {
143 yCError(ControlBoardRemapperParamsCOMPONENT) <<"parameter 'networkNames' is not a properly formatted bottle";
144 }
145 }
146 yCInfo(ControlBoardRemapperParamsCOMPONENT) << "Parameter 'networkNames' using value:" << m_networkNames;
147 }
148 else
149 {
150 yCInfo(ControlBoardRemapperParamsCOMPONENT) << "Parameter 'networkNames' using DEFAULT value:" << m_networkNames;
151 }
152 prop_check.unput("networkNames");
153 }
154
155 //Parser of parameter verbose
156 {
157 if (config.check("verbose"))
158 {
159 m_verbose = config.find("verbose").asBool();
160 yCInfo(ControlBoardRemapperParamsCOMPONENT) << "Parameter 'verbose' using value:" << m_verbose;
161 }
162 else
163 {
164 yCInfo(ControlBoardRemapperParamsCOMPONENT) << "Parameter 'verbose' using DEFAULT value:" << m_verbose;
165 }
166 prop_check.unput("verbose");
167 }
168
169 /*
170 //This code check if the user set some parameter which are not check by the parser
171 //If the parser is set in strict mode, this will generate an error
172 if (prop_check.size() > 0)
173 {
174 bool extra_params_found = false;
175 for (auto it=prop_check.begin(); it!=prop_check.end(); it++)
176 {
177 if (m_parser_is_strict)
178 {
179 yCError(ControlBoardRemapperParamsCOMPONENT) << "User asking for parameter: "<<it->name <<" which is unknown to this parser!";
180 extra_params_found = true;
181 }
182 else
183 {
184 yCWarning(ControlBoardRemapperParamsCOMPONENT) << "User asking for parameter: "<< it->name <<" which is unknown to this parser!";
185 }
186 }
187
188 if (m_parser_is_strict && extra_params_found)
189 {
190 return false;
191 }
192 }
193 */
194 return true;
195}
196
197
199{
200 std::string doc;
201 doc = doc + std::string("\n=============================================\n");
202 doc = doc + std::string("This is the help for device: ControlBoardRemapper\n");
203 doc = doc + std::string("\n");
204 doc = doc + std::string("This is the list of the parameters accepted by the device:\n");
205 doc = doc + std::string("'axesNames': Ordered list of the axes that are part of the remapped device. e.g.(/joint0 /joint1)\n");
206 doc = doc + std::string("'networkNames': List of the robot parts to be used in remapped device. e.g.(/partA /partB)\n");
207 doc = doc + std::string("'verbose': print additional output if enabled\n");
208 doc = doc + std::string("\n");
209 doc = doc + std::string("Here are some examples of invocation command with yarpdev, with all params:\n");
210 doc = doc + " yarpdev --device controlboardremapper --axesNames <optional_value> --networkNames <optional_value> --verbose false\n";
211 doc = doc + std::string("Using only mandatory params:\n");
212 doc = doc + " yarpdev --device controlboardremapper\n";
213 doc = doc + std::string("=============================================\n\n"); return doc;
214}
#define yError(...)
Definition Log.h:361
std::vector< std::string > getListOfParams() const override
Return a list of all params used by the device.
std::string getConfiguration() const override
Return the configuration of the device.
std::string getDocumentationOfDeviceParams() const override
Get the documentation of the DeviceDriver's parameters.
bool getParamValue(const std::string &paramName, std::string &paramValue) const override
Return the value (represented as a string) of the requested parameter.
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
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,...)