12#ifndef ARCANE_CASEOPTIONENUM_H
13#define ARCANE_CASEOPTIONENUM_H
17#include "arcane/core/CaseOptionSimple.h"
61 void addAlternativeNodeName(
const String& lang,
const String& tname);
76class ARCANE_CORE_EXPORT CaseOptionEnumValue
81 CaseOptionEnumValue(
const String&
name,
int value);
83 CaseOptionEnumValue(
const CaseOptionEnumValue& rhs);
84 ~CaseOptionEnumValue();
88 int value()
const {
return m_value; }
162class ARCANE_CORE_EXPORT CaseOptionEnum
163:
public CaseOptionSimple
172 virtual void print(
const String& lang, std::ostream& o)
const;
175 _updateFromFunction(current_time, current_iteration);
180 m_enum_values->addEnumValue(value, do_clone);
182 CaseOptionEnumValues* enumValues()
const {
return m_enum_values; }
184 virtual void visit(ICaseDocumentVisitor* visitor)
const;
186 int enumValueAsInt()
const {
return _optionValue(); }
191 virtual void _search(
bool is_phase1);
192 virtual bool _allowPhysicalUnit() {
return false; }
201 void _setEnumDefaultValue(
int def_value);
207 void _updateFromFunction(
Real current_time,
Integer current_iteration);
219template <
class EnumType>
221:
public CaseOptionEnum
226 : CaseOptionEnum(cob, type_name)
227 , m_value(EnumType())
235 ARCANE_CASEOPTION_CHECK_IS_INITIALIZED;
240 operator EnumType()
const {
return value(); }
253 _setEnumDefaultValue(
static_cast<int>(def_value));
259 ARCANE_CASEOPTION_CHECK_IS_INITIALIZED;
260 return isPresent() ? m_value : arg_value;
272 m_value =
static_cast<EnumType
>(i);
276 return static_cast<int>(m_value);
287class ARCANE_CORE_EXPORT CaseOptionMultiEnum
288:
public CaseOptionBase
294 ~CaseOptionMultiEnum();
298 virtual void print(
const String& lang, std::ostream& o)
const;
304 m_enum_values->addEnumValue(value, do_clone);
307 CaseOptionEnumValues* enumValues()
const {
return m_enum_values; }
309 virtual void visit(ICaseDocumentVisitor* visitor)
const;
313 virtual void _search(
bool is_phase1);
314 virtual bool _allowPhysicalUnit() {
return false; }
341class CaseOptionMultiEnumT
342:
public CaseOptionMultiEnum
352 : CaseOptionMultiEnum(cob, type_name)
359 m_values.resize(
size);
361 *view = m_values.view();
369 (*this)[index] =
static_cast<T
>(v);
373 return static_cast<int>((*this)[index]);
constexpr ArrayView() noexcept
Constructs an empty view.
constexpr Integer size() const noexcept
Returns the size of the array.
EnumType value() const
Option value.
EnumType operator()() const
Option value.
void setDefaultValue(EnumType def_value)
Sets the default value of the option.
virtual void _setOptionValue(int i)
Sets the option value to v.
EnumType valueIfPresentOrArgument(EnumType arg_value)
Returns the option value if isPresent()==true, otherwise arg_value.
virtual int _optionValue() const
Returns the option value.
String nameOfValue(int value, const String &lang) const
Returns the name corresponding to the value value for the language lang.
CaseOptionEnumValues()
Constructs the instance.
UniqueArray< CaseOptionEnumValue * > EnumValueList
Type of the value list.
void getValidNames(const String &lang, StringArray &names) const
Fills names with valid names for the language lang.
bool valueOfName(const String &name, const String &lang, int &value) const
Returns the value of the enumeration having the name name.
Integer nbEnumValue() const
Returns the number of enumeration values.
CaseOptionEnumValue * enumValue(Integer index) const
Returns the i-th value.
void addEnumValue(CaseOptionEnumValue *value, bool do_clone)
Adds the enumeration value value. The instance becomes the owner of value, which is destroyed when it...
virtual void print(const String &lang, std::ostream &o) const
Prints the option value in the language lang, to the stream o.
virtual void _setOptionValue(int v)=0
Sets the option value to v.
virtual void updateFromFunction(Real current_time, Integer current_iteration)
Updates the option value from a function.
virtual int _optionValue() const =0
Returns the option value.
virtual void _setOptionValue(Integer index, int v)
virtual Integer _nbElem() const
Returns the number of elements in the array.
virtual int _optionValue(Integer index) const
Returns the enumeration value for index index.
virtual void _allocate(Integer size)
Allocates an array for size elements.
virtual Integer _nbElem() const =0
Returns the number of elements in the array.
virtual void print(const String &lang, std::ostream &o) const
Prints the option value in the language lang, to the stream o.
virtual void _allocate(Integer size)=0
Allocates an array for size elements.
virtual ICaseFunction * function() const
Returns the function linked to this option or nullptr if none exists.
virtual void updateFromFunction(Real, Integer)
Updates the option value from a function.
virtual int _optionValue(Integer index) const =0
Returns the enumeration value for index index.
virtual void _setOptionValue(Integer index, int v)=0
String name(const String &lang) const
returns the name of the option in the language lang. If no translation is available in the language l...
CaseOptionName(const String &true_name)
Constructs a name option true_name.
String trueName() const
Returns the true name (non-translated) of the option.
bool isPresent() const
Returns true if the option is present.
Unicode character string.
1D data vector with value semantics (STL style).
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Array< String > StringArray
Dynamic one-dimensional array of strings.
Int32 Integer
Type representing an integer.
double Real
Type representing a real number.