YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
FrameGrabberCropper_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:47 2025
12
13
15#include <yarp/os/LogStream.h>
16#include <yarp/os/Value.h>
17
18namespace {
19 YARP_LOG_COMPONENT(FrameGrabberCropperParamsCOMPONENT, "yarp.device.FrameGrabberCropper")
20}
21
22
26
27
29{
30 std::vector<std::string> params;
31 params.push_back("x1");
32 params.push_back("y1");
33 params.push_back("x2");
34 params.push_back("y2");
35 params.push_back("forwardRgbVisualParams");
36 return params;
37}
38
39
40bool FrameGrabberCropper_ParamsParser::getParamValue(const std::string& paramName, std::string& paramValue) const
41{
42 if (paramName =="x1")
43 {
44 paramValue = std::to_string(m_x1);
45 return true;
46 }
47 if (paramName =="y1")
48 {
49 paramValue = std::to_string(m_y1);
50 return true;
51 }
52 if (paramName =="x2")
53 {
54 paramValue = std::to_string(m_x2);
55 return true;
56 }
57 if (paramName =="y2")
58 {
59 paramValue = std::to_string(m_y2);
60 return true;
61 }
62 if (paramName =="forwardRgbVisualParams")
63 {
64 if (m_forwardRgbVisualParams==true) paramValue = "true";
65 else paramValue = "false";
66 return true;
67 }
68
69 yError() <<"parameter '" << paramName << "' was not found";
70 return false;
71
72}
73
74
76{
77 //This is a sub-optimal solution.
78 //Ideally getConfiguration() should return all parameters but it is currently
79 //returning only user provided parameters (excluding default values)
80 //This behaviour will be fixed in the near future.
81 std::string s_cfg = m_provided_configuration;
82 return s_cfg;
83}
84
86{
87 //Check for --help option
88 if (config.check("help"))
89 {
90 yCInfo(FrameGrabberCropperParamsCOMPONENT) << getDocumentationOfDeviceParams();
91 }
92
95 //Parser of parameter x1
96 {
97 if (config.check("x1"))
98 {
99 m_x1 = config.find("x1").asInt64();
100 yCInfo(FrameGrabberCropperParamsCOMPONENT) << "Parameter 'x1' using value:" << m_x1;
101 }
102 else
103 {
104 yCError(FrameGrabberCropperParamsCOMPONENT) << "Mandatory parameter 'x1' not found!";
105 yCError(FrameGrabberCropperParamsCOMPONENT) << "Description of the parameter: x1";
106 return false;
107 }
108 prop_check.unput("x1");
109 }
110
111 //Parser of parameter y1
112 {
113 if (config.check("y1"))
114 {
115 m_y1 = config.find("y1").asInt64();
116 yCInfo(FrameGrabberCropperParamsCOMPONENT) << "Parameter 'y1' using value:" << m_y1;
117 }
118 else
119 {
120 yCError(FrameGrabberCropperParamsCOMPONENT) << "Mandatory parameter 'y1' not found!";
121 yCError(FrameGrabberCropperParamsCOMPONENT) << "Description of the parameter: y1";
122 return false;
123 }
124 prop_check.unput("y1");
125 }
126
127 //Parser of parameter x2
128 {
129 if (config.check("x2"))
130 {
131 m_x2 = config.find("x2").asInt64();
132 yCInfo(FrameGrabberCropperParamsCOMPONENT) << "Parameter 'x2' using value:" << m_x2;
133 }
134 else
135 {
136 yCError(FrameGrabberCropperParamsCOMPONENT) << "Mandatory parameter 'x2' not found!";
137 yCError(FrameGrabberCropperParamsCOMPONENT) << "Description of the parameter: x2";
138 return false;
139 }
140 prop_check.unput("x2");
141 }
142
143 //Parser of parameter y2
144 {
145 if (config.check("y2"))
146 {
147 m_y2 = config.find("y2").asInt64();
148 yCInfo(FrameGrabberCropperParamsCOMPONENT) << "Parameter 'y2' using value:" << m_y2;
149 }
150 else
151 {
152 yCError(FrameGrabberCropperParamsCOMPONENT) << "Mandatory parameter 'y2' not found!";
153 yCError(FrameGrabberCropperParamsCOMPONENT) << "Description of the parameter: y2";
154 return false;
155 }
156 prop_check.unput("y2");
157 }
158
159 //Parser of parameter forwardRgbVisualParams
160 {
161 if (config.check("forwardRgbVisualParams"))
162 {
163 m_forwardRgbVisualParams = config.find("forwardRgbVisualParams").asBool();
164 yCInfo(FrameGrabberCropperParamsCOMPONENT) << "Parameter 'forwardRgbVisualParams' using value:" << m_forwardRgbVisualParams;
165 }
166 else
167 {
168 yCInfo(FrameGrabberCropperParamsCOMPONENT) << "Parameter 'forwardRgbVisualParams' using DEFAULT value:" << m_forwardRgbVisualParams;
169 }
170 prop_check.unput("forwardRgbVisualParams");
171 }
172
173 /*
174 //This code check if the user set some parameter which are not check by the parser
175 //If the parser is set in strict mode, this will generate an error
176 if (prop_check.size() > 0)
177 {
178 bool extra_params_found = false;
179 for (auto it=prop_check.begin(); it!=prop_check.end(); it++)
180 {
181 if (m_parser_is_strict)
182 {
183 yCError(FrameGrabberCropperParamsCOMPONENT) << "User asking for parameter: "<<it->name <<" which is unknown to this parser!";
184 extra_params_found = true;
185 }
186 else
187 {
188 yCWarning(FrameGrabberCropperParamsCOMPONENT) << "User asking for parameter: "<< it->name <<" which is unknown to this parser!";
189 }
190 }
191
192 if (m_parser_is_strict && extra_params_found)
193 {
194 return false;
195 }
196 }
197 */
198 return true;
199}
200
201
203{
204 std::string doc;
205 doc = doc + std::string("\n=============================================\n");
206 doc = doc + std::string("This is the help for device: FrameGrabberCropper\n");
207 doc = doc + std::string("\n");
208 doc = doc + std::string("This is the list of the parameters accepted by the device:\n");
209 doc = doc + std::string("'x1': x1\n");
210 doc = doc + std::string("'y1': y1\n");
211 doc = doc + std::string("'x2': x2\n");
212 doc = doc + std::string("'y2': y2\n");
213 doc = doc + std::string("'forwardRgbVisualParams': Forward the the IRgbVisualParams calls to the attached device\n");
214 doc = doc + std::string("\n");
215 doc = doc + std::string("Here are some examples of invocation command with yarpdev, with all params:\n");
216 doc = doc + " yarpdev --device frameGrabberCropper --x1 0 --y1 0 --x2 100 --y2 100 --forwardRgbVisualParams false\n";
217 doc = doc + std::string("Using only mandatory params:\n");
218 doc = doc + " yarpdev --device frameGrabberCropper --x1 0 --y1 0 --x2 100 --y2 100\n";
219 doc = doc + std::string("=============================================\n\n"); return doc;
220}
#define yError(...)
Definition Log.h:361
std::string getDocumentationOfDeviceParams() const override
Get the documentation of the DeviceDriver's parameters.
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.
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 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,...)