YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
DeviceTemplate_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 (1.0)
8//
9// This is an automatically generated file. Please do not edit it.
10// It will be re-generated if the cmake flag ALLOW_DEVICE_PARAM_PARSER_GERNERATION is ON.
11
12// Generated on: Thu Jan 25 14:38:34 2024
13
14
16#include <yarp/os/LogStream.h>
17#include <yarp/os/Value.h>
18
19namespace {
20 YARP_LOG_COMPONENT(DeviceTemplateParamsCOMPONENT, "yarp.device.DeviceTemplate")
21}
22
23
24std::vector<std::string> DeviceTemplate_ParamsParser::getListOfParams() const
25{
26 std::vector<std::string> params;
27 params.push_back("dummy_group::dummy_param1");
28 params.push_back("dummy_param2");
29 return params;
30}
31
32
34{
35 std::string config_string = config.toString();
36 yarp::os::Property prop_check(config_string.c_str());
37 //Parser of parameter dummy_group::dummy_param1
38 {
39 yarp::os::Bottle sectionp;
40 sectionp = config.findGroup("dummy_group");
41 if (sectionp.check("dummy_param1"))
42 {
43 m_dummy_group_dummy_param1 = sectionp.find("dummy_param1").asString();
44 yCInfo(DeviceTemplateParamsCOMPONENT) << "Parameter 'dummy_group::dummy_param1' using value:" << m_dummy_group_dummy_param1;
45 }
46 else
47 {
48 yCError(DeviceTemplateParamsCOMPONENT) << "Mandatory parameter 'dummy_group::dummy_param1' not found!";
49 yCError(DeviceTemplateParamsCOMPONENT) << "Description of the parameter: This is the description of dummy_param1";
50 return false;
51 }
52 prop_check.unput("dummy_group::dummy_param1");
53 }
54
55 //Parser of parameter dummy_param2
56 {
57 if (config.check("dummy_param2"))
58 {
59 m_dummy_param2 = config.find("dummy_param2").asFloat64();
60 yCInfo(DeviceTemplateParamsCOMPONENT) << "Parameter 'dummy_param2' using value:" << m_dummy_param2;
61 }
62 else
63 {
64 yCInfo(DeviceTemplateParamsCOMPONENT) << "Parameter 'dummy_param2' using DEFAULT value:" << m_dummy_param2;
65 }
66 prop_check.unput("dummy_param2");
67 }
68
69 /*
70 //This code check if the user set some parameter which are not check by the parser
71 //If the parser is set in strict mode, this will generate an error
72 if (prop_check.size() > 0)
73 {
74 bool extra_params_found = false;
75 for (auto it=prop_check.begin(); it!=prop_check.end(); it++)
76 {
77 if (m_parser_is_strict)
78 {
79 yCError(DeviceTemplateParamsCOMPONENT) << "User asking for parameter: "<<it->name <<" which is unknown to this parser!";
80 extra_params_found = true;
81 }
82 else
83 {
84 yCWarning(DeviceTemplateParamsCOMPONENT) << "User asking for parameter: "<< it->name <<" which is unknown to this parser!";
85 }
86 }
87
88 if (m_parser_is_strict && extra_params_found)
89 {
90 return false;
91 }
92 }
93 */
94 return true;
95}
96
97
99{
100 std::string doc;
101 doc = doc + std::string("'dummy_group::dummy_param1': This is the description of dummy_param1\n");
102 doc = doc + std::string("'dummy_param2': This is the description of dummy_param2\n");
103 doc = doc + std::string("\n");
104 doc = doc + std::string("Here are some examples of invocation command with yarpdev, with all params:\n");
105 doc = doc + " yarpdev --device DeviceTemplate --dummy_group::dummy_param1 dummy_default_value --dummy_param2 9.81\n";
106 doc = doc + std::string("Using only mandatory params:\n");
107 doc = doc + " yarpdev --device DeviceTemplate --dummy_group::dummy_param1 dummy_default_value\n";
108 doc = doc + std::string("\n");
109 return doc;
110}
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
std::vector< std::string > getListOfParams() const override
Return a list of all params used by the device.
std::string getDocumentationOfDeviceParams() const override
Get the documentation of the DeviceDriver's parameters.
A simple collection of objects that can be described and transmitted in a portable way.
Definition Bottle.h:64
bool check(const std::string &key) const override
Check if there exists a property of the given name.
Definition Bottle.cpp:277
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
Definition Bottle.cpp:287
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.
virtual Bottle & findGroup(const std::string &key) const =0
Gets a list corresponding to a given keyword.
virtual std::string asString() const
Get string value.
Definition Value.cpp:234
#define yCInfo(component,...)
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)