Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
BasicReader.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/* BasicReader.h (C) 2000-2024 */
9/* */
10/* Simple reader. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_STD_INTERNAL_BASICREADER_H
13#define ARCANE_STD_INTERNAL_BASICREADER_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/std/internal/BasicReaderWriter.h"
18
19#include <map>
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24namespace Arcane::impl
25{
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
33class BasicReader
34: public BasicReaderWriterCommon
35, public IDataReader
36, public IDataReader2
37{
38 public:
39
45 {
46 public:
47
48 virtual ~IItemGroupFinder() = default;
49 virtual ItemGroup getWantedGroup(VariableMetaData* vmd) = 0;
50 };
51
52 public:
53
54 BasicReader(IApplication* app, IParallelMng* pm, Int32 forced_rank_to_read,
55 const String& path, bool want_parallel);
56
57 public:
58
59 void beginRead(const VariableCollection& vars) override;
60 void endRead() override {}
61 String metaData() override;
62 void read(IVariable* v, IData* data) override;
63
64 void fillMetaData(ByteArray& bytes) override;
65 void beginRead(const DataReaderInfo& infos) override;
66 void read(const VariableDataReadInfo& infos) override;
67
68 public:
69
70 void initialize();
71 void setItemGroupFinder(IItemGroupFinder* group_finder)
72 {
73 m_item_group_finder = group_finder;
74 }
75 void fillComparisonHash(std::map<String, String>& comparison_hash_map);
76 IHashAlgorithm* comparisonHashAlgorithm() const { return m_comparison_hash_algorithm.get(); }
77
78 private:
79
80 bool m_want_parallel = false;
81 Integer m_nb_written_part = 0;
82 Int32 m_version = -1;
83
84 Int32 m_first_rank_to_read = -1;
85 Int32 m_nb_rank_to_read = -1;
86 Int32 m_forced_rank_to_read = -1;
87
88 std::map<String, Ref<ParallelDataReader>> m_parallel_data_readers;
89 UniqueArray<Ref<IGenericReader>> m_global_readers;
90 IItemGroupFinder* m_item_group_finder;
92 Ref<IDataCompressor> m_data_compressor;
93 Ref<IHashAlgorithm> m_comparison_hash_algorithm;
94
95 private:
96
97 void _directReadVal(VariableMetaData* varmd, IData* data);
98
100 void _setRanksToRead();
101 Ref<IGenericReader> _readOwnMetaDataAndCreateReader(Int32 rank);
102};
103
104/*---------------------------------------------------------------------------*/
105/*---------------------------------------------------------------------------*/
106
107} // namespace Arcane::impl
108
109/*---------------------------------------------------------------------------*/
110/*---------------------------------------------------------------------------*/
111
112#endif
Data reading information.
Application interface.
Interface for reading data of a variable (Version 2).
virtual void endRead()=0
Notifies the end of data reading.
Interface for reading variable data.
Definition IDataReader.h:35
Interface of a data item.
Definition IData.h:34
Interface of a hashing algorithm.
Interface of the parallelism manager for a subdomain.
Interface of a variable.
Definition IVariable.h:40
Mesh entity group.
Definition ItemGroup.h:51
Reference to an instance.
Data reading information for a variable.
Metadata on a variable.
Interface to find the group associated with a variable based on this metadata.
Definition BasicReader.h:45
Ref< KeyValueTextReader > m_forced_rank_to_read_text_reader
Reader for the first rank to read.
Definition BasicReader.h:91
String metaData() override
Metadata.
void fillComparisonHash(std::map< String, String > &comparison_hash_map)
Fills the argument with pairs (variable_name, hash_value).
void read(IVariable *v, IData *data) override
Reads the data data of the variable var.
void fillMetaData(ByteArray &bytes) override
Fills bytes with the metadata content.
Int32 Integer
Type representing an integer.
Array< Byte > ByteArray
Dynamic one-dimensional array of characters.
Definition UtilsTypes.h:121
std::int32_t Int32
Signed integer type of 32 bits.