Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
CaseOptions.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* CaseOptions.h (C) 2000-2025 */
9/* */
10/* Data set options. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CASEOPTIONS_H
13#define ARCANE_CASEOPTIONS_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
18
19#include "arcane/utils/Array.h"
20#include "arcane/utils/String.h"
21#include "arcane/utils/Ref.h"
22
23#include "arcane/core/XmlNode.h"
24#include "arcane/core/ICaseOptions.h"
25#include "arcane/core/ICaseOptionList.h"
26
27// These files are not necessary for this '.h' but are included
28// because axlstar only includes 'CaseOptions.h'
29#include "arcane/core/CaseOptionSimple.h"
30#include "arcane/core/CaseOptionEnum.h"
31#include "arcane/core/CaseOptionExtended.h"
32#include "arcane/core/CaseOptionComplexValue.h"
33
34/*---------------------------------------------------------------------------*/
35/*---------------------------------------------------------------------------*/
36
37namespace Arcane
38{
39namespace AxlOptionsBuilder
40{
41 class Document;
42}
43
44/*---------------------------------------------------------------------------*/
45/*---------------------------------------------------------------------------*/
46
47/*!
48 * \internal
49 * \brief Base class for a data set options list.
50 *
51 * Instances of this class must all be allocated by
52 * the new() operator and must not be destroyed; the case manager
53 * (ICaseMng) handles this.
54 */
55class ARCANE_CORE_EXPORT CaseOptions
57, public ICaseOptions
58{
60
61 private:
62
63 struct XmlContent
64 {
65 String m_xml_content;
66 IXmlDocumentHolder* m_document = nullptr;
67 };
68
69 public:
70
71 //! Constructs an options set.
72 CaseOptions(ICaseMng* cm, const String& name);
73 //! Constructs an options set.
75 //! Constructs an options set.
76 CaseOptions(ICaseMng* cm, const String& name, const XmlNode& parent);
77 //! Constructs an options set.
78 CaseOptions(ICaseOptionList*, const String& name, const XmlNode& parent, bool is_optional = false, bool is_multi = false);
79 //! Constructs an options set.
80
81 protected:
82
84 //! Constructs an options set.
86
87 private:
88
89 friend class ServiceBuilderWithOptionsBase;
90
91 // Only for ServiceBuilderWithOptionsBase
92 static ReferenceCounter<ICaseOptions> createDynamic(ICaseMng* cm, const AxlOptionsBuilder::Document& options_doc);
93
94 //! \internal
95 CaseOptions(ICaseMng*, const XmlContent& xm_content);
96
97 public:
98
99 //! Frees resources
100 ~CaseOptions() override;
101
102 private:
103
104 CaseOptions(const CaseOptions& rhs) = delete;
105 CaseOptions& operator=(const CaseOptions& rhs) = delete;
106
107 public:
108
109 //! Returns the true name (non-translated) of the element.
110 String rootTagTrueName() const override;
111
112 //! Returns the name of the element in the data set language.
113 String rootTagName() const override;
114
115 //! Name in language \a lang of the option. Returns \a rootTagTrueName() if no translation exists.
116 String translatedName(const String& lang) const override;
117
118 //! Returns the true name (non-translated) of the element.
119 virtual String trueName() const { return rootTagTrueName(); }
120
121 //! Returns the name of the element in the data set language.
122 virtual String name() const { return rootTagName(); }
123
124 void read(bool is_phase1) override
125 {
126 auto p = (is_phase1) ? eCaseOptionReadPhase::Phase1 : eCaseOptionReadPhase::Phase2;
127 read(p);
128 }
129
130 void read(eCaseOptionReadPhase phase) override;
131
132 void addInvalidChildren(XmlNodeList&) override;
133
134 void printChildren(const String& lang, int indent) override;
135
136 //! Returns the associated service or 0 if none exists.
137 IServiceInfo* caseServiceInfo() const override;
138
139 //! Returns the associated module or 0 if none exists.
140 IModule* caseModule() const override;
141
142 //! Associates service \a m with this data set.
143 void setCaseServiceInfo(IServiceInfo* m) override;
144
145 //! Associates module \a m with this data set.
146 void setCaseModule(IModule* m) override;
147
148 //! Adds all child options to the list \a col.
149 void deepGetChildren(Array<CaseOptionBase*>& col) override;
150
151 ICaseOptionList* configList() override;
152
153 const ICaseOptionList* configList() const override;
154
155 //! Function indicating the activation status of the option
156 ICaseFunction* activateFunction() override;
157
158 /*!
159 \brief True if the option is present in the file,
160 false if it is the default value.
161 */
162 bool isPresent() const override;
163
164 /*!
165 \brief Adds a translation for the option name.
166 Adds the option name \a name corresponding to language \a lang.
167 If a translation already exists for this language, it is replaced by
168 this one.
169 */
170 void addAlternativeNodeName(const String& lang, const String& name) override;
171
172 ICaseMng* caseMng() const override;
173 ITraceMng* traceMng() const override;
174 ISubDomain* subDomain() const override;
175 IMesh* mesh() const override;
176 MeshHandle meshHandle() const override;
177 ICaseDocument* caseDocument() const override;
178 ICaseDocumentFragment* caseDocumentFragment() const override;
179
180 void detach() override;
181
182 void visit(ICaseDocumentVisitor* visitor) const override;
183
184 String xpathFullName() const override;
185
186 Ref<ICaseOptions> toReference() override;
187
188 protected:
189
190 friend class CaseOptionMultiServiceImpl;
191
192 void _setTranslatedName();
193 bool _setMeshHandleAndCheckDisabled(const String& mesh_name);
194
195 protected:
196
197 CaseOptionsPrivate* m_p; //!< Implementation
198
199 private:
200
201 void _setMeshHandle(const MeshHandle& handle);
202 void _setParent(ICaseOptionList* parent);
203};
204
205/*---------------------------------------------------------------------------*/
206/*---------------------------------------------------------------------------*/
207
208} // End namespace Arcane
209
210/*---------------------------------------------------------------------------*/
211/*---------------------------------------------------------------------------*/
212
213#endif
#define ARCCORE_DEFINE_REFERENCE_COUNTED_INCLASS_METHODS()
Macro to define methods managing counters of references.
Data set 'ServiceInstance' option.
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.
virtual String trueName() const
Returns the true name (non-translated) of the element.
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.
CaseOptionsPrivate * m_p
Implementation.
CaseOptions(ICaseMng *cm, const String &name)
Constructs an options set.
Case manager interface.
Definition ICaseMng.h:57
Manager of a DOM document.
Handle on a mesh.
Definition MeshHandle.h:48
Thread-safe implementation of a reference counter.
Encapsulation of a pointer with a reference counter.
Node of a DOM tree.
Definition XmlNode.h:51
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
eCaseOptionReadPhase
Reading phases.