Arcane  4.2.3.0
Developer documentation
Loading...
Searching...
No Matches
ArcaNetReader.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/* ArcaNetReader.h (C) 2000-2026 */
9/* */
10/* Reader for ArcaNet files. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCCORE_COMMON_ARCANETREADER_H
13#define ARCCORE_COMMON_ARCANETREADER_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arccore/base/String.h"
18#include "arccore/base/StringBuilder.h"
19
20#include "arccore/common/Array.h"
21#include "arccore/common/CommonGlobal.h"
22
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
26namespace Arcane
27{
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
32/*
33 * Example of ArcaNet file (RC2) :
34{
35 "versions": {
36 "_": 0,
37 "arcane": 0,
38 "arccher": 0
39 },
40
41 // Coucou
42
43 "general": {
44 "_": {
45 "name": "Common"
46 },
47 "arcane": {
48 "dataset": "./dataset.arc",
49 "options": {
50 "//meshes/mesh/filename": "aaa.msh",
51 "T": 4
52 }
53 },
54 "arccher": {
55 "mpi": 4
56 }
57 },
58
59 "commons": {
60 "4procs": {
61 "_": {
62 "name": "4 Procs"
63 },
64 "arccher": {
65 "mpi": 4
66 }
67 },
68 "4threads": {
69 "_": {
70 "name": "4 Threads"
71 },
72 "arcane": {
73 "options": {
74 "S": 4
75 }
76 }
77 },
78 "16mpithreads": {
79 "_": {
80 "name": "16 Hybrid",
81 "depend_a": ["4procs", "4threads"]
82 }
83 }
84 },
85
86 "variations": {
87 "nb_iterations": {
88 "10": {
89 "_": {
90 "name": "10 itérations"
91 },
92 "arcane": {
93 "options": {
94 "MaxIteration": 10
95 }
96 }
97 },
98 "20": {
99 "_": {
100 "name": "20 itérations"
101 },
102 "arcane": {
103 "options": {
104 "MaxIteration": 20
105 }
106 }
107 },
108 "30": {
109 "_": {
110 "name": "30 itérations"
111 },
112 "arcane": {
113 "options": {
114 "MaxIteration": 30
115 }
116 }
117 }
118 }
119 },
120
121 "cases": {
122 // Reserved symbol for cases name : ":", "=", "~"
123
124 // How to call "case1" :
125 // - "case1" -> ok
126 "case1": {
127 "_": {
128 "name": "Cas 1",
129 // Reserved symbol for depend_a/depend_b elements : "=", "!", "+"
130 "depend_a": ["4procs", "nb_iterations=10"]
131 },
132
133 // Reserved symbol for prog name : ":", "=", "~"
134 "arcane": {
135 "options": {
136 "//meshes/mesh/filename": "aaa.msh",
137 "T": 4
138 }
139 },
140
141 "arccher": {
142 "mpi": 2
143 }
144 },
145
146 // How to call "case2" :
147 // - "case2" -> error
148 // - "case2:nb_iterations=10" -> ok
149 // - "case2:nb_iterations=20" -> error
150 // - "case2~init:nb_iterations=10" -> ok
151 // - "case2~init:nb_iterations=20" -> error
152 "case2": {
153 "_": {
154 "name": "Cas 2",
155 "depend_b": ["16mpithreads"],
156 "depend_a": ["nb_iterations!20"]
157 },
158 "arcane": {
159 "options": {
160 "//meshes/mesh/filename": "bbb.msh",
161 "T": 8
162 }
163 },
164 "arcane~init": {
165 "options": {
166 "//meshes/mesh/filename": "bbb.msh",
167 "T": 16
168 }
169 }
170 },
171 // How to call "case3" :
172 // - "case3" -> error
173 // - "case3:nb_iterations=10" -> ok
174 // - "case3:nb_iterations=20" -> ok
175 // - "case3:nb_iterations=30" -> error
176 "case3": {
177 "_": {
178 "name": "Cas 3",
179 "depend_a": ["4procs", "nb_iterations+10+20"]
180 },
181
182 "arcane": {
183 "options": {
184 "//meshes/mesh/filename": "ccc.msh",
185 "T": 4
186 }
187 },
188
189 "arccher": {
190 "mpi": 2
191 }
192 },
193 }
194}
195 */
196
200class ARCCORE_COMMON_EXPORT ArcaNetReader
201{
202 public:
203
208 ArcaNetReader(const JSONValue& root);
209
210 public:
211
219 void init(const String& case_and_variations_values, const String& prog_name);
220
225 void read();
226
231 ArrayView<JSONValue> jsonValues() { return m_values; }
232
240 JSONValue extractFilePart(const JSONValue& config_part);
241
249 JSONValue extractProgPart(const JSONValue& config_part);
250
259 JSONValue extractPart(const String& part_name, const JSONValue& config_part);
260
266 bool computePath() const { return m_build_path; }
267
271 String path() const { return m_path; }
272
276 String configPartName() { return m_prog_custom_part_name.empty() ? m_prog_part_name : m_prog_custom_part_name; }
277
278 private:
279
280 void _readDependPart(const JSONValue& depend_part);
281 void _readConfigPart(const JSONValue& config_part, const String& node_name);
282 void _addElemInPath(const String& elem);
283 void _readFileBeforePart(const JSONValue& config_part);
284 void _readFileAfterPart(const JSONValue& config_part);
285 void _readArcanePart(const JSONValue& config_part);
286
287 private:
288
289 bool m_build_path = false;
290 StringBuilder m_path;
291 Integer m_level_path = 0;
292 const JSONValue& m_root;
293 UniqueArray<String> m_explored;
294 UniqueArray<String> m_variations_key_resolved;
295 UniqueArray<String> m_variations_value_resolved;
296 String m_prog_part_name;
297 String m_prog_custom_part_name;
298 UniqueArray<JSONValue> m_values;
299 String m_case_name;
300};
301
302/*---------------------------------------------------------------------------*/
303/*---------------------------------------------------------------------------*/
304
305} // End namespace Arcane
306
307/*---------------------------------------------------------------------------*/
308/*---------------------------------------------------------------------------*/
309
310#endif
bool computePath() const
Method allowing to determining if the path is recorded. To enable the recording, you can set ARCCORE_...
void read()
Method allowing to read the file and fill the chain of dependencies. First, you need to call 'init()'...
String path() const
Method allowing to get the dependencies path.
ArcaNetReader(const JSONValue &root)
Constructor.
ArrayView< JSONValue > jsonValues()
Method allowing to get all JSONValue to read, following the chain of dependencies.
String configPartName()
Method allowing to get the final name of program part.
void init(const String &case_and_variations_values, const String &prog_name)
Method allowing to initialise the file reader.
Modifiable view of an array of type T.
Unicode character string constructor.
bool empty() const
True if the string is empty (null or "").
Definition String.cc:317
1D data vector with value semantics (STL style).
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.