9#ifndef CAMCOM_COMMON_PARAMETER_HPP
10#define CAMCOM_COMMON_PARAMETER_HPP
20#include "ifw/fnd/defs/base.hpp"
31 template<
typename T>
Parameter(
const std::string& name,
const T& value) {
34 if constexpr (std::is_same_v<T, int16_t>) {
35 m_type = DataType::INT16;
37 else if constexpr (std::is_same_v<T, int32_t>) {
38 m_type = DataType::INT32;
40 else if constexpr (std::is_same_v<T, int64_t>) {
41 m_type = DataType::INT64;
43 else if constexpr (std::is_same_v<T, uint16_t>) {
44 m_type = DataType::UINT16;
46 else if constexpr (std::is_same_v<T, uint32_t>) {
47 m_type = DataType::UINT32;
49 else if constexpr (std::is_same_v<T, uint64_t>) {
50 m_type = DataType::UINT64;
52 else if constexpr (std::is_same_v<T, float>) {
53 m_type = DataType::FLOAT;
55 else if constexpr (std::is_same_v<T, double_t>) {
56 m_type = DataType::DOUBLE;
58 else if constexpr (std::is_same_v<T, bool>) {
59 m_type = DataType::BOOL;
61 else if constexpr (std::is_same_v<T, char>) {
62 m_type = DataType::CHAR;
64 else if constexpr (std::is_same_v<T, std::string>) {
65 m_type = DataType::STRING;
67 else if constexpr (std::is_same_v<T, std::byte>) {
68 m_type = DataType::BYTE;
72 const std::string
GetName()
const;
73 void SetName(
const std::string& name) { m_name = name; }
77 template <
typename T>
const T
GetValue()
const {
80 return std::get<T>(m_value);
81 }
catch (std::bad_variant_access&) {
82 FNDTHROW(
"Illegal type: {} encountered - parameter: {}",
typeid(T).name(), m_name);
91 template <
typename T>
void Store(
const std::string& name,
const T& value);
105 DataType m_type{DataType::UNSPECIFIED};
106 std::optional<ParameterMetadata> m_metadata;
113 m_type = DataType::INT32;
118 m_value =
static_cast<int>(value);
119 m_type = DataType::INT32;
125 m_type = DataType::FLOAT;
131 m_type = DataType::DOUBLE;
137 m_type = DataType::STRING;
143 m_type = DataType::STRING;
149 m_type = DataType::BOOL;
const std::string GetName() const
Definition parameter.cpp:30
const T GetValue() const
Definition parameter.hpp:77
const std::string ToString() const
Definition parameter.cpp:73
void Store(const std::string &name, const T &value)
Parameter()
Definition parameter.cpp:26
bool HasMetadata() const
Definition parameter.hpp:96
const std::string GetTypeAsString() const
Definition parameter.cpp:61
void SetMetadata(const ParameterMetadata &metadata)
Definition parameter.hpp:99
Parameter(const std::string &name, const T &value)
Definition parameter.hpp:31
void SetName(const std::string &name)
Definition parameter.hpp:73
Parameter(const std::string &name, const Value &value, const DataType &type)
Definition parameter.cpp:17
const DataType & GetType() const
Definition parameter.cpp:56
const std::string GetValueAsString() const
Definition parameter.cpp:35
const ParameterMetadata & GetMetadata() const
Definition parameter.cpp:82
void SetMetadata(ParameterMetadata &&metadata)
Definition parameter.hpp:100
ParameterMetadata & GetMutableMetadata()
Definition parameter.cpp:91
void Store(const std::string &name, const Value &value, const DataType &type)
Definition parameter.cpp:66
CamCom data type — re-export of the ELT IFW (ifw-fnd) data type.
Definition adapterBase.cpp:18
std::variant< int, float, double, std::string, bool > Value
Definition value.hpp:17
ifw::fnd::datatype::DataType DataType
Definition datatype.hpp:27
Header file for the CamCom Common Library.