Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
DataFactoryMng.cc
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/* DataFactoryMng.cc (C) 2000-2021 */
9/* */
10/* Data Factory Manager. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/impl/DataFactoryMng.h"
15
16#include "arcane/utils/PlatformUtils.h"
17#include "arcane/utils/Deleter.h"
18#include "arcane/utils/ITraceMng.h"
19#include "arcane/utils/FatalErrorException.h"
20
21#include "arcane/core/IApplication.h"
22#include "arcane/core/IData.h"
23#include "arcane/core/IDataStorageFactory.h"
25
26#include "arcane/datatype/DataStorageTypeInfo.h"
27#include "arcane/datatype/DataStorageBuildInfo.h"
28
29#include "arcane/impl/SerializedData.h"
30#include "arcane/impl/DataFactory.h"
31#include "arcane/impl/DataOperation.h"
32
33/*---------------------------------------------------------------------------*/
34/*---------------------------------------------------------------------------*/
35
36namespace Arcane
37{
38
39/*---------------------------------------------------------------------------*/
40/*---------------------------------------------------------------------------*/
41
42extern "C++" void
43arcaneRegisterSimpleData(IDataFactoryMng* df);
44
45/*---------------------------------------------------------------------------*/
46/*---------------------------------------------------------------------------*/
47
48DataFactoryMng::
49DataFactoryMng(IApplication* app)
50: TraceAccessor(app->traceMng())
51, m_application(app)
52, m_old_factory(new DataFactory(app))
53{
54}
55
56/*---------------------------------------------------------------------------*/
57/*---------------------------------------------------------------------------*/
58
59DataFactoryMng::
60~DataFactoryMng()
61{
62 delete m_old_factory;
63}
64
65/*---------------------------------------------------------------------------*/
66/*---------------------------------------------------------------------------*/
67
68Ref<IData> DataFactoryMng::
69createSimpleDataRef(const String& storage_type, const DataStorageBuildInfo& build_info)
70{
71 auto x = m_factories.find(storage_type);
72 if (x == m_factories.end())
73 ARCANE_FATAL("Can not find data factory named={0}", storage_type);
74 // Positions the values of \a build_info that are not yet
75 // initialized.
76 DataStorageBuildInfo b = build_info;
77 if (!b.memoryAllocator())
78 b.setMemoryAllocator(platform::getDefaultDataAllocator());
79
80 return x->second->createSimpleDataRef(b);
81}
82
83/*---------------------------------------------------------------------------*/
84/*---------------------------------------------------------------------------*/
85
86IDataOperation* DataFactoryMng::
87createDataOperation(Parallel::eReduceType rt)
88{
89 return arcaneCreateDataOperation(rt);
90}
91
92/*---------------------------------------------------------------------------*/
93/*---------------------------------------------------------------------------*/
94
95Ref<ISerializedData> DataFactoryMng::
96createSerializedDataRef(eDataType data_type, Int64 memory_size,
97 Integer nb_dim, Int64 nb_element, Int64 nb_base_element,
98 bool is_multi_size, Int64ConstArrayView dimensions)
99{
100 return arcaneCreateSerializedDataRef(data_type, memory_size, nb_dim, nb_element,
101 nb_base_element, is_multi_size, dimensions);
102}
103
104/*---------------------------------------------------------------------------*/
105/*---------------------------------------------------------------------------*/
106
107Ref<ISerializedData> DataFactoryMng::
108createEmptySerializedDataRef()
109{
111}
112
113/*---------------------------------------------------------------------------*/
114/*---------------------------------------------------------------------------*/
115
116void DataFactoryMng::
117build()
118{
119 arcaneRegisterSimpleData(this);
120}
121
122/*---------------------------------------------------------------------------*/
123/*---------------------------------------------------------------------------*/
124
125ITraceMng* DataFactoryMng::
126traceMng() const
127{
129}
130
131/*---------------------------------------------------------------------------*/
132/*---------------------------------------------------------------------------*/
133
134void DataFactoryMng::
135registerDataStorageFactory(Ref<IDataStorageFactory> factory)
136{
137 DataStorageTypeInfo t = factory->storageTypeInfo();
138 m_factories.insert(std::make_pair(t.fullName(), factory));
139}
140
141/*---------------------------------------------------------------------------*/
142/*---------------------------------------------------------------------------*/
143
145arcaneCreateDataFactoryMngRef(IApplication* app)
146{
148 df->build();
149 return df;
150}
151
152/*---------------------------------------------------------------------------*/
153/*---------------------------------------------------------------------------*/
154
155} // End namespace Arcane
156
157/*---------------------------------------------------------------------------*/
158/*---------------------------------------------------------------------------*/
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
Various mathematical functions.
Data factory manager.
Interface of a data factory.
Definition DataFactory.h:33
Type information for a data container.
Application interface.
Interface of the data factory manager.
Interface of an operation on a data.
Reference to an instance.
ITraceMng * traceMng() const
Trace manager.
eReduceType
Supported reduction types.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Ref< ISerializedData > arcaneCreateSerializedDataRef(eDataType data_type, Int64 memory_size, Integer nb_dim, Int64 nb_element, Int64 nb_base_element, bool is_multi_size, Int64ConstArrayView dimensions)
Creates serialized data.
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
ConstArrayView< Int64 > Int64ConstArrayView
C equivalent of a 1D array of 64-bit integers.
Definition UtilsTypes.h:480
Ref< ISerializedData > arcaneCreateEmptySerializedDataRef()
Creates serialized data.
eDataType
Data type.
Definition DataTypes.h:41
auto makeRef(InstanceType *t) -> Ref< InstanceType >
Creates a reference on a pointer.