14#include "arcane/core/CaseOptions.h"
16#include "arcane/utils/ITraceMng.h"
17#include "arcane/utils/FatalErrorException.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/CaseNodeNames.h"
24#include "arcane/core/CaseOptionError.h"
25#include "arcane/core/ICaseDocumentVisitor.h"
26#include "arcane/core/MeshHandle.h"
27#include "arcane/core/IMeshMng.h"
28#include "arcane/core/IXmlDocumentHolder.h"
29#include "arcane/core/internal/ICaseMngInternal.h"
30#include "arcane/core/internal/ICaseOptionListInternal.h"
32#include "arcane/core/CaseOptionsMulti.h"
43namespace AxlOptionsBuilder
45 extern "C++" IXmlDocumentHolder*
57class CaseOptionsPrivate
70 : m_case_mng(co_list->
caseMng())
75 if (m_mesh_handle.isNull())
76 m_mesh_handle = m_case_mng->meshMng()->defaultMeshHandle();
81 delete m_own_case_document_fragment;
93 bool m_is_multi =
false;
94 bool m_is_translated_name_set =
false;
95 bool m_is_phase1_read =
false;
98 bool m_is_case_mng_registered =
false;
112 m_p->m_config_list = ICaseOptionListInternal::create(cm,
this,
XmlNode());
113 m_p->m_is_case_mng_registered =
true;
124 m_p->m_config_list = ICaseOptionListInternal::create(parent,
this,
XmlNode());
135 m_p->m_config_list = ICaseOptionListInternal::create(cm,
this, parent_elem);
136 m_p->m_is_case_mng_registered =
true;
145 const XmlNode& parent_elem,
bool is_optional,
bool is_multi)
148 ICaseOptionList* col = ICaseOptionListInternal::create(parent,
this, parent_elem, is_optional, is_multi);
149 m_p->m_config_list = col;
152 _setTranslatedName();
162 m_p->m_config_list = config_list;
163 m_p->m_is_case_mng_registered =
true;
175 m_p->m_config_list = config_list;
189 m_p->m_config_list = ICaseOptionListInternal::create(cm,
this, parent_elem);
193 m_p->m_case_mng_ref = cm->toReference();
203 if (
m_p->m_is_case_mng_registered)
204 m_p->m_case_mng->unregisterOptions(
this);
218 m_p->m_parent->removeChild(
this);
219 m_p->m_parent =
nullptr;
220 m_p->m_config_list =
nullptr;
229 return m_p->m_true_name;
247 return m_p->m_config_list->isPresent();
256 return m_p->m_config_list->xpathFullName();
269 if (
m_p->m_is_translated_name_set)
271 m_p->m_name_translations.add(lang,
name);
280 return m_p->m_config_list.get();
286const ICaseOptionList* CaseOptions::
289 return m_p->m_config_list.get();
298 return m_p->m_service_info;
307 return m_p->m_module;
316 m_p->m_service_info = m;
334 return m_p->m_case_mng;
340ITraceMng* CaseOptions::
352 return m_p->m_case_mng->subDomain();
361 return m_p->m_mesh_handle;
370 return meshHandle().
mesh();
379 return caseMng()->caseDocument();
386caseDocumentFragment()
const
388 auto* x =
m_p->m_own_case_document_fragment;
391 return caseMng()->caseDocumentFragment();
400 traceMng()->info(5) <<
"SetMeshHandle for " <<
m_p->m_name <<
" mesh_name=" << handle.meshName();
401 m_p->m_mesh_handle = handle;
410 parent->addChild(
this);
411 m_p->m_parent = parent;
412 _setMeshHandle(parent->meshHandle());
436 if (mesh_name.
empty()) {
439 _setMeshHandle(
m_p->m_parent->meshHandle());
448 m_p->m_config_list->disable();
451 _setMeshHandle(*handle);
463 if (
m_p->m_is_translated_name_set)
464 traceMng()->
info() <<
"WARNING: translated name already set for " <<
m_p->m_name;
466 m_p->m_name =
m_p->m_true_name;
473 m_p->m_is_translated_name_set =
true;
483 String tr =
m_p->m_name_translations.find(lang);
487 return m_p->m_true_name;
496 return m_p->m_activate_function;
506 bool is_phase1 = read_phase == eCaseOptionReadPhase::Phase1;
507 if (is_phase1 &&
m_p->m_is_phase1_read)
510 if (is_phase1 && !
m_p->m_is_translated_name_set)
511 _setTranslatedName();
513 m_p->m_config_list->readChildren(is_phase1);
518 XmlNode velem =
m_p->m_config_list->rootElement();
520 String func_activation_name = velem.
attrValue(cnn->function_activation_ref);
521 if (!func_activation_name.
null()) {
522 ICaseFunction* func = caseMng()->findFunction(func_activation_name);
525 String::format(
"No function with the name '{0}' exists",
526 func_activation_name));
530 String::format(
"The function '{0}' requires a parameter of type 'time'",
531 func_activation_name));
535 String::format(
"The function '{0}' requires a parameter of type 'bool'",
536 func_activation_name));
539 m_p->m_activate_function = func;
540 tm->
info() <<
"Use the function '" << func->
name() <<
"' to activate the option "
547 if (!func_name.
null())
549 String::format(
"Attribute <{0}> invalid.",
552 m_p->m_is_phase1_read =
true;
565 m_p->m_config_list->_internalApi()->addInvalidChildren(nlist);
572printChildren(
const String& lang,
int indent)
574 m_p->m_config_list->printChildren(lang, indent);
583 m_p->m_config_list->visit(visitor);
592 m_p->m_config_list->deepGetChildren(col);
604 content.m_document = xml_doc;
613Ref<ICaseOptions> CaseOptions::
630 min_occurs, max_occurs))
643 parent_element, min_occurs, max_occurs))
656 return opt->subDomain();
Base class for 1D data vectors.
Data set 'ServiceInstance' option.
XML node names of an Arcane dataset.
static void addError(ICaseDocumentFragment *document, const TraceInfo &where, const String &node_name, const String &message, bool is_collective=false)
Generic error.
IModule * m_module
Associated module or 0 if none.
ICaseFunction * m_activate_function
Function indicating activation status.
IServiceInfo * m_service_info
Associated service or 0 if none.
Base class for a data set options list.
String xpathFullName() const override
Full name in XPath format corresponding to rootElement().
void addInvalidChildren(XmlNodeList &) override
Adds unrecognized elements to nlist.
bool isPresent() const override
True if the option is present in the file, false if it is the default value.
bool _setMeshHandleAndCheckDisabled(const String &mesh_name)
Positions the mesh associated with this option.
void setCaseServiceInfo(IServiceInfo *m) override
Associates service m with this data set.
void visit(ICaseDocumentVisitor *visitor) const override
Applies the visitor to this option.
void addAlternativeNodeName(const String &lang, const String &name) override
Adds a translation for the option name. Adds the option name name corresponding to language lang....
String rootTagName() const override
Returns the name of the element in the data set language.
String rootTagTrueName() const override
Returns the true name (non-translated) of the element.
ICaseFunction * activateFunction() override
Function indicating the activation status of the option.
void setCaseModule(IModule *m) override
Associates module m with this data set.
String translatedName(const String &lang) const override
Name in language lang of the option. Returns rootTagTrueName() if no translation exists.
virtual String name() const
Returns the name of the element in the data set language.
~CaseOptions() override
Frees resources.
IServiceInfo * caseServiceInfo() const override
Returns the associated service or 0 if none exists.
IModule * caseModule() const override
Returns the associated module or 0 if none exists.
CaseOptionsPrivate * m_p
Implementation.
ISubDomain * subDomain() const override
Associated sub-domain.
void deepGetChildren(Array< CaseOptionBase * > &col) override
Adds all child options to the list col.
CaseOptions(ICaseMng *cm, const String &name)
Constructs an options set.
Interface of a part of a dataset.
virtual CaseNodeNames * caseNodeNames()=0
Returns the instance containing the names of XML nodes by language.
virtual String language() const =0
Language used in the dataset.
Visitor interface for a dataset option.
Interface of a class managing an XML document of the dataset.
Interface of a dataset function.
@ ParamReal
Real type parameter.
@ ValueBool
Boolean type value.
virtual String name() const =0
function name
virtual eValueType valueType() const =0
Function value type.
virtual eParamType paramType() const =0
Function parameter type.
virtual ICaseDocumentFragment * createDocumentFragment(IXmlDocumentHolder *document)=0
Creates a fragment.
virtual ICaseMngInternal * _internalImpl()=0
Internal implementation.
virtual IMeshMng * meshMng() const =0
Associated mesh manager.
virtual ITraceMng * traceMng()=0
Trace manager.
virtual void registerOptions(ICaseOptions *)=0
Registers a list of dataset options.
Internal API of the data set options list interface.
Interface for a data set options list.
virtual ICaseMng * caseMng() const =0
Returns the case manager.
virtual MeshHandle meshHandle() const =0
Handle of the associated mesh.
Interface for a list of data set options.
virtual MeshHandle * findMeshHandle(const String &name, bool throw_exception)=0
Searches for the mesh with name name.
virtual MeshHandle defaultMeshHandle() const =0
Handle for the default mesh.
Interface for service or module information.
Interface of the subdomain manager.
virtual TraceMessage info()=0
Stream for an information message.
Manager of a DOM document.
virtual XmlNode documentNode()=0
Document node. This node is null if the document does not exist.
IMesh * mesh() const
Associated mesh.
IMeshMng * meshMng() const
Associated mesh manager. nullptr if isNull() is true.
Reference to an instance.
Encapsulation of a pointer with a reference counter.
Unicode string dictionary.
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.
bool empty() const
True if the string is empty (null or "").
List of nodes of a DOM tree.
String xpathFullName() const
XPath name of the node with its ancestors.
String attrValue(const String &name, bool throw_exception=false) const
Value of attribute name.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
eCaseOptionReadPhase
Reading phases.
Int32 Integer
Type representing an integer.
auto makeRef(InstanceType *t) -> Ref< InstanceType >
Creates a reference on a pointer.