29#include <SimoxUtility/algorithm/get_map_keys_values.h>
38 template <
typename AronTypeT,
typename DerivedT,
typename ValueT>
55 "Could not navigate through a non container navigator. The input path was: " +
60 std::vector<VariantPtr>
75 this->
aron->acceptedValues = valueMap;
78 std::map<std::string, int>
81 return this->
aron->acceptedValues;
84 std::vector<std::string>
87 std::vector<std::string> names;
88 for (
const auto& [k, _] : this->
aron->acceptedValues)
95 std::vector<ValueType>
98 std::vector<ValueType> vals;
99 for (
const auto& [_, i] : this->
aron->acceptedValues)
109 for (
const auto& [k, v] : this->
aron->acceptedValues)
117 "Enum could not be resolved. Input was: " +
125 return this->
aron->acceptedValues.at(s);
131 return this->
aron->enumName;
137 this->
aron->enumName = s;
143 this->
aron->acceptedValues[s] = i;
149 return this->
aron->defaultValue;
156 this->aron->acceptedValues.end(),
157 this->aron->defaultValue) != this->aron->acceptedValues.end())
158 <<
"An aron enum type has an invalid default value set. Got: "
159 << this->
aron->defaultValue
160 <<
"Valid values are: " << ::simox::alg::get_keys(this->
aron->acceptedValues);
161 return this->
aron->acceptedValues.at(this->
aron->defaultValue);
167 for (
const auto& [key, value] : this->
aron->acceptedValues)
171 this->
aron->defaultValue = key;
175 __PRETTY_FUNCTION__,
"Got invalid input for enum value", std::to_string(v));
182 <<
"Trying to set an invalid default value for aron enum type. Got: "
183 << this->
aron->defaultValue;
184 this->
aron->defaultValue = v;
A base class for aron exceptions.
The ValueNotValidException class.
size_t childrenSize() const override
ValueType getDefaultValue() const
void setEnumName(const std::string &s)
std::vector< std::string > getAcceptedValueNames() const
std::map< std::string, int > getAcceptedValueMap() const
std::string getDefaultValueName() const
void setDefaultValue(const ValueType &v)
std::string getValueName(ValueType i) const
SpecializedVariantBase< AronTypeT, DerivedT > Base
SpecializedVariantBase(const type::Descriptor &descriptor, const Path &path)
void setAcceptedValueMap(const std::map< std::string, ValueType > &valueMap)
void addAcceptedValue(const std::string &s, ValueType i)
std::vector< ValueType > getAcceptedValues() const
std::string getEnumName() const
VariantPtr navigateAbsolute(const Path &path) const override
naviate absolute
std::vector< VariantPtr > getChildren() const override
get all child elements
int getValue(const std::string &s) const
void setDefaultValueName(const std::string &v)
virtual ~EnumVariant()=default
AronTypeT::PointerType aron
SpecializedVariantBase(const type::Descriptor &descriptor, const Path &path)
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
std::shared_ptr< Variant > VariantPtr