14#include "arcane/core/CaseOptionBase.h"
16#include "arcane/utils/FatalErrorException.h"
17#include "arcane/utils/StringBuilder.h"
19#include "arcane/core/CaseOptionBuildInfo.h"
20#include "arcane/core/StringDictionary.h"
21#include "arcane/core/CaseOptions.h"
22#include "arcane/core/ICaseMng.h"
23#include "arcane/core/ICaseDocument.h"
24#include "arcane/core/CaseOptionException.h"
25#include "arcane/core/internal/ICaseOptionListInternal.h"
40class CaseOptionBasePrivate
70CaseOptionBasePrivate::
72: m_case_mng(cob.caseMng())
73, m_parent_option_list(cob.caseOptionList())
74, m_case_document_fragment(m_parent_option_list->caseDocumentFragment())
76, m_true_name(cob.name())
78, m_axl_default_value(cob.defaultValue())
79, m_default_value(m_axl_default_value)
80, m_min_occurs(cob.minOccurs())
81, m_max_occurs(cob.maxOccurs())
82, m_is_optional(cob.isOptional())
83, m_is_initialized(false)
84, m_is_override_default(false)
95CaseOptionBase(
const CaseOptionBuildInfo& cob)
96: m_p(new CaseOptionBasePrivate(cob))
98 cob.caseOptionList()->_internalApi()->addConfig(
this, cob.element());
116 return m_p->m_case_mng;
125 return m_p->m_parent_option_list;
134 return m_p->m_case_mng->traceMng();
143 return m_p->m_case_mng->subDomain();
161 return m_p->m_case_document_fragment;
170 return m_p->m_default_value;
177_setDefaultValue(
const String& def_value)
189 _setCategoryDefaultValue();
190 _setTranslatedName();
200 return m_p->m_true_name;
218 return m_p->m_min_occurs;
227 return m_p->m_max_occurs;
236 return m_p->m_is_optional;
261_setCategoryDefaultValue()
264 if (m_p->m_is_override_default)
268 m_p->m_default_value = m_p->m_axl_default_value;
270 String v = m_p->m_default_values.find(category);
272 m_p->m_default_value = v;
284 String tr = m_p->m_name_translations.find(lang);
297 m_p->m_root_element = root_element;
306 return m_p->m_root_element;
315 m_p->m_name_translations.add(lang,
name);
324 m_p->m_default_values.add(category, value);
340_isInitialized()
const
349_checkIsInitialized()
const
351 if (!_isInitialized()) {
360_checkMinMaxOccurs(
Integer nb_occur)
362 Integer min_occurs = m_p->m_min_occurs;
363 Integer max_occurs = m_p->m_max_occurs;
364 bool is_optional = m_p->m_is_optional;
366 if (nb_occur == 0 && is_optional) {
370 if (nb_occur < min_occurs) {
371 StringBuilder msg =
"Bad number of occurences (less than min)";
374 msg +=
" min_occur=";
377 msg += m_p->m_root_element.xpathFullName();
380 throw CaseOptionException(A_FUNCINFO, msg.toString(),
true);
383 if (nb_occur > max_occurs) {
384 StringBuilder msg =
"Bad number of occurences (greater than max)";
387 msg +=
" max_occur=";
390 msg += m_p->m_root_element.xpathFullName();
393 throw CaseOptionException(A_FUNCINFO, msg.toString(),
true);
401_xpathFullName()
const
403 return m_p->m_root_element.xpathFullName();
#define ARCANE_THROW(exception_class,...)
Macro for throwing an exception with formatting.
bool m_is_override_default
const String m_axl_default_value
Initial default value.
Integer m_min_occurs
Minimum number of occurrences.
String m_name
Translated option name.
ICaseMng * m_case_mng
Sub-domain manager.
XmlNode m_root_element
Option's DOM element.
Integer m_max_occurs
Maximum number of occurrences (-1 == unbounded).
StringDictionary m_default_values
List of default values by category.
bool m_is_initialized
true if initialized
ICaseDocumentFragment * m_case_document_fragment
Associated document.
String m_default_value
Default value.
StringDictionary m_name_translations
List of option names by language.
ICaseOptionList * m_parent_option_list
Parent.
String m_true_name
Option name.
String name() const
Returns the option name corresponding to the data set language.
String translatedName(const String &lang) const
Name of the option in the language lang. Returns name() if no translation exists.
void addDefaultValue(const String &category, const String &value)
Adds the default value value to the category category.
String _defaultValue() const
Returns the default value of the option or 0 if none exists.
ICaseDocument * caseDocument() const
Returns the document manager.
void search(bool is_phase1)
Retrieves the value from the configuration file for the variable.
ICaseMng * caseMng() const
Case manager.
ICaseDocumentFragment * caseDocumentFragment() const
Returns the document associated with this option.
void addAlternativeNodeName(const String &lang, const String &name)
Adds a translation for the option name.
void setRootElement(const XmlNode &root_element)
Positions the root element at root_element.
bool isOptional() const
Allows knowing if an option is optional.
Integer maxOccurs() const
Maximum number of occurrences (for a multiple option) (-1 == unbounded).
XmlNode rootElement() const
Returns the root element of the DOM.
ITraceMng * traceMng() const
Trace manager.
ISubDomain * subDomain() const
Sub-domain manager.
String trueName() const
Returns the true name (untranslated) of the option.
ICaseOptionList * parentOptionList() const
Parent OptionList.
Integer minOccurs() const
Minimum number of occurrences (for a multiple option).
virtual String defaultCategory() const =0
Category used for default values.
virtual String language() const =0
Language used in the dataset.
virtual ICaseDocument * caseDocument()=0
XML document of the dataset (can be null if no dataset).
Interface of the subdomain manager.
String find(const String &key, bool throw_exception=false) const
Returns the value associated with key.
Unicode character string.
bool null() const
Returns true if the string is null.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.