12#ifndef ARCANE_IMPL_INTERNAL_ARRAY2DATA_H
13#define ARCANE_IMPL_INTERNAL_ARRAY2DATA_H
19#include "arcane/utils/ArrayShape.h"
20#include "arcane/utils/String.h"
21#include "arcane/utils/IDataCompressor.h"
22#include "arcane/utils/Array2.h"
23#include "arcane/utils/MemoryView.h"
24#include "arcane/utils/Ref.h"
25#include "arcane/utils/FatalErrorException.h"
27#include "arcane/core/IData.h"
28#include "arcane/core/IDataVisitor.h"
29#include "arcane/core/internal/IDataInternal.h"
30#include "arcane/core/datatype/DataAllocationInfo.h"
31#include "arcane/core/datatype/DataTypeTraits.h"
32#include "arcane/core/datatype/DataStorageTypeInfo.h"
46template <
class DataType>
57 typedef Array2DataT<DataType> ThatClass;
64 Array2DataT(
const Array2DataT<DataType>& rhs);
65 ~Array2DataT()
override;
84 DataInterfaceType*
cloneTrue()
override {
return _cloneTrue(); }
88 auto* d = _cloneTrue();
93 auto* d = _cloneTrueEmpty();
112 visitor->applyVisitor(
this);
116 visitor->applyDataVisitor(
this);
128 visitor->applyVisitor(
this);
133 void swapValuesDirect(ThatClass* true_data);
162template <
typename DataType>
163class Array2DataT<DataType>::Impl
169 explicit Impl(Array2DataT<DataType>* p)
175 void reserve(
Integer new_capacity)
override { m_p->m_value.reserve(new_capacity); }
178 m_p->m_value.resize(new_dim1_size, m_p->m_value.dim2Size());
182 if (new_dim1_size < 0)
183 ARCANE_FATAL(
"Bad value '{0}' for dim1_size", new_dim1_size);
184 if (new_dim2_size < 0)
185 ARCANE_FATAL(
"Bad value '{0}' for dim2_size", new_dim2_size);
188 bool need_reshape =
false;
189 if (new_dim2_size != m_p->m_value.dim2Size())
191 m_p->m_value.resize(new_dim1_size, new_dim2_size);
193 m_p->m_shape.setNbDimension(1);
194 m_p->m_shape.setDimension(0, new_dim2_size);
198 void shrink()
const override { m_p->m_value.shrink(); }
206 compressor->
compress(bytes, buf.m_buffer);
207 buf.m_original_dim1_size = m_p->m_value.dim1Size();
208 buf.m_original_dim2_size = m_p->m_value.dim2Size();
209 m_p->m_value.clear();
210 m_p->m_value.shrink();
218 m_p->m_value.resize(buf.m_original_dim1_size, buf.m_original_dim2_size);
230 Int32 nb_basic_element = storage_info.nbBasicElement();
236 return m_p->view().dim1Size();
242 m_p->computeHash(hash_info);
248 Array2DataT<DataType>* m_p =
nullptr;
#define ARCANE_THROW(exception_class,...)
Macro for throwing an exception with formatting.
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
#define ARCCORE_DEFINE_REFERENCE_COUNTED_INCLASS_METHODS()
Macro to define methods managing counters of references.
Int32 extent0() const override
Number of elements in the first dimension.
void resizeOnlyDim1(Int32 new_dim1_size) override
Resizes the container only in dimension 1.
Array2< DataType > & _internalDeprecatedValue() override
Container associated with the data.
MutableMemoryView memoryView() override
Memory view of the data.
IMemoryAllocator * memoryAllocator() const override
Allocator used for the data.
bool decompressAndFill(DataCompressionBuffer &buf) override
Decompresses the data and fills the data values.
void resize(Int32 new_dim1_size, Int32 new_dim2_size) override
Resizes the container.
void changeAllocator(const MemoryAllocationOptions &v) override
Changes the variable's allocator.
bool compressAndClear(DataCompressionBuffer &buf) override
Compresses the data and frees the associated memory.
void computeHash(DataHashInfo &hash_info) override
Calculates the hash of the data.
void reserve(Integer new_capacity) override
Reserves memory for new_capacity elements.
INumericDataInternal * numericData() override
Generic interface for numeric data (nullptr if the data is not numeric).
void shrink() const override
Frees additional allocated memory.
ConstArray2View< DataType > view() const override
Constant view on the data.
void fillDefault() override
Fills the data with its default value.
void assignSerializedData(const ISerializedData *sdata) override
Assign the serialized values sdata to the data.
void resize(Integer new_size) override
Resize the data.
IData * clone() override
Clone the data. The created instance must be destroyed by the 'delete' operator.
const Array2< DataType > & value() const override
Data value.
void visitArray2(IArray2DataVisitor *visitor) override
Apply the visitor to the data.
UniqueArray2< DataType > m_value
Data.
DataAllocationInfo allocationInfo() const override
Allocation information.
IData * cloneEmpty() override
Clone the data but without elements. The created instance must be destroyed by the 'delete' operator.
Ref< DataInterfaceType > cloneTrueRef() override
Clone the data.
IDataInternal * _commonInternal() override
void computeHash(IHashAlgorithm *algo, ByteArray &output) const override
Compute a hash key on this data.
Ref< IData > cloneRef() override
Clone the data.
void serialize(ISerializer *sbuf, IDataOperation *operation) override
Serializes the data by applying the operation.
Ref< IData > cloneEmptyRef() override
Clone the data but without elements.
Ref< ISerializedData > createSerializedDataRef(bool use_basic_type) const override
Serialize the data.
DataInterfaceType * cloneTrueEmpty() override
Clone the data but without elements.
void allocateBufferForSerializedData(ISerializedData *sdata) override
Allocate memory to read the serialized values sdata.
DataStorageTypeInfo storageTypeInfo() const override
Information about the data container type.
IArray2DataInternalT< DataType > * _internal() override
Array2< DataType > & value() override
Data value.
Integer dimension() const override
Dimension. 0 for a scalar, 1 for a mono-dim array, 2 for a bi-dim array.
DataInterfaceType * cloneTrue() override
Clone the data.
Ref< DataInterfaceType > cloneTrueEmptyRef() override
Clone the data but without elements.
void swapValues(IData *data) override
Swap the values of data with those of the instance.
Array2View< DataType > view() override
View on the data.
void visit(IDataVisitor *visitor) override
Applies the visitor to the data.
Integer multiTag() const override
Multi-tag. 0 if not multiple, 1 if multiple, 2 if multiple for MultiArray variables (obsolete).
void visitScalar(IScalarDataVisitor *) override
Apply the visitor to the data.
void setAllocationInfo(const DataAllocationInfo &v) override
Sets the allocation information.
void setShape(const ArrayShape &new_shape) override
Sets the array shape.
eDataType dataType() const override
Data type.
ArrayShape shape() const override
Array shape for a 1D or 2D data item.
void visitArray(IArrayDataVisitor *) override
Apply the visitor to the data.
void copy(const IData *data) override
Copy the data data into the current instance.
void setName(const String &name) override
Sets the name of the data (internal).
Mutable view for a 2D array.
Class representing a classic 2D array.
View for a constant 2D array.
Information on data allocation.
Class to manage data compression/decompression.
Information for calculating data hash.
Information to construct an instance of 'IData'.
Type information for a data container.
Interface for a two-dimensional array data of type T.
Interface of a bi-dimensional array data item of type T.
Interface of the visitor pattern for a 2D array data item.
Interface of the visitor pattern for an array data item.
Interface of a service for compressing/decompressing data.
virtual void decompress(Span< const std::byte > compressed_values, Span< std::byte > values)=0
Decompresses the data compressed_values and stores it in values.
virtual void compress(Span< const std::byte > values, Array< std::byte > &compressed_values)=0
Compresses the data values and stores it in compressed_values.
Interface of an operation on a data.
Interface of the visitor pattern for a data item.
Interface of a data item.
Interface of a hashing algorithm.
Interface for a memory allocator.
Interface for an 'IData' of a numeric type.
Interface of the visitor pattern for a scalar data item.
Interface of a serialized data.
Options to configure allocations.
Mutable view on a contiguous memory region containing fixed-size elements.
Exception when an operation is not supported.
Reference to an instance.
Thread-safe implementation of a reference counter.
View of an array of elements of type T.
Unicode character string.
2D data vector with value semantics (STL style).
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
MutableMemoryView makeMutableMemoryView(void *ptr, Int32 datatype_size, Int64 nb_element)
Creates a mutable memory view.
Int32 Integer
Type representing an integer.
Array< Byte > ByteArray
Dynamic one-dimensional array of characters.
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
Impl::SpanTypeFromSize< conststd::byte, SizeType >::SpanType asBytes(const SpanImpl< DataType, SizeType, Extent > &s)
Converts the view into an array of non-modifiable bytes.
auto makeRef(InstanceType *t) -> Ref< InstanceType >
Creates a reference on a pointer.
Impl::SpanTypeFromSize< std::byte, SizeType >::SpanType asWritableBytes(const SpanImpl< DataType, SizeType, Extent > &s)
Converts the view into an array of modifiable bytes.
Integer basicDataTypeSize(eBasicDataType type)
Size of data type type.
std::int32_t Int32
Signed integer type of 32 bits.