Control Libraries 7.4.0
Loading...
Searching...
No Matches
ParameterType.hpp
1#pragma once
2
3#include <map>
4#include <stdexcept>
5
6namespace state_representation {
7
12enum class ParameterType {
13 BOOL,
14 BOOL_ARRAY,
15 INT,
16 INT_ARRAY,
17 DOUBLE,
18 DOUBLE_ARRAY,
19 STRING,
20 STRING_ARRAY,
21 STATE,
22 VECTOR,
23 MATRIX
24};
25
26static const std::map<std::string, ParameterType> parameter_type_map = {
27 {"Bool", ParameterType::BOOL}, {"BoolArray", ParameterType::BOOL_ARRAY},
28 {"Int", ParameterType::INT}, {"IntArray", ParameterType::INT_ARRAY},
29 {"Double", ParameterType::DOUBLE}, {"DoubleArray", ParameterType::DOUBLE_ARRAY},
30 {"String", ParameterType::STRING}, {"StringArray", ParameterType::STRING_ARRAY},
31 {"State", ParameterType::STATE}, {"Vector", ParameterType::VECTOR},
32 {"Matrix", ParameterType::MATRIX}};
33
38[[maybe_unused]] static const std::map<std::string, ParameterType>& get_parameter_type_map() {
39 return parameter_type_map;
40}
41
48[[maybe_unused]] static ParameterType parameter_type_from_name(const std::string& name) {
49 try {
50 return parameter_type_map.at(name);
51 } catch (...) {
52 throw std::out_of_range("The \"" + name + "\" ParameterType does not exist.");
53 }
54}
55
62[[maybe_unused]] static std::string get_parameter_type_name(const ParameterType& parameter_type) {
63 switch (parameter_type) {
64 case ParameterType::BOOL:
65 return "Bool";
66 case ParameterType::BOOL_ARRAY:
67 return "BoolArray";
68 case ParameterType::INT:
69 return "Int";
70 case ParameterType::INT_ARRAY:
71 return "IntArray";
72 case ParameterType::DOUBLE:
73 return "Double";
74 case ParameterType::DOUBLE_ARRAY:
75 return "DoubleArray";
76 case ParameterType::STRING:
77 return "String";
78 case ParameterType::STRING_ARRAY:
79 return "StringArray";
80 case ParameterType::STATE:
81 return "State";
82 case ParameterType::VECTOR:
83 return "Vector";
84 case ParameterType::MATRIX:
85 return "Matrix";
86 default:
87 throw std::out_of_range("This ParameterType does not exist.");
88 }
89}
90
91}// namespace state_representation
Core state variables and objects.
ParameterType
The parameter value types.