Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
IDataInternal.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/* IDataInternal.h (C) 2000-2025 */
9/* */
10/* Internal part of IData in Arcane. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_INTERNAL_IDATAINTERNAL_H
13#define ARCANE_CORE_INTERNAL_IDATAINTERNAL_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
18
19#include "arcane/utils/UniqueArray.h"
20#include "arcane/utils/IHashAlgorithm.h"
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25namespace Arcane
26{
27class IDataCompressor;
29
30/*---------------------------------------------------------------------------*/
31/*---------------------------------------------------------------------------*/
32
37{
38 public:
39
41 Int64 m_original_dim1_size = 0;
42 Int64 m_original_dim2_size = 0;
43 IDataCompressor* m_compressor = nullptr;
44};
45
46/*---------------------------------------------------------------------------*/
47/*---------------------------------------------------------------------------*/
48
52class DataHashInfo
53{
54 public:
55
56 explicit DataHashInfo(IHashAlgorithmContext* context)
57 : m_context(context)
58 {}
59
60 public:
61
62 IHashAlgorithmContext* context() const { return m_context; }
63 Int32 version() const { return m_version; }
64 void setVersion(Int32 v) { m_version = v; }
65
66 private:
67
68 IHashAlgorithmContext* m_context = nullptr;
69 Int32 m_version = 0;
70};
71
72/*---------------------------------------------------------------------------*/
73/*---------------------------------------------------------------------------*/
74
79class ARCANE_CORE_EXPORT IDataInternal
80{
81 public:
82
83 virtual ~IDataInternal() = default;
84
85 public:
86
102 {
103 ARCANE_UNUSED(buf);
104 return false;
105 }
106
120 {
121 ARCANE_UNUSED(buf);
122 return false;
123 }
124
126 virtual INumericDataInternal* numericData() { return nullptr; }
127
133 virtual void computeHash(DataHashInfo& hash_info) = 0;
134};
135
136/*---------------------------------------------------------------------------*/
137/*---------------------------------------------------------------------------*/
138
147class ARCANE_CORE_EXPORT INumericDataInternal
148{
149 public:
150
151 virtual ~INumericDataInternal() = default;
152
153 public:
154
157
159 virtual Int32 extent0() const = 0;
160
165 virtual void changeAllocator(const MemoryAllocationOptions& alloc_info) = 0;
166
170 virtual IMemoryAllocator* memoryAllocator() const = 0;
171};
172
173/*---------------------------------------------------------------------------*/
174/*---------------------------------------------------------------------------*/
175
177: public IDataInternal
178{
179};
180
181/*---------------------------------------------------------------------------*/
182/*---------------------------------------------------------------------------*/
183
188template <class DataType>
190: public IDataInternal
191{
192 public:
193
195 virtual void reserve(Integer new_capacity) = 0;
196
199
201 virtual Integer capacity() const = 0;
202
204 virtual void shrink() const = 0;
205
207 virtual void resize(Integer new_size) = 0;
208
210 virtual void dispose() = 0;
211};
212
213/*---------------------------------------------------------------------------*/
214/*---------------------------------------------------------------------------*/
215
220template <class DataType>
222: public IDataInternal
223{
224 public:
225
227 virtual void reserve(Integer new_capacity) = 0;
228
231
233 virtual void resizeOnlyDim1(Int32 new_dim1_size) = 0;
234
236 virtual void resize(Int32 new_dim1_size, Int32 new_dim2_size) = 0;
237
239 virtual void shrink() const = 0;
240};
241
242/*---------------------------------------------------------------------------*/
243/*---------------------------------------------------------------------------*/
244
245} // End namespace Arcane
246
247/*---------------------------------------------------------------------------*/
248/*---------------------------------------------------------------------------*/
249
250namespace Arcane::impl
251{
252
259extern "C++" ARCANE_CORE_EXPORT void
260copyContiguousData(INumericDataInternal* destination, ConstMemoryView source, RunQueue& queue);
261
268extern "C++" ARCANE_CORE_EXPORT void
269copyContiguousData(IData* destination, IData* source, RunQueue& queue);
270
271extern "C++" ARCANE_CORE_EXPORT void
272fillContiguousDataGeneric(IData* data, const void* fill_address,
273 Int32 datatype_size, RunQueue& queue);
274
275template <typename DataType> inline void
276fillContiguousData(IData* data, const DataType& value, RunQueue& queue)
277{
278 constexpr Int32 type_size = static_cast<Int32>(sizeof(DataType));
279 fillContiguousDataGeneric(data, &value, type_size, queue);
280}
281
282} // namespace Arcane::impl
283
284/*---------------------------------------------------------------------------*/
285/*---------------------------------------------------------------------------*/
286
287#endif
Declarations of Arcane's general types.
Class representing a classic 2D array.
Base class for 1D data vectors.
Class to manage data compression/decompression.
Information for calculating data hash.
Interface for a two-dimensional array data of type T.
virtual Array2< DataType > & _internalDeprecatedValue()=0
Container associated with the data.
virtual void resize(Int32 new_dim1_size, Int32 new_dim2_size)=0
Resizes the container.
virtual void resizeOnlyDim1(Int32 new_dim1_size)=0
Resizes the container only in dimension 1.
virtual void shrink() const =0
Frees additional allocated memory.
virtual void reserve(Integer new_capacity)=0
Reserves memory for new_capacity elements.
Interface for an array data of type T.
virtual Integer capacity() const =0
Capacity allocated by the container.
virtual void reserve(Integer new_capacity)=0
Reserves memory for new_capacity elements.
virtual Array< DataType > & _internalDeprecatedValue()=0
Container associated with the data.
virtual void shrink() const =0
Frees additional allocated memory.
virtual void dispose()=0
Clears the container and frees allocated memory.
virtual void resize(Integer new_size)=0
Resizes the container.
Interface of a service for compressing/decompressing data.
Internal part of IData.
virtual void computeHash(DataHashInfo &hash_info)=0
Calculates the hash of the data.
virtual bool decompressAndFill(DataCompressionBuffer &buf)
Decompresses the data and fills the data values.
virtual bool compressAndClear(DataCompressionBuffer &buf)
Compresses the data and frees the associated memory.
virtual INumericDataInternal * numericData()
Generic interface for numeric data (nullptr if the data is not numeric).
Context for calculating a hash incrementally.
Interface for an 'IData' of a numeric type.
virtual void changeAllocator(const MemoryAllocationOptions &alloc_info)=0
Changes the variable's allocator.
virtual Int32 extent0() const =0
Number of elements in the first dimension.
virtual IMemoryAllocator * memoryAllocator() const =0
Allocator used for the data.
virtual MutableMemoryView memoryView()=0
Memory view of the data.
Mutable view on a contiguous memory region containing fixed-size elements.
1D data vector with value semantics (STL style).
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
std::int32_t Int32
Signed integer type of 32 bits.