Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
BasicWriter.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/* BasicWriter.h (C) 2000-2024 */
9/* */
10/* Simple writer. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_STD_INTERNAL_BASICWRITER_H
13#define ARCANE_STD_INTERNAL_BASICWRITER_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/std/internal/BasicReaderWriter.h"
18#include "arcane/std/internal/ParallelDataWriter.h"
19
20#include <map>
21#include <set>
22
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
26namespace Arcane::impl
27{
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
35class BasicWriter
36: public BasicReaderWriterCommon
37, public IDataWriter
38{
39 public:
40
41 BasicWriter(IApplication* app, IParallelMng* pm, const String& path,
42 eOpenMode open_mode, Integer version, bool want_parallel);
43
44 public:
45
47 void beginWrite(const VariableCollection& vars) override;
48 void endWrite() override;
49 void setMetaData(const String& meta_data) override;
50 void write(IVariable* v, IData* data) override;
52
53 public:
54
57 {
58 _checkNoInit();
59 m_data_compressor = data_compressor;
60 }
61
64 {
65 _checkNoInit();
66 m_compare_hash_algorithm = hash_algo;
67 }
68
70 void setSaveValues(bool v)
71 {
72 _checkNoInit();
74 }
75 void initialize();
76
77 private:
78
79 bool m_want_parallel = false;
80 bool m_is_gather = false;
81 bool m_is_init = false;
83 bool m_is_save_values = true;
84 Int32 m_version = -1;
85
86 Ref<IDataCompressor> m_data_compressor;
87 Ref<IHashAlgorithm> m_compare_hash_algorithm;
88 Ref<IHashAlgorithm> m_hash_algorithm;
89 Ref<KeyValueTextWriter> m_text_writer;
90
91 ParallelDataWriterList m_parallel_data_writers;
92 std::set<ItemGroup> m_written_groups;
93
94 ScopedPtrT<IGenericWriter> m_global_writer;
95
96 private:
97
98 void _directWriteVal(IVariable* v, IData* data);
99 String _computeCompareHash(IVariable* var, IData* write_data);
100 Ref<ParallelDataWriter> _getWriter(IVariable* var);
101 void _endWriteV3();
102 void _checkNoInit();
103};
104
105/*---------------------------------------------------------------------------*/
106/*---------------------------------------------------------------------------*/
107
108} // namespace Arcane::impl
109
110/*---------------------------------------------------------------------------*/
111/*---------------------------------------------------------------------------*/
112
113#endif
Application interface.
Interface for writing variable data.
Definition IDataWriter.h:45
Interface of a data item.
Definition IData.h:34
Interface of the parallelism manager for a subdomain.
Interface of a variable.
Definition IVariable.h:40
list of 'ParallelDataWriter'.
Reference to an instance.
Encapsulation of an automatically destructing pointer.
Definition ScopedPtr.h:44
bool m_is_save_values
Indicates whether to save the values.
Definition BasicWriter.h:83
String _computeCompareHash(IVariable *var, IData *write_data)
Calculates a comparison hash for the variable.
void setCompareHashAlgorithm(Ref< IHashAlgorithm > hash_algo)
Definition BasicWriter.h:63
void beginWrite(const VariableCollection &vars) override
Implementation of IDataWriter.
void setDataCompressor(Ref< IDataCompressor > data_compressor)
Sets the compression service. Must be called before initialize().
Definition BasicWriter.h:56
void write(IVariable *v, IData *data) override
Writes the data data of the variable var.
void setMetaData(const String &meta_data) override
Sets the metadata information.
Int32 Integer
Type representing an integer.
std::int32_t Int32
Signed integer type of 32 bits.