Arcane  4.2.3.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
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/* Lecteur de fichiers ArcaNet. */
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 // Symbole réservé pour le nom du cas : ":", "=", "~"
123
124 // Comment appeler "case1" :
125 // - "case1" -> ok
126 "case1": {
127 "_": {
128 "name": "Cas 1",
129 // Symbole réservé pour les éléments depend_a/depend_b : "=", "!", "+"
130 "depend_a": ["4procs", "nb_iterations=10"]
131 },
132
133 // Symbole réservé pour le nom du programme : ":", "=", "~"
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 // Comment appeler "case2" :
147 // - "case2" -> erreur
148 // - "case2:nb_iterations=10" -> ok
149 // - "case2:nb_iterations=20" -> erreur
150 // - "case2~init:nb_iterations=10" -> ok
151 // - "case2~init:nb_iterations=20" -> erreur
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 // Comment appeler "case3" :
172 // - "case3" -> erreur
173 // - "case3:nb_iterations=10" -> ok
174 // - "case3:nb_iterations=20" -> ok
175 // - "case3:nb_iterations=30" -> erreur
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
Méthode permettant de déterminer si le chemin est enregistré. Pour activer l'enregistrement,...
void read()
Méthode permettant de lire le fichier et de remplir la chaîne de dépendances. Il faut d'abord appeler...
String path() const
Méthode permettant d'obtenir le chemin des dépendances.
ArcaNetReader(const JSONValue &root)
Constructeur.
ArrayView< JSONValue > jsonValues()
Méthode permettant d'obtenir toutes les JSONValue à lire, en suivant la chaîne de dépendances.
String configPartName()
Méthode permettant d'obtenir le nom final de la partie programme.
void init(const String &case_and_variations_values, const String &prog_name)
Méthode permettant d'initialiser le lecteur de fichier.
Vue modifiable d'un tableau d'un type T.
Constructeur de chaîne de caractère unicode.
Chaîne de caractères unicode.
bool empty() const
Vrai si la chaîne est vide (nulle ou "").
Definition String.cc:316
Vecteur 1D de données avec sémantique par valeur (style STL).
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type représentant un entier.