YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
parameter.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2024-2024 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#include <string>
7#include <vector>
8#include <deque>
9#include <chrono>
10#include <ctime>
11#include <memory>
12
13#include "parameter.h"
14
15const bool enable_debug_prints = false;
16#define ADD_DEBUG_COMMENT(out) if (enable_debug_prints) { out << "/* " << __FUNCTION__ << ":" << __LINE__ << " */\n"; }
17#define S_TAB1 " "
18#define S_TAB2 " "
19#define S_TAB3 " "
20
21void Parameter::setFullyScopedParamName(std::string fullyScopedParamName)
22{
23 this->fullyScopedName = fullyScopedParamName;
24 const std::string delimiter = "::";
25 size_t pos = 0;
26 std::string token;
27
28
29 while ((pos = fullyScopedParamName.find(delimiter)) != std::string::npos) {
30 token = fullyScopedParamName.substr(0, pos);
31 paramGroups.push_back(token);
32 fullyScopedParamName.erase(0, pos + delimiter.length());
33 }
34
35 if (!fullyScopedParamName.empty())
36 {
37 this->paramOnlyName=fullyScopedParamName;
38 }
39}
40
42{
43 if (this->paramGroups.size() == 0)
44 return std::string();
45
46 std::string full_groupname = this->paramGroups[0];
47 for (size_t i = 1; i < this->paramGroups.size(); i++)
48 full_groupname = full_groupname + std::string("::") + this->paramGroups[i];
49
50 return full_groupname;
51}
52
53std::string Parameter::getFullParamName() const
54{
55 if (this->paramGroups.size() == 0)
56 return this->paramOnlyName;
57
58 return getFullGroupOnlyName() + std::string("::") + this->paramOnlyName;
59}
60
61std::string Parameter::getFullGroupOnlyVariable() const
62{
63 if (!optional_variable_name.empty())
65
66 if (this->paramGroups.size() == 0)
67 return std::string();
68
69 std::string full_groupname = this->paramGroups[0];
70 for (size_t i = 1; i < this->paramGroups.size(); i++)
71 full_groupname = full_groupname + std::string("_") + this->paramGroups[i];
72
73 return full_groupname;
74}
75
77{
78 //If the user has requested a special name for that variable, then use it
79 if (!this->optional_variable_name.empty())
80 return this->optional_variable_name;
81
82 //Otherwise generate it from the parameter name
83 if (this->paramGroups.size() == 0)
84 return this->paramOnlyName;
85
86 return getFullGroupOnlyVariable() + std::string("_") + this->paramOnlyName;
87}
88
89std::string Parameter::getParamOnly() const
90{
91 return this->paramOnlyName;
92}
93
94std::deque<std::string> Parameter::getListOfGroups() const
95{
96 return this->paramGroups;
97}
std::string getParamOnly() const
Definition parameter.cpp:89
std::string getFullParamName() const
Definition parameter.cpp:53
std::string optional_variable_name
Definition parameter.h:33
void setFullyScopedParamName(std::string fullyScopedParamName)
Definition parameter.cpp:21
std::string getFullGroupOnlyName() const
Definition parameter.cpp:41
std::string getFullParamVariable() const
Definition parameter.cpp:76
std::deque< std::string > getListOfGroups() const
Definition parameter.cpp:94
const bool enable_debug_prints
Definition parameter.cpp:15