16#include "arcane/utils/NotSupportedException.h"
17#include "arcane/utils/ArgumentException.h"
18#include "arcane/utils/TraceInfo.h"
19#include "arcane/utils/IHashAlgorithm.h"
20#include "arcane/utils/NotImplementedException.h"
21#include "arcane/utils/Real2.h"
22#include "arcane/utils/Real3.h"
23#include "arcane/utils/Real2x2.h"
24#include "arcane/utils/Real3x3.h"
25#include "arcane/utils/ArrayShape.h"
26#include "arcane/utils/Array.h"
27#include "arcane/utils/String.h"
28#include "arcane/utils/Ref.h"
30#include "arcane/core/IDataFactory.h"
31#include "arcane/core/IData.h"
32#include "arcane/core/IDataVisitor.h"
34#include "arcane/core/datatype/DataAllocationInfo.h"
35#include "arcane/core/datatype/DataStorageTypeInfo.h"
36#include "arcane/core/datatype/DataStorageBuildInfo.h"
37#include "arcane/core/datatype/DataTypeTraits.h"
39#include "arcane/impl/ScalarData.h"
40#include "arcane/impl/SerializedData.h"
41#include "arcane/impl/DataStorageFactory.h"
43#include "arcane/core/ISerializer.h"
44#include "arcane/core/internal/IDataInternal.h"
58template <
class DataType>
67 typedef ScalarDataT<DataType> ThatClass;
77 explicit Internal(ScalarDataT<DataType>* p)
85 m_p->computeHash(hash_info);
90 ScalarDataT<DataType>* m_p =
nullptr;
100 explicit ScalarDataT(
const DataStorageBuildInfo& dsbi);
101 ScalarDataT(
const ScalarDataT<DataType>& rhs)
103 , m_trace(rhs.m_trace)
105 , m_allocation_info(rhs.m_allocation_info)
123 DataInterfaceType*
cloneTrue()
override {
return _cloneTrue(); }
127 auto* d = _cloneTrue();
132 auto* d = _cloneTrueEmpty();
150 visitor->applyVisitor(
this);
154 visitor->applyDataVisitor(
this);
175 DataInterfaceType* _cloneTrue()
const {
return new ThatClass(*
this); }
176 DataInterfaceType* _cloneTrueEmpty()
const {
return new ThatClass(m_trace); }
185, m_trace(dsbi.traceMng())
193template <
typename DataType>
199 Int32 nb_basic_type = TraitsType::nbBasicType();
208template <
typename DataType>
212 return staticStorageTypeInfo();
218template <
typename DataType>
226 Integer type_size =
sizeof(DataType);
228 if (use_basic_type) {
231 type_size =
sizeof(BasicType);
235 Integer nb_base_element = nb_element * nb_count;
236 Integer full_size = nb_base_element * type_size;
239 dimensions.
add(nb_element);
241 nb_base_element,
false, dimensions);
242 sd->setConstBytes(base_values);
249template <
typename DataType>
258 if (data_type !=
dataType() && data_type != base_data_type)
268template <
typename DataType>
278template <
typename DataType>
290 if (mode == ISerializer::ModeReserve)
301template <
typename DataType>
311template <
typename DataType>
321template <
typename DataType>
330template <
typename DataType>
334 Integer type_size =
sizeof(DataType);
343template <
typename DataType>
347 hash_info.setVersion(2);
355template <
typename DataType>
359 const DataInterfaceType* true_data =
dynamic_cast<const DataInterfaceType*
>(data);
368template <
typename DataType>
372 DataInterfaceType* true_data =
dynamic_cast<DataInterfaceType*
>(data);
381template <
typename DataType>
385 visitor->applyVisitor(
this);
391template <
typename DataType>
401template <
typename DataType>
411template <
typename DataType>
421template <
typename DataType>
451ARCANE_INTERNAL_INSTANTIATE_TEMPLATE_FOR_NUMERIC_DATATYPE(ScalarDataT);
#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.
constexpr Integer size() const noexcept
Returns the size of the array.
void add(ConstReferenceType val)
Adds element val to the end of the array.
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'.
Type information for a data container.
Interface of the visitor pattern for a 2D array data item.
Interface of the visitor pattern for an 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.
virtual void updateHash(Span< const std::byte > input)=0
Adds the array input to the calculated hash.
Interface of a hashing algorithm.
virtual void computeHash64(Span< const Byte > input, ByteArray &output)
Calculates the hash value for the array input.
Interface of a scalar data item of type T.
virtual DataType & value()=0
Data value.
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 setWritableBytes(Span< Byte > bytes)=0
Positions the serialized values.
eMode
Serializer operating mode.
@ ModePut
The serializer expects reserve().
@ ModeGet
The serializer expects get().
virtual void putSpan(Span< const Real > values)
Add the array values.
virtual eMode mode() const =0
Current operating mode.
virtual void getSpan(Span< Real > values)
Retrieve the array values.
virtual void reserveSpan(eBasicDataType dt, Int64 n)=0
Reserves memory for n values of dt.
Exception when an operation is not supported.
Reference to an instance.
Thread-safe implementation of a reference counter.
void computeHash(DataHashInfo &hash_info) override
Calculates the hash of the data.
DataType & value() override
Data value.
void assignSerializedData(const ISerializedData *sdata) override
Assign the serialized values sdata to the data.
ArrayShape shape() const override
Array shape for a 1D or 2D data item.
void setShape(const ArrayShape &) override
Sets the array shape.
DataInterfaceType * cloneTrueEmpty() override
Clone the data but without elements.
void setAllocationInfo(const DataAllocationInfo &v) override
Sets the allocation information.
Ref< IData > cloneEmptyRef() override
Clone the data but without elements.
void copy(const IData *data) override
Copy the data data into the current instance.
void resize(Integer) override
Resize the data.
IDataInternal * _commonInternal() override
void setName(const String &name) override
Sets the name of the data (internal).
DataInterfaceType * cloneTrue() override
Clone the data.
void visit(IDataVisitor *visitor) override
Applies the visitor to the data.
void visitArray2(IArray2DataVisitor *visitor) override
Apply the visitor to the data.
void fillDefault() override
Fills the data with its default value.
IData * cloneEmpty() override
Clone the data but without elements. The created instance must be destroyed by the 'delete' operator.
const DataType & value() const override
Data value.
Integer multiTag() const override
Multi-tag. 0 if not multiple, 1 if multiple, 2 if multiple for MultiArray variables (obsolete).
DataAllocationInfo allocationInfo() const override
Allocation information.
void swapValues(IData *data) override
Swap the values of data with those of the instance.
Integer dimension() const override
Dimension. 0 for a scalar, 1 for a mono-dim array, 2 for a bi-dim array.
void serialize(ISerializer *sbuf, IDataOperation *operation) override
Serializes the data by applying the operation.
void computeHash(IHashAlgorithm *algo, ByteArray &output) const override
Compute a hash key on this data.
void visitArray(IArrayDataVisitor *visitor) override
Apply the visitor to the data.
Ref< DataInterfaceType > cloneTrueRef() override
Clone the data.
Ref< DataInterfaceType > cloneTrueEmptyRef() override
Clone the data but without elements.
IData * clone() override
Clone the data. The created instance must be destroyed by the 'delete' operator.
Ref< ISerializedData > createSerializedDataRef(bool use_basic_type) const override
Serialize the data.
eDataType dataType() const override
Data type.
Ref< IData > cloneRef() override
Clone the data.
DataStorageTypeInfo storageTypeInfo() const override
Information about the data container type.
void visit(IScalarDataVisitor *visitor) override
Applies the visitor to the data.
void allocateBufferForSerializedData(ISerializedData *sdata) override
Allocate memory to read the serialized values sdata.
void visitScalar(IScalarDataVisitor *visitor) override
Apply the visitor to the data.
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 --
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.
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.
Impl::SpanTypeFromSize< conststd::byte, SizeType >::SpanType asBytes(const SpanImpl< DataType, SizeType, Extent > &s)
Converts the view into an array of non-modifiable bytes.
ConstArrayView< Byte > ByteConstArrayView
C equivalent of a 1D array of characters.
unsigned char Byte
Type of a byte.
auto makeRef(InstanceType *t) -> Ref< InstanceType >
Creates a reference on a pointer.
std::int32_t Int32
Signed integer type of 32 bits.