22 #ifndef CRNConfigElement_HEADER
23 #define CRNConfigElement_HEADER
71 const SObject&
GetValue() noexcept {
return value; }
80 return Data::Convert<T>(*value);
91 bool HasMinValue() const noexcept {
return minValue.get() !=
nullptr; }
104 return Data::Convert<T>(*minValue);
114 minValue =
Clone(*value);
115 setValue(val, minValue);
118 bool HasMaxValue() const noexcept {
return maxValue.get() !=
nullptr; }
131 return Data::Convert<T>(*maxValue);
141 maxValue =
Clone(*value);
142 setValue(val, maxValue);
154 for (SCObject obj : allowedValues)
156 lst.push_back(Data::Convert<T>(*obj));
166 allowedValues.
Clear();
167 for (Iter tmp = b; tmp != e; ++tmp)
176 setValue(val, allowedValues.
Back());
184 template<
typename T>
static void setValue(T val,
const SObject &value)
186 const String valstring(val);
187 auto i = std::static_pointer_cast<
Int>(value);
190 *i = valstring.ToInt();
193 auto r = std::static_pointer_cast<Real>(value);
196 *r = valstring.ToDouble();
199 auto p = std::static_pointer_cast<Prop3>(value);
202 *p = valstring.ToProp3();
205 auto s = std::static_pointer_cast<String>(value);
211 auto su = std::static_pointer_cast<StringUTF8>(value);
214 *su = valstring.CStr();
217 auto pa = std::static_pointer_cast<Path>(value);
220 *pa = valstring.CStr();
230 Vector allowedValues;
SCObject GetMaxValue() const
Gets the inner representation of the element's max value.
SCObject GetValue() const
Gets the inner representation of the element's value.
const SObject & GetMinValue() noexcept
Gets the inner representation of the element's min value.
T GetMinValue() const
Gets the element's minimal value.
const crn::Vector & GetAllowedValues() const
Returns the list of allowed values.
ConfigElement()
Default constructor for serialization.
Unintialized object error.
SObject & Back()
Returns a reference to the last element.
bool HasMaxValue() const noexcept
Tells if the element has max value.
T GetValue() const
Gets the element's value.
SCObject GetMinValue() const
Gets the inner representation of the element's min value.
const std::vector< T > GetAllowedValues() const
Returns the list of allowed values.
A UTF32 character string class.
void AddAllowedValue(T val)
Adds a value to the list of allowed values.
const SObject & GetMaxValue() noexcept
Gets the inner representation of the element's max value.
ConfigElement & operator=(const ConfigElement &)=delete
A convenience class for file paths.
void Clear() noexcept
Empties the vector.
void SetAllowedValues(Iter b, Iter e)
Sets the list of allowed values.
const String & GetName() const noexcept
Gets the translated name of the element.
void SetMinValue(T val)
Sets the element's min value.
A element of configuration.
String GetType() const
Gets the inner type of data in the element.
const String & GetDescription() const noexcept
Gets the description of the element.
const SObject & GetValue() noexcept
Gets the inner representation of the element's value.
void SetMaxValue(T val)
Sets the element's max value.
void SetValue(T val)
Sets the element's value.
Interface class for the metric real number class.
CRN_ALIAS_SMART_PTR(ImageBW)
A character string class.
void PushBack(const SObject &d)
Adds an object at the end of the vector.
T GetMaxValue() const
Gets the element's minimal value.
UObject Clone(const Object &obj)
Clones an object if possible.
bool HasMinValue() const noexcept
Tells if the element has min value.