-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvalue_manager.cpp
More file actions
38 lines (36 loc) · 1.28 KB
/
Copy pathvalue_manager.cpp
File metadata and controls
38 lines (36 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright 2024 Simon Sagmeister
#include <iostream>
#include "param_management_cpp/param_value_manager.hpp"
class SoftwareModule
{
private:
tam::pmg::ParamValueManager::SharedPtr param_manager =
std::make_shared<tam::pmg::ParamValueManager>();
void declare_parameters() const
{
// Declare the parameters
param_manager->declare_parameter("a", 1.0, tam::pmg::ParameterType::DOUBLE, "Description of a");
param_manager->declare_parameter("b", 2.0, tam::pmg::ParameterType::DOUBLE, "Description of b");
param_manager->declare_parameter("c", 3.0, tam::pmg::ParameterType::DOUBLE, "Description of c");
}
public:
SoftwareModule()
{
// Declare the parameters here and initialize the values in the struct
declare_parameters();
}
double step() const
{
// Be careful, getting a parameter directly from the manager each time is
// comparably inefficient. It is better to get the value once and store it in a local variable.
// For this, see the example "value_manager_struct.cpp"
return param_manager->get_value("a").as_double() * param_manager->get_value("b").as_double() *
param_manager->get_value("c").as_double();
}
};
int main()
{
auto module = SoftwareModule();
std::cout << "Result: " << module.step() << std::endl;
return 0;
}