14#include "arcane/core/CaseOptionEnum.h"
16#include "arcane/utils/Array.h"
17#include "arcane/utils/ITraceMng.h"
19#include "arcane/core/ICaseFunction.h"
20#include "arcane/core/ICaseMng.h"
21#include "arcane/core/ICaseDocument.h"
22#include "arcane/core/StringDictionary.h"
23#include "arcane/core/CaseOptionError.h"
24#include "arcane/core/ICaseDocumentVisitor.h"
95CaseOptionEnumValue(
const String& name,
int value)
102CaseOptionEnumValue(
const CaseOptionEnumValue& rhs)
104, m_value(rhs.m_value)
109~CaseOptionEnumValue()
168 const String& n = ev->name(lang);
185 if (ev->value() == value) {
200 names.
add(ev->name(lang));
213, m_type_name(type_name)
224 delete m_enum_values;
231_search(
bool is_phase1)
233 CaseOptionSimple::_search(is_phase1);
236 bool is_default = _element().null();
237 String str_val = (is_default) ?
_defaultValue() : _element().value();
238 bool has_valid_value =
true;
239 if (str_val.null()) {
247 has_valid_value =
false;
249 _setHasValidValue(has_valid_value);
251 if (has_valid_value) {
258 bool is_bad = m_enum_values->valueOfName(str_val, lang, value);
262 m_enum_values->getValidNames(lang, valid_values);
277_setEnumDefaultValue(
int def_value)
284 if (_isInitialized())
288 _setDefaultValue(m_enum_values->nameOfValue(def_value, String()));
297 _checkIsInitialized();
299 o <<
"'" << m_enum_values->nameOfValue(v, lang) <<
"' (" << v <<
")";
308 visitor->applyVisitor(
this);
315_updateFromFunction(
Real current_time,
Integer current_iteration)
317 _checkIsInitialized();
325 new_str = _convertFunctionRealToString(func, current_time);
328 new_str = _convertFunctionIntegerToString(func, current_iteration);
334 bool is_bad = m_enum_values->
valueOfName(new_str, lang, new_value);
343 msg->
debug() <<
"New value for enum option <" <<
name() <<
"> " << new_value;
344 bool has_changed = new_value != current_value;
345 _setChangedSinceLastIteration(has_changed);
359, m_type_name(type_name)
368~CaseOptionMultiEnum()
370 delete m_enum_values;
376void CaseOptionMultiEnum::
377_search(
bool is_phase1)
381 Integer size = elem_list.size();
382 _checkMinMaxOccurs(size);
391 for (
Integer index = 0; index < size; ++index) {
392 XmlNode velem = elem_list[index];
394 String str_val = (velem.null()) ?
_defaultValue() : velem.value();
395 if (str_val.null()) {
396 CaseOptionError::addOptionNotFoundError(caseDocumentFragment(), A_FUNCINFO,
397 name(), rootElement());
403 bool is_bad = m_enum_values->valueOfName(str_val, lang, value);
407 m_enum_values->getValidNames(lang, valid_values);
427 o <<
"'" << m_enum_values->nameOfValue(v, lang) <<
"' (" << v <<
")";
437 visitor->applyVisitor(
this);
void add(ConstReferenceType val)
Adds element val to the end of the array.
Base class for a data set option.
String name() const
Returns the option name corresponding to the data set language.
String _defaultValue() const
Returns the default value of the option or 0 if none exists.
ICaseMng * caseMng() const
Case manager.
ICaseDocumentFragment * caseDocumentFragment() const
Returns the document associated with this option.
XmlNode rootElement() const
Returns the root element of the DOM.
Information for building a dataset option.
Name and value of a data set enumeration.
Set of values for an enumeration.
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.
~CaseOptionEnumValues()
Releases resources.
EnumValueList * m_enum_values
Enumeration values.
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 int _optionValue() const =0
Returns the option value.
String m_type_name
Enumeration name.
virtual void visit(ICaseDocumentVisitor *visitor) const
Applies the visitor to this option.
static void addInvalidTypeError(ICaseDocumentFragment *document, const TraceInfo &where, const String &node_name, const XmlNode &parent, const String &value, const String &expected_type)
Error when a dataset value is not of the correct type. This error is collective.
static void addOptionNotFoundError(ICaseDocumentFragment *document, const TraceInfo &where, const String &node_name, const XmlNode &parent)
Error when a dataset option is not found. This error is collective.
virtual void visit(ICaseDocumentVisitor *visitor) const
Applies the visitor to this option.
virtual Integer _nbElem() const =0
Returns the number of elements in the array.
String m_type_name
Enumeration name.
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 int _optionValue(Integer index) const =0
Returns the enumeration value for index index.
virtual void _setOptionValue(Integer index, int v)=0
Name of a data set option. This class allows storing the name of an option in multiple languages.
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...
virtual ~CaseOptionName()
Releases resources.
CaseOptionName(const String &true_name)
Constructs a name option true_name.
StringDictionary * m_translations
Translations.
String m_true_name
Option name.
void addAlternativeNodeName(const String &lang, const String &tname)
Adds a translation for the option name. Adds the name tname corresponding to the language lang....
Base class for simple options (single value).
ICaseFunction * function() const override
Function associated with this option (0 if none).
bool isOptional() const
Indicates if the option is optional.
bool isPresent() const
Returns true if the option is present.
virtual String language() const =0
Language used in the dataset.
Visitor interface for a dataset option.
Interface of a dataset function.
@ ParamUnknown
Unknown parameter type.
@ ParamReal
Real type parameter.
@ ParamInteger
Integer type parameter.
virtual eParamType paramType() const =0
Function parameter type.
virtual ITraceMng * traceMng()=0
Trace manager.
virtual TraceMessageDbg debug(Trace::eDebugLevel=Trace::Medium)=0
Stream for a debug message.
Unicode string dictionary.
Unicode character string.
bool null() const
Returns true if the string is null.
XmlNodeList children(const String &name) const
Set of child nodes of this node having the name name.
-- 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.
UniqueArray< String > StringUniqueArray
Dynamic 1D array of strings.