16#include "arcane/utils/NotSupportedException.h"
17#include "arcane/utils/NotImplementedException.h"
18#include "arcane/utils/ArgumentException.h"
19#include "arcane/utils/TraceInfo.h"
20#include "arcane/utils/ITraceMng.h"
21#include "arcane/utils/IHashAlgorithm.h"
22#include "arcane/utils/Array.h"
23#include "arcane/utils/ArrayShape.h"
25#include "arcane/core/datatype/DataAllocationInfo.h"
26#include "arcane/core/datatype/DataStorageTypeInfo.h"
27#include "arcane/core/datatype/DataStorageBuildInfo.h"
28#include "arcane/core/datatype/DataTypeTraits.h"
30#include "arcane/impl/SerializedData.h"
31#include "arcane/impl/DataStorageFactory.h"
33#include "arcane/core/ISerializer.h"
34#include "arcane/core/IDataVisitor.h"
36#include "arcane/core/internal/IDataInternal.h"
61 typedef StringArrayData ThatClass;
66 explicit StringArrayData(
ITraceMng* trace);
68 StringArrayData(
const StringArrayData& rhs);
69 ~StringArrayData()
override;
87 DataInterfaceType*
cloneTrue()
override {
return _cloneTrue(); }
91 auto* d = _cloneTrue();
96 auto* d = _cloneTrueEmpty();
115 visitor->applyVisitor(
this);
143 ThatClass* _cloneTrue()
const {
return new ThatClass(*
this); }
144 ThatClass* _cloneTrueEmpty()
const {
return new ThatClass(m_trace); }
156 using String = DataType;
158 explicit Impl(StringArrayData* p)
164 void reserve(
Integer new_capacity)
override { m_p->m_value.reserve(new_capacity); }
167 void shrink()
const override { m_p->m_value.shrink(); }
169 void dispose()
override { m_p->m_value.dispose(); }
172 m_p->computeHash(hash_info);
177 StringArrayData* m_p;
185: m_trace(dsbi.traceMng())
186, m_internal(new Impl(this))
191StringArrayData(ITraceMng* trace)
193, m_internal(new Impl(this))
197StringArrayData(
const StringArrayData& rhs)
199, m_trace(rhs.m_trace)
200, m_internal(new
Impl(this))
201, m_allocation_info(rhs.m_allocation_info)
216DataStorageTypeInfo StringArrayData::
217staticStorageTypeInfo()
220 Int32 nb_basic_type = 0;
223 return DataStorageTypeInfo(bdt, nb_basic_type,
dimension, multi_tag);
232 return staticStorageTypeInfo();
241 ARCANE_UNUSED(use_basic_type);
245 Int64 needed_memory = 0;
248 for (
Integer i = 0; i < nb_element; ++i) {
251 needed_memory += len;
254 Int64 nb_base_element = needed_memory;
256 nb_base_element,
true, dimensions);
257 sd->allocateMemory(needed_memory);
263 for (
Integer i = 0; i < nb_element; ++i) {
267 for (
Int64 z = 0; z < len; ++z)
268 svalues[index + z] = str[z];
303 for (
Integer i = 0; i < nb_element; ++i) {
304 Int64 len = dimensions[i];
319 ARCANE_UNUSED(operation);
322 if (mode == ISerializer::ModeReserve) {
324 sbuf->reserveInteger(1);
325 for (
Integer z = 0; z < size; ++z)
331 for (
Integer z = 0; z < size; ++z)
339 for (
Integer z = 0; z < size; ++z)
358 ARCANE_UNUSED(operation);
380 s->computeHash(algo, output);
389 hash_info.setVersion(2);
401 const auto* true_data =
dynamic_cast<const DataInterfaceType*
>(data);
404 m_value.copy(true_data->view());
413 auto* true_data =
dynamic_cast<ThatClass*
>(data);
416 m_value.swap(true_data->m_value);
434 visitor->applyVisitor(
this);
#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.
Exception when an argument is invalid.
Modifiable view of an array of type T.
Base class for 1D data vectors.
Constant view of an array of type T.
constexpr Integer size() const noexcept
Number of elements in the array.
Information on data allocation.
Information for calculating data hash.
Information to construct an instance of 'IData'.
static void registerDataFactory(IDataFactoryMng *dfm)
Registers a factory for the data DataType in dfm.
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 1D array data item.
Interface of the data factory manager.
Interface of an operation on a data.
Interface of the visitor pattern for a data item.
Interface of a data item.
Context for calculating a hash incrementally.
virtual void updateHash(Span< const std::byte > input)=0
Adds the array input to the calculated hash.
Interface of a hashing algorithm.
Interface of the visitor pattern for a scalar data item.
Interface of a serialized data.
virtual eDataType baseDataType() const =0
Data type.
virtual Int64 memorySize() const =0
Indicates the number of bytes that must be allocated to store or read the data.
virtual void allocateMemory(Int64 size)=0
Allocates an array to hold the serialized elements.
virtual Int64ConstArrayView extents() const =0
Array containing the number of elements for each dimension.
virtual Span< const Byte > constBytes() const =0
Serialized values.
virtual void reserve(eBasicDataType dt, Int64 n)=0
Reserves memory for n objects of type dt.
virtual Integer getInteger()=0
Retrieve a size.
eMode
Serializer operating mode.
@ ModePut
The serializer expects reserve().
@ ModeGet
The serializer expects get().
virtual void putInteger(Integer value)=0
Add the integer value.
virtual void put(Span< const Real > values)=0
Add the array values.
virtual eReadMode readMode() const =0
Read mode.
virtual eMode mode() const =0
Current operating mode.
@ ReadReplace
Replace current elements with those read.
@ ReadAdd
Add those read to the current elements.
virtual void get(ArrayView< Real > values)=0
Retrieve the array values.
Exception when a function is not implemented.
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.
Integer capacity() const override
Capacity allocated by the container.
void dispose() override
Clears the container and frees allocated memory.
void resize(Integer new_size) override
Resizes the container.
void reserve(Integer new_capacity) override
Reserves memory for new_capacity elements.
void computeHash(DataHashInfo &hash_info) override
Calculates the hash of the data.
void shrink() const override
Frees additional allocated memory.
Array< DataType > & _internalDeprecatedValue() override
Container associated with the data.
Ref< IData > cloneEmptyRef() override
Clone the data but without elements.
void copy(const IData *data) override
Copy the data data into the current instance.
ArrayView< DataType > view() override
View on the data.
void setName(const String &name) override
Sets the name of the data (internal).
Ref< ISerializedData > createSerializedDataRef(bool use_basic_type) const override
Serialize the data.
void resize(Integer new_size) override
Resize the data.
Ref< IData > cloneRef() override
Clone the data.
void setShape(const ArrayShape &) override
Sets the array shape.
Integer multiTag() const override
Multi-tag. 0 if not multiple, 1 if multiple, 2 if multiple for MultiArray variables (obsolete).
void visitArray(IArrayDataVisitor *visitor) override
Apply the visitor to the data.
IArrayDataInternalT< DataType > * _internal() override
void assignSerializedData(const ISerializedData *sdata) override
Assign the serialized values sdata to the data.
Ref< DataInterfaceType > cloneTrueRef() override
Clone the data.
eDataType dataType() const override
Data type.
DataStorageTypeInfo storageTypeInfo() const override
Information about the data container type.
void visitScalar(IScalarDataVisitor *visitor) override
Apply 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.
ArrayShape shape() const override
Array shape for a 1D or 2D data item.
Array< DataType > & value() override
Data value.
void computeHash(IHashAlgorithm *algo, ByteArray &output) const override
Compute a hash key on this data.
void setAllocationInfo(const DataAllocationInfo &v) override
Sets the allocation information.
void visit(IArrayDataVisitor *visitor) override
Applies the visitor to the data.
IData * cloneEmpty() override
Clone the data but without elements. The created instance must be destroyed by the 'delete' operator.
void swapValues(IData *data) override
Swap the values of data with those of the instance.
void visit(IDataVisitor *visitor) override
Applies the visitor to the data.
UniqueArray< DataType > m_value
Data.
void serialize(ISerializer *sbuf, IDataOperation *operation) override
Serializes the data by applying the operation.
DataAllocationInfo allocationInfo() const override
Allocation information.
DataInterfaceType * cloneTrueEmpty() override
Clone the data but without elements.
DataInterfaceType * cloneTrue() override
Clone the data.
void fillDefault() override
Fills the data with its default value.
Ref< DataInterfaceType > cloneTrueEmptyRef() override
Clone the data but without elements.
void allocateBufferForSerializedData(ISerializedData *sdata) override
Allocate memory to read the serialized values sdata.
IDataInternal * _commonInternal() override
void visitArray2(IArray2DataVisitor *visitor) override
Apply the visitor to the data.
IData * clone() override
Clone the data. The created instance must be destroyed by the 'delete' operator.
const Array< DataType > & value() const override
Constant data value.
ConstArrayView< DataType > view() const override
Constant view on the data.
Unicode character string.
1D data vector with value semantics (STL style).
-- 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.
UniqueArray< Int64 > Int64UniqueArray
Dynamic 1D array of 64-bit integers.
std::int64_t Int64
Signed integer type of 64 bits.
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.
eBasicDataType
Type of a basic data item.
ConstArrayView< Int64 > Int64ConstArrayView
C equivalent of a 1D array of 64-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.
std::int32_t Int32
Signed integer type of 32 bits.