Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
BasicReaderWriter.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2024 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/* BasicReaderWriter.h (C) 2000-2024 */
9/* */
10/* Lecture/Ecriture simple. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13#ifndef ARCANE_STD_INTERNAL_BASICREADERWRITER_H
14#define ARCANE_STD_INTERNAL_BASICREADERWRITER_H
15/*---------------------------------------------------------------------------*/
16/*---------------------------------------------------------------------------*/
17
18#include "arcane/utils/TraceAccessor.h"
19#include "arcane/utils/String.h"
20#include "arcane/utils/ArrayShape.h"
21#include "arcane/utils/ScopedPtr.h"
22#include "arcane/utils/Array.h"
23
25#include "arcane/core/XmlNode.h"
26#include "arcane/core/VariableMetaData.h"
27
28#include "arcane/core/IDataWriter.h"
29#include "arcane/core/IDataReader.h"
30#include "arcane/core/IDataReader2.h"
31
32#include "arcane/std/internal/BasicReaderWriterDatabase.h"
33#include "arcane/std/internal/VariableDataInfo.h"
34
35#include <map>
36
37/*---------------------------------------------------------------------------*/
38/*---------------------------------------------------------------------------*/
39
40namespace Arcane
41{
42class ISerializedData;
43class IParallelMng;
44class ParallelDataWriter;
45class ParallelDataReader;
46}
47
48namespace Arcane::impl
49{
50
51/*---------------------------------------------------------------------------*/
52/*---------------------------------------------------------------------------*/
53
55{
56 public:
57
59 : m_full_name(varmd->fullName())
60 , m_item_group_name(varmd->itemGroupName())
61 , m_mesh_name(varmd->meshName())
62 , m_item_family_name(varmd->itemFamilyName())
63 {
64 }
65
66 public:
67
68 const String& fullName() const { return m_full_name; }
69 const String& itemGroupName() const { return m_item_group_name; }
70 const String& meshName() const { return m_mesh_name; }
71 const String& itemFamilyName() const { return m_item_family_name; }
72 bool isItemVariable() const { return !m_item_family_name.null(); }
73
74 private:
75
76 String m_full_name;
77 String m_item_group_name;
78 String m_mesh_name;
79 String m_item_family_name;
80};
81
82/*---------------------------------------------------------------------------*/
83/*---------------------------------------------------------------------------*/
89{
90 public:
91
92 virtual ~IGenericReader() = default;
93
94 public:
95
96 virtual void initialize(const String& path, Int32 rank) = 0;
97 virtual void readData(const String& var_full_name, IData* data) = 0;
98 virtual void readItemGroup(const String& group_name, Int64Array& written_unique_ids,
100 virtual String comparisonHashValue(const String& var_full_name) const = 0;
101 virtual const VariableDataInfoMap& variablesDataInfoMap() const =0;
102};
103
104/*---------------------------------------------------------------------------*/
105/*---------------------------------------------------------------------------*/
110: public TraceAccessor
111, public IGenericReader
112{
113 public:
114
115 // Si 'version==-1', alors cela sera déterminé lors de
116 // l'initialisation.
118
119 public:
120
121 void initialize(const String& path, Int32 rank) override;
122 void readData(const String& var_full_name, IData* data) override;
123 void readItemGroup(const String& group_name, Int64Array& written_unique_ids,
124 Int64Array& wanted_unique_ids) override;
125 String comparisonHashValue(const String& var_full_name) const override;
126 const VariableDataInfoMap& variablesDataInfoMap() const override
127 {
128 return m_variables_data_info;
129 }
130
131 private:
132
133 IApplication* m_application = nullptr;
134 Ref<KeyValueTextReader> m_text_reader;
135 String m_path;
136 Int32 m_rank = A_NULL_RANK;
137 Int32 m_version = -1;
138 VariableDataInfoMap m_variables_data_info;
139
140 private:
141
142 Ref<VariableDataInfo> _getVarInfo(const String& full_name);
143};
144
145/*---------------------------------------------------------------------------*/
146/*---------------------------------------------------------------------------*/
152{
153 public:
154
155 virtual ~IGenericWriter() = default;
156
157 public:
158
159 virtual void initialize(const String& path, Int32 rank) = 0;
168 const String& comparison_hash,
169 bool is_save_values) = 0;
170 virtual void writeItemGroup(const String& group_full_name,
173 virtual void endWrite() = 0;
174};
175
176/*---------------------------------------------------------------------------*/
177/*---------------------------------------------------------------------------*/
178
180: public TraceAccessor
181, public IGenericWriter
182{
183 public:
184
185 BasicGenericWriter(IApplication* app, Int32 version,
187
188 public:
189
190 void initialize(const String& path, Int32 rank) override;
192 const String& compare_hash, bool is_save_values) override;
195 void endWrite() override;
196
197 private:
198
199 IApplication* m_application = nullptr;
200 Int32 m_version = -1;
201 String m_path;
202 Int32 m_rank = A_NULL_RANK;
203 Ref<KeyValueTextWriter> m_text_writer;
204 VariableDataInfoMap m_variables_data_info;
205};
206
207/*---------------------------------------------------------------------------*/
208/*---------------------------------------------------------------------------*/
209
211: public TraceAccessor
212{
213 // Pour accéder aux méthodes statiques
214 friend class BasicGenericReader;
215 friend class BasicGenericWriter;
216
217 public:
218
219 enum eOpenMode
220 {
221 OpenModeRead,
222 OpenModeTruncate,
223 OpenModeAppend
224 };
225
226 public:
227
229 const String& path, eOpenMode open_mode);
230
231 protected:
232
233 IApplication* m_application = nullptr;
234 IParallelMng* m_parallel_mng = nullptr;
235 eOpenMode m_open_mode = OpenModeRead;
236 String m_path;
237 Integer m_verbose_level = 0;
238
239 protected:
240
241 String _getMetaDataFileName(Int32 rank) const;
242
243 protected:
244
245 static String _getArcaneDBTag();
246 static String _getOwnMetatadaFile(const String& path, Int32 rank);
247 static String _getArcaneDBFile(const String& path, Int32 rank);
248 static String _getBasicVariableFile(Int32 version, const String& path, Int32 rank);
249 static String _getBasicGroupFile(const String& path, const String& name, Int32 rank);
250 static Ref<IDataCompressor> _createDeflater(IApplication* app, const String& name);
251 static Ref<IHashAlgorithm> _createHashAlgorithm(IApplication* app, const String& name);
252 static void _fillUniqueIds(const ItemGroup& group, Array<Int64>& uids);
253};
254
255/*---------------------------------------------------------------------------*/
256/*---------------------------------------------------------------------------*/
257
258} // namespace Arcane::impl
259
260/*---------------------------------------------------------------------------*/
261/*---------------------------------------------------------------------------*/
262
263#endif
Déclarations des types généraux de Arcane.
Tableau d'items de types quelconques.
Interface de l'application.
Interface d'une donnée.
Definition IData.h:33
Interface du gestionnaire de parallélisme pour un sous-domaine.
Interface d'une donnée sérialisée.
Groupe d'entités de maillage.
Definition ItemGroup.h:49
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
Meta-données sur une variable.
Implémentation basique de IGenericReader.
void writeData(const String &var_full_name, const ISerializedData *sdata, const String &compare_hash, bool is_save_values) override
Sauve une variable.
virtual void writeData(const String &var_full_name, const ISerializedData *sdata, const String &comparison_hash, bool is_save_values)=0
Sauve une variable.
Tableau associatif des données des variables.
Chaîne de caractères unicode.
bool null() const
Retourne true si la chaîne est nulle.
Definition String.cc:304
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-