8 #ifndef LLUVIA_CORE_NODE_PARAMETER_H_
9 #define LLUVIA_CORE_NODE_PARAMETER_H_
18 #include <type_traits>
40 void set(const T& value)
43 if constexpr (std::is_integral_v<T>) {
45 m_value.v_int =
static_cast<int32_t
>(value);
46 }
else if constexpr (std::is_floating_point_v<T>) {
48 m_value.v_float =
static_cast<float>(value);
49 }
else if constexpr (std::is_same_v<T, std::string>) {
51 m_value.v_string = std::string {value};
54 static_assert(!std::is_integral_v<T>,
"type T does not match any of the supported types");
62 if constexpr (std::is_integral_v<T> || std::is_floating_point_v<T> || std::is_same_v<T, bool>) {
66 return static_cast<int32_t
>(m_value.v_int);
68 return static_cast<float>(m_value.v_float);
71 "String parameter type not supported when casting to integral or floating point types");
73 }
else if constexpr (std::is_same_v<T, std::string>) {
76 return m_value.v_string;
79 "String parameter type not supported when casting to integral or floating point types");
84 static_assert(!std::is_integral_v<T>,
"type T does not match any of the supported types");
Definition: Parameter.h:23
Parameter & operator=(Parameter &&)=default
Parameter & operator=(const Parameter &)=default
int32_t v_int
Definition: Parameter.h:93
const T get() const
Definition: Parameter.h:59
ll::ParameterType getType() const noexcept
float v_float
Definition: Parameter.h:94
Parameter(ParameterType type)
Parameter(Parameter &&)=default
void set(const T &value)
Definition: Parameter.h:40
Parameter(const Parameter &)=default
std::string v_string
Definition: Parameter.h:98
error related classes and methods.
ParameterType
Definition: ParameterType.h:15
std::error_code createErrorCode(ll::ErrorCode errorCode)
Creates an error code.
Definition: error.h:138