Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
AxlOptionsBuilder.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/* AxlOptionsBuilder.h (C) 2000-2023 */
9/* */
10/* Classes for dynamically creating data set options. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_AXLOPTIONSBUILDER_H
13#define ARCANE_CORE_AXLOPTIONSBUILDER_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/String.h"
18
20
21#include <memory>
22
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
26namespace Arcane::AxlOptionsBuilder
27{
28class OneOption;
29class OneOptionImpl;
32
33/*---------------------------------------------------------------------------*/
34/*---------------------------------------------------------------------------*/
35
39class ARCANE_CORE_EXPORT OptionList
40{
41 friend OneOption;
42 friend OneOptionImpl;
43 friend DocumentXmlWriter;
44 friend DocumentJSONWriter;
45
46 public:
47
49 OptionList();
51 explicit OptionList(const std::initializer_list<OneOption>& options);
52
53 public:
54
55 OptionList& add(const String& name, const OptionList& option);
56 OptionList& add(const OneOption& opt);
57 OptionList& add(const std::initializer_list<OneOption>& options);
58
59 public:
60
61 OptionList clone() const;
62
63 private:
64
65 std::shared_ptr<OneOptionImpl> m_p;
66};
67
68/*---------------------------------------------------------------------------*/
69/*---------------------------------------------------------------------------*/
70
74class ARCANE_CORE_EXPORT OneOption
75{
76 friend class OptionList;
77 friend class OneOptionImpl;
78 friend DocumentXmlWriter;
79 friend DocumentJSONWriter;
80
81 protected:
82
83 enum class Type
84 {
85 CO_Simple,
86 CO_Enumeration,
87 CO_Extended,
88 CO_Complex,
89 CO_ServiceInstance
90 };
91
92 public:
93
94 OneOption() = default;
95
96 protected:
97
98 OneOption(Type type, const String& name, const String& value)
99 : m_type(type)
100 , m_name(name)
101 , m_value(value)
102 {}
103 OneOption(Type type, const String& name, const OptionList& option);
104
105 protected:
106
107 Type m_type = Type::CO_Simple;
108 String m_name;
111 String m_function_name; //<! Function name (ICaseFunction)
112 std::shared_ptr<OneOptionImpl> m_sub_option;
113};
114
115/*---------------------------------------------------------------------------*/
116/*---------------------------------------------------------------------------*/
117
121class ARCANE_CORE_EXPORT Simple
122: public OneOption
123{
124 public:
125
126 Simple(const String& name, Int32 value)
127 : OneOption(Type::CO_Simple, name, String::fromNumber(value))
128 {}
129
130 Simple(const String& name, Int64 value)
131 : OneOption(Type::CO_Simple, name, String::fromNumber(value))
132 {
133 }
134
135 Simple(const String& name, Real value)
136 : OneOption(Type::CO_Simple, name, String::fromNumber(value))
137 {
138 }
139
140 Simple(const String& name, const String& value)
141 : OneOption(Type::CO_Simple, name, value)
142 {
143 }
144
145 public:
146
147 Simple& addFunction(const String& func_name)
148 {
149 m_function_name = func_name;
150 return (*this);
151 }
152};
153
154/*---------------------------------------------------------------------------*/
155/*---------------------------------------------------------------------------*/
156
160class ARCANE_CORE_EXPORT Enumeration
161: public OneOption
162{
163 public:
164
165 Enumeration(const String& name, const String& value)
166 : OneOption(Type::CO_Enumeration, name, value)
167 {
168 }
169};
170
171/*---------------------------------------------------------------------------*/
172/*---------------------------------------------------------------------------*/
173
177class ARCANE_CORE_EXPORT Extended
178: public OneOption
179{
180 public:
181
182 Extended(const String& name, const String& value)
183 : OneOption(Type::CO_Extended, name, value)
184 {
185 }
186};
187
188/*---------------------------------------------------------------------------*/
189/*---------------------------------------------------------------------------*/
190
194class ARCANE_CORE_EXPORT Complex
195: public OneOption
196{
197 public:
198
199 Complex(const String& name, const std::initializer_list<OneOption>& options);
200 Complex(const String& name, const OptionList& option);
201};
202
203/*---------------------------------------------------------------------------*/
204/*---------------------------------------------------------------------------*/
205
209class ARCANE_CORE_EXPORT ServiceInstance
210: public OneOption
211{
212 public:
213
214 ServiceInstance(const String& option_name, const String& service_name,
215 const std::initializer_list<OneOption>& options);
216 ServiceInstance(const String& option_name, const String& service_name,
217 const OptionList& options);
218 ServiceInstance(const String& option_name, const String& service_name);
219};
220
221/*---------------------------------------------------------------------------*/
222/*---------------------------------------------------------------------------*/
223
227class ARCANE_CORE_EXPORT Document
228{
229 friend DocumentXmlWriter;
230 friend DocumentJSONWriter;
231
232 public:
233
234 Document(const String& lang, const OptionList& options)
235 : m_language(lang)
236 , m_options(options)
237 {}
238
239 public:
240
241 const String& language() const { return m_language; }
242
243 private:
244
245 String m_language;
246 OptionList m_options;
247};
248
249/*---------------------------------------------------------------------------*/
250/*---------------------------------------------------------------------------*/
251
252} // namespace Arcane::AxlOptionsBuilder
253
254/*---------------------------------------------------------------------------*/
255/*---------------------------------------------------------------------------*/
256
257#endif
Declarations of Arcane's general types.
Base class for a dynamic option.
String m_service_name
Option value (if CO_Simple option).
OptionList()
Constructs an empty set of options.
GenericDocument< UTF8<> > Document
GenericDocument with UTF8 encoding.
Definition document.h:2891
std::int64_t Int64
Signed integer type of 64 bits.
double Real
Type representing a real number.
std::int32_t Int32
Signed integer type of 32 bits.