12#ifndef ARCANE_IMPL_INTERNAL_ARRAYDATA_H
13#define ARCANE_IMPL_INTERNAL_ARRAYDATA_H
19#include "arcane/utils/ArrayShape.h"
20#include "arcane/utils/String.h"
21#include "arcane/utils/IDataCompressor.h"
22#include "arcane/utils/Array.h"
23#include "arcane/utils/MemoryView.h"
24#include "arcane/utils/Ref.h"
25#include "arcane/utils/NotSupportedException.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 ArrayDataT<DataType> ThatClass;
64 ArrayDataT(
const ArrayDataT<DataType>& rhs);
65 ~ArrayDataT()
override;
84 DataInterfaceType*
cloneTrue()
override {
return _cloneTrue(); }
88 auto* d = _cloneTrue();
93 auto* d = _cloneTrueEmpty();
111 visitor->applyVisitor(
this);
115 visitor->applyDataVisitor(
this);
123 visitor->applyVisitor(
this);
132 void swapValuesDirect(ThatClass* true_data);
164template <
typename DataType>
165class ArrayDataT<DataType>::Impl
171 explicit Impl(ArrayDataT<DataType>* p)
177 void reserve(
Integer new_capacity)
override { m_p->m_value.reserve(new_capacity); }
180 void shrink()
const override { m_p->m_value.shrink(); }
182 void dispose()
override { m_p->m_value.dispose(); }
190 compressor->
compress(bytes, buf.m_buffer);
191 buf.m_original_dim1_size = values.
size();
192 m_p->m_value.clear();
193 m_p->m_value.shrink();
201 m_p->m_value.resize(buf.m_original_dim1_size);
212 return m_p->view().size();
218 m_p->computeHash(hash_info);
224 ArrayDataT<DataType>* m_p =
nullptr;
#define ARCANE_THROW(exception_class,...)
Macro for throwing an exception with formatting.
#define ARCCORE_DEFINE_REFERENCE_COUNTED_INCLASS_METHODS()
Macro to define methods managing counters of references.
void computeHash(DataHashInfo &hash_info) override
Calculates the hash of the data.
void reserve(Integer new_capacity) override
Reserves memory for new_capacity elements.
void resize(Integer new_size) override
Resizes the container.
INumericDataInternal * numericData() override
Generic interface for numeric data (nullptr if the data is not numeric).
bool decompressAndFill(DataCompressionBuffer &buf) override
Decompresses the data and fills the data values.
Integer capacity() const override
Capacity allocated by the container.
Array< DataType > & _internalDeprecatedValue() override
Container associated with the data.
void changeAllocator(const MemoryAllocationOptions &v) override
Changes the variable's allocator.
void dispose() override
Clears the container and frees allocated memory.
void shrink() const override
Frees additional allocated memory.
IMemoryAllocator * memoryAllocator() const override
Allocator used for the data.
Int32 extent0() const override
Number of elements in the first dimension.
MutableMemoryView memoryView() override
Memory view of the data.
bool compressAndClear(DataCompressionBuffer &buf) override
Compresses the data and frees the associated memory.
IData * cloneEmpty() override
Clone the data but without elements. The created instance must be destroyed by the 'delete' operator.
ArrayView< DataType > view() override
View on the data.
eDataType dataType() const override
Data type.
ConstArrayView< DataType > view() const override
Constant view on the data.
Ref< ISerializedData > createSerializedDataRef(bool use_basic_type) const override
Serialize the data.
void serialize(ISerializer *sbuf, IDataOperation *operation) override
Serializes the data by applying the operation.
void allocateBufferForSerializedData(ISerializedData *sdata) override
Allocate memory to read the serialized values sdata.
void visitScalar(IScalarDataVisitor *) override
Apply the visitor to the data.
void computeHash(IHashAlgorithm *algo, ByteArray &output) const override
Compute a hash key on this data.
DataStorageTypeInfo storageTypeInfo() const override
Information about the data container type.
ArrayShape shape() const override
Array shape for a 1D or 2D data item.
Ref< IData > cloneRef() override
Clone the data.
const Array< DataType > & value() const override
Constant data value.
void setName(const String &name) override
Sets the name of the data (internal).
void visitArray2(IArray2DataVisitor *) override
Apply the visitor to the data.
void visitArray(IArrayDataVisitor *visitor) override
Apply the visitor to the data.
DataAllocationInfo allocationInfo() const override
Allocation information.
DataInterfaceType * cloneTrue() override
Clone the data.
void visit(IArrayDataVisitor *visitor) override
Applies the visitor to the data.
void swapValues(IData *data) override
Swap the values of data with those of the instance.
void assignSerializedData(const ISerializedData *sdata) override
Assign the serialized values sdata to the data.
DataInterfaceType * cloneTrueEmpty() override
Clone the data but without elements.
UniqueArray< DataType > m_value
Data.
Array< DataType > & value() override
Data value.
Integer multiTag() const override
Multi-tag. 0 if not multiple, 1 if multiple, 2 if multiple for MultiArray variables (obsolete).
void fillDefault() override
Fills the data with its default value.
void visit(IDataVisitor *visitor) override
Applies the visitor to the data.
Integer dimension() const override
Dimension. 0 for a scalar, 1 for a mono-dim array, 2 for a bi-dim array.
void copy(const IData *data) override
Copy the data data into the current instance.
Ref< DataInterfaceType > cloneTrueEmptyRef() override
Clone the data but without elements.
Ref< IData > cloneEmptyRef() override
Clone the data but without elements.
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.
void setAllocationInfo(const DataAllocationInfo &v) override
Sets the allocation information.
void setShape(const ArrayShape &new_shape) override
Sets the array shape.
IDataInternal * _commonInternal() override
Ref< DataInterfaceType > cloneTrueRef() override
Clone the data.
IArrayDataInternalT< DataType > * _internal() override
Modifiable view of an array of type T.
Base class for 1D data vectors.
Constant view of an array of type T.
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 of the visitor pattern for a 2D array data item.
Interface for an array data of type T.
Interface of a 1D array data item of type T.
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.
constexpr __host__ __device__ SizeType size() const noexcept
Returns the size of the array.
View of an array of elements of type T.
Unicode character string.
1D 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.
std::int32_t Int32
Signed integer type of 32 bits.