-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathreference_manager.cpp
More file actions
40 lines (38 loc) · 1.32 KB
/
Copy pathreference_manager.cpp
File metadata and controls
40 lines (38 loc) · 1.32 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
39
40
// Copyright 2024 Simon Sagmeister
#include <iostream>
#include "param_management_cpp/param_reference_manager.hpp"
struct ModuleParameters
{
double a, b, c;
};
class SoftwareModule
{
private:
ModuleParameters params; // Use a struct for caching and simpler access due to autocompletion
tam::pmg::ParamReferenceManager::SharedPtr param_manager =
std::make_shared<tam::pmg::ParamReferenceManager>();
void declare_parameters()
{
// Declare the parameters.
// The reference manager automatically keeps the values inside the struct up to date.
// Do not write manually to the param struct!
// clang-format off
param_manager->declare_parameter("a", ¶ms.a ,1.0, tam::pmg::ParameterType::DOUBLE, "Description of a"); // NOLINT
param_manager->declare_parameter("b", ¶ms.b ,2.0, tam::pmg::ParameterType::DOUBLE, "Description of b"); // NOLINT
param_manager->declare_parameter("c", ¶ms.c ,3.0, tam::pmg::ParameterType::DOUBLE, "Description of c"); // NOLINT
// clang-format on
}
public:
SoftwareModule()
{
// Declare the parameters here and initialize the values in the struct
declare_parameters();
}
double step() const { return params.a * params.b * params.c; }
};
int main()
{
auto module = SoftwareModule();
std::cout << "Result: " << module.step() << std::endl;
return 0;
}