YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
MultipleAnalogSensorsServer_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.0)
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_GERNERATION is ON.
10
11// Generated on: Thu May 22 11:32:42 2025
12
13
15#include <yarp/os/LogStream.h>
16#include <yarp/os/Value.h>
17
18namespace {
19 YARP_LOG_COMPONENT(MultipleAnalogSensorsServerParamsCOMPONENT, "yarp.device.MultipleAnalogSensorsServer")
20}
21
22
26
27
29{
30 std::vector<std::string> params;
31 params.push_back("name");
32 params.push_back("period");
33 return params;
34}
35
36
37bool MultipleAnalogSensorsServer_ParamsParser::getParamValue(const std::string& paramName, std::string& paramValue) const
38{
39 if (paramName =="name")
40 {
41 paramValue = m_name;
42 return true;
43 }
44 if (paramName =="period")
45 {
46 paramValue = std::to_string(m_period);
47 return true;
48 }
49
50 yError() <<"parameter '" << paramName << "' was not found";
51 return false;
52
53}
54
55
57{
58 //This is a sub-optimal solution.
59 //Ideally getConfiguration() should return all parameters but it is currently
60 //returning only user provided parameters (excluding default values)
61 //This behaviour will be fixed in the near future.
62 std::string s_cfg = m_provided_configuration;
63 return s_cfg;
64}
65
67{
68 //Check for --help option
69 if (config.check("help"))
70 {
71 yCInfo(MultipleAnalogSensorsServerParamsCOMPONENT) << getDocumentationOfDeviceParams();
72 }
73
76 //Parser of parameter name
77 {
78 if (config.check("name"))
79 {
80 m_name = config.find("name").asString();
81 yCInfo(MultipleAnalogSensorsServerParamsCOMPONENT) << "Parameter 'name' using value:" << m_name;
82 }
83 else
84 {
85 yCError(MultipleAnalogSensorsServerParamsCOMPONENT) << "Mandatory parameter 'name' not found!";
86 yCError(MultipleAnalogSensorsServerParamsCOMPONENT) << "Description of the parameter: Prefix of the port opened by this device";
87 return false;
88 }
89 prop_check.unput("name");
90 }
91
92 //Parser of parameter period
93 {
94 if (config.check("period"))
95 {
96 m_period = config.find("period").asInt64();
97 yCInfo(MultipleAnalogSensorsServerParamsCOMPONENT) << "Parameter 'period' using value:" << m_period;
98 }
99 else
100 {
101 yCError(MultipleAnalogSensorsServerParamsCOMPONENT) << "Mandatory parameter 'period' not found!";
102 yCError(MultipleAnalogSensorsServerParamsCOMPONENT) << "Description of the parameter: Refresh period of the broadcasted values in ms";
103 yCError(MultipleAnalogSensorsServerParamsCOMPONENT) << "Remember: Units for this parameter are: 'ms'";
104 return false;
105 }
106 prop_check.unput("period");
107 }
108
109 /*
110 //This code check if the user set some parameter which are not check by the parser
111 //If the parser is set in strict mode, this will generate an error
112 if (prop_check.size() > 0)
113 {
114 bool extra_params_found = false;
115 for (auto it=prop_check.begin(); it!=prop_check.end(); it++)
116 {
117 if (m_parser_is_strict)
118 {
119 yCError(MultipleAnalogSensorsServerParamsCOMPONENT) << "User asking for parameter: "<<it->name <<" which is unknown to this parser!";
120 extra_params_found = true;
121 }
122 else
123 {
124 yCWarning(MultipleAnalogSensorsServerParamsCOMPONENT) << "User asking for parameter: "<< it->name <<" which is unknown to this parser!";
125 }
126 }
127
128 if (m_parser_is_strict && extra_params_found)
129 {
130 return false;
131 }
132 }
133 */
134 return true;
135}
136
137
139{
140 std::string doc;
141 doc = doc + std::string("\n=============================================\n");
142 doc = doc + std::string("This is the help for device: MultipleAnalogSensorsServer\n");
143 doc = doc + std::string("\n");
144 doc = doc + std::string("This is the list of the parameters accepted by the device:\n");
145 doc = doc + std::string("'name': Prefix of the port opened by this device\n");
146 doc = doc + std::string("'period': Refresh period of the broadcasted values in ms\n");
147 doc = doc + std::string("\n");
148 doc = doc + std::string("Here are some examples of invocation command with yarpdev, with all params:\n");
149 doc = doc + " yarpdev --device multipleanalogsensorsserver --name <mandatory_value> --period <mandatory_value>\n";
150 doc = doc + std::string("Using only mandatory params:\n");
151 doc = doc + " yarpdev --device multipleanalogsensorsserver --name <mandatory_value> --period <mandatory_value>\n";
152 doc = doc + std::string("=============================================\n\n"); return doc;
153}
#define yError(...)
Definition Log.h:361
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
bool getParamValue(const std::string &paramName, std::string &paramValue) const override
Return the value (represented as a string) of the requested parameter.
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.
A class for storing options and configuration information.
Definition Property.h:33
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.
#define yCInfo(component,...)
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)