Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
Arcane::ISerializedData Class Referenceabstract

Interface of a serialized data. More...

#include <arcane/core/ISerializedData.h>

Inheritance diagram for Arcane::ISerializedData:
Collaboration diagram for Arcane::ISerializedData:

Public Member Functions

virtual ~ISerializedData ()=default
 Frees resources.
virtual eDataType baseDataType () const =0
 Data type.
virtual Integer nbDimension () const =0
 Dimension. 0 for a scalar, 1 for a 1D array, ...
virtual Int64 nbElement () const =0
 Number of elements.
virtual Int64 nbBaseElement () const =0
 Number of base elements.
virtual bool isMultiSize () const =0
 Indicates if it is a multi-size array. (only relevant if nbDimension()>1).
virtual Int64 memorySize () const =0
 Indicates the number of bytes that must be allocated to store or read the data.
virtual Int64ConstArrayView extents () const =0
 Array containing the number of elements for each dimension.
virtual ArrayShape shape () const =0
 Shape of the array associated with the data.
virtual Span< const ByteconstBytes () const =0
 Serialized values.
virtual Span< BytewritableBytes ()=0
 View of the serialized values.
virtual void setWritableBytes (Span< Byte > bytes)=0
 Positions the serialized values.
virtual void setConstBytes (Span< const Byte > bytes)=0
 Positions the serialized values for reading.
virtual void allocateMemory (Int64 size)=0
 Allocates an array to hold the serialized elements.
virtual void serialize (ISerializer *buffer)=0
 Serialize the data for reading or writing.
virtual void serialize (ISerializer *buffer) const =0
 Serialize the data for reading.
virtual void computeHash (IHashAlgorithm *algo, ByteArray &output) const =0
 Compute a hash key on this data.
 ARCANE_DEPRECATED_2018_R ("Use method 'writableBytes()' or 'constBytes()' instead") virtual ByteConstArrayView buffer() const =0
 Serialized values.
 ARCANE_DEPRECATED_2018_R ("Use method 'writableBytes()' or 'constBytes()' instead") virtual ByteArrayView buffer()=0
 Serialized values.
virtual Span< const Bytebytes () const =0
 Serialized values.
virtual void setBuffer (ByteArrayView buffer)=0
 Positions the serialized values.
virtual void setBuffer (ByteConstArrayView buffer)=0
 Positions the serialized values.
virtual void setBytes (Span< Byte > bytes)=0
 Positions the serialized values.
virtual void setBytes (Span< const Byte > bytes)=0
 Positions the serialized values.
virtual Span< Bytebytes ()=0
 Serialized values.

Private Member Functions

 ARCCORE_DECLARE_REFERENCE_COUNTED_INCLASS_METHODS ()

Detailed Description

Interface of a serialized data.

A data (IData) is serialized into an instance of this class.

Regardless of the data type, the serialized type must be a base type among the following: DT_Byte, DT_Int16, DT_Int32, DT_Int64, DT_Real.

An instance of this class is only valid as long as the reference data is not modified.

To serialize a data data for writing:

IData* data = ...;
ISerializedData* sdata = data->createSerializedData();
// sdata->constBytes() contains the serialized data.
std::cout.write(reinterpret_cast<const char*>(buf.data()),buf.size());
Interface of a data item.
Definition IData.h:34
Interface of a serialized data.
virtual Span< const Byte > constBytes() const =0
Serialized values.
View of an array of elements of type T.
Definition Span.h:635

To serialize a data data for reading:

IData* data = ...
// Create an instance of an ISerializedData.
// Fills sdata->writableBytes() from your source
Span<Byte> buf(sdata->writableBytes());
std::cin.read(reinterpret_cast<char*>(buf.data()),buf.size());
// Assigns the value to \a data
data->assignSerializedData(sdata);
virtual void allocateBufferForSerializedData(ISerializedData *sdata)=0
Allocate memory to read the serialized values sdata.
virtual void assignSerializedData(const ISerializedData *sdata)=0
Assign the serialized values sdata to the data.
virtual Span< Byte > writableBytes()=0
View of the serialized values.
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.

Definition at line 62 of file ISerializedData.h.

Member Function Documentation

◆ allocateMemory()

virtual void Arcane::ISerializedData::allocateMemory ( Int64 size)
pure virtual

Allocates an array to hold the serialized elements.

After calling this method, it is possible to retrieve a view of the serialized values via writableBytes() or constBytes().

Implemented in Arcane::SerializedData.

Referenced by Arcane::StringArrayData::allocateBufferForSerializedData(), and Arcane::StringScalarData::allocateBufferForSerializedData().

Here is the caller graph for this function:

◆ ARCANE_DEPRECATED_2018_R() [1/2]

Arcane::ISerializedData::ARCANE_DEPRECATED_2018_R ( "Use method 'writableBytes()' or 'constBytes()' instead" )
pure virtual

Serialized values.

Deprecated
Use bytes() instead.

References ARCANE_DEPRECATED_2018_R().

Here is the call graph for this function:

◆ ARCANE_DEPRECATED_2018_R() [2/2]

Arcane::ISerializedData::ARCANE_DEPRECATED_2018_R ( "Use method 'writableBytes()' or 'constBytes()' instead" ) const
pure virtual

Serialized values.

Deprecated
Use bytes() instead.

Referenced by ARCANE_DEPRECATED_2018_R().

Here is the caller graph for this function:

◆ baseDataType()

◆ bytes() [1/2]

virtual Span< const Byte > Arcane::ISerializedData::bytes ( ) const
pure virtual

Serialized values.

Implemented in Arcane::SerializedData.

References bytes().

Referenced by bytes(), bytes(), setBytes(), setBytes(), setConstBytes(), and setWritableBytes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bytes() [2/2]

virtual Span< Byte > Arcane::ISerializedData::bytes ( )
pure virtual

Serialized values.

Warning
This method returns a non-empty view only if one has called setBytes(Span<Byte>) or allocateMemory().

Implemented in Arcane::SerializedData.

References Arcane::arcaneCreateEmptySerializedDataRef(), Arcane::arcaneCreateSerializedDataRef(), bytes(), and shape().

Here is the call graph for this function:

◆ computeHash()

virtual void Arcane::ISerializedData::computeHash ( IHashAlgorithm * algo,
ByteArray & output ) const
pure virtual

Compute a hash key on this data.

The key is added to output. The length of the key depends on the algorithm used.

Implemented in Arcane::SerializedData.

◆ constBytes()

virtual Span< const Byte > Arcane::ISerializedData::constBytes ( ) const
pure virtual

Serialized values.

Implemented in Arcane::SerializedData.

Referenced by Arcane::StringArrayData::assignSerializedData(), Arcane::StringScalarData::assignSerializedData(), and Arcane::impl::BasicGenericWriter::writeData().

Here is the caller graph for this function:

◆ extents()

virtual Int64ConstArrayView Arcane::ISerializedData::extents ( ) const
pure virtual

Array containing the number of elements for each dimension.

Implemented in Arcane::SerializedData.

Referenced by Arcane::Array2DataT< DataType >::allocateBufferForSerializedData(), Arcane::NumArrayDataT< DataType, RankValue >::allocateBufferForSerializedData(), Arcane::StringArrayData::assignSerializedData(), and Arcane::impl::BasicGenericWriter::writeData().

Here is the caller graph for this function:

◆ isMultiSize()

virtual bool Arcane::ISerializedData::isMultiSize ( ) const
pure virtual

Indicates if it is a multi-size array. (only relevant if nbDimension()>1).

Implemented in Arcane::SerializedData.

Referenced by Arcane::Array2DataT< DataType >::allocateBufferForSerializedData(), Arcane::NumArrayDataT< DataType, RankValue >::allocateBufferForSerializedData(), and Arcane::impl::BasicGenericWriter::writeData().

Here is the caller graph for this function:

◆ memorySize()

virtual Int64 Arcane::ISerializedData::memorySize ( ) const
pure virtual

◆ nbBaseElement()

virtual Int64 Arcane::ISerializedData::nbBaseElement ( ) const
pure virtual

Number of base elements.

Implemented in Arcane::SerializedData.

Referenced by Arcane::StringScalarData::assignSerializedData(), and Arcane::impl::BasicGenericWriter::writeData().

Here is the caller graph for this function:

◆ nbDimension()

virtual Integer Arcane::ISerializedData::nbDimension ( ) const
pure virtual

Dimension. 0 for a scalar, 1 for a 1D array, ...

Implemented in Arcane::SerializedData.

Referenced by Arcane::impl::BasicGenericWriter::writeData().

Here is the caller graph for this function:

◆ nbElement()

virtual Int64 Arcane::ISerializedData::nbElement ( ) const
pure virtual

Number of elements.

Implemented in Arcane::SerializedData.

Referenced by Arcane::ArrayDataT< DataType >::allocateBufferForSerializedData(), and Arcane::impl::BasicGenericWriter::writeData().

Here is the caller graph for this function:

◆ serialize() [1/2]

virtual void Arcane::ISerializedData::serialize ( ISerializer * buffer) const
pure virtual

Serialize the data for reading.

Implemented in Arcane::SerializedData.

◆ serialize() [2/2]

virtual void Arcane::ISerializedData::serialize ( ISerializer * buffer)
pure virtual

Serialize the data for reading or writing.

Implemented in Arcane::SerializedData.

Referenced by Arcane::Hdf5ReaderWriter::_writeValParallel().

Here is the caller graph for this function:

◆ setBuffer() [1/2]

virtual void Arcane::ISerializedData::setBuffer ( ByteArrayView buffer)
pure virtual

Positions the serialized values.

The array buffer must not be modified as long as this instance is used.

Deprecated
Use setBytes() instead.

Implemented in Arcane::SerializedData.

References setBuffer().

Referenced by setBuffer(), and setBuffer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setBuffer() [2/2]

virtual void Arcane::ISerializedData::setBuffer ( ByteConstArrayView buffer)
pure virtual

Positions the serialized values.

The array buffer must not be modified as long as this instance is used.

Deprecated
Use setBytes() instead.

Implemented in Arcane::SerializedData.

References setBuffer().

Here is the call graph for this function:

◆ setBytes() [1/2]

virtual void Arcane::ISerializedData::setBytes ( Span< Byte > bytes)
pure virtual

Positions the serialized values.

The array bytes must not be modified as long as this instance is used.

Implemented in Arcane::SerializedData.

References bytes(), and setBytes().

Referenced by setBytes(), and setBytes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setBytes() [2/2]

virtual void Arcane::ISerializedData::setBytes ( Span< const Byte > bytes)
pure virtual

Positions the serialized values.

The array bytes must not be modified as long as this instance is used.

Implemented in Arcane::SerializedData.

References bytes(), and setBytes().

Here is the call graph for this function:

◆ setConstBytes()

virtual void Arcane::ISerializedData::setConstBytes ( Span< const Byte > bytes)
pure virtual

Positions the serialized values for reading.

The view bytes must remain valid as long as this instance is used.

Implemented in Arcane::SerializedData.

References bytes().

Here is the call graph for this function:

◆ setWritableBytes()

virtual void Arcane::ISerializedData::setWritableBytes ( Span< Byte > bytes)
pure virtual

Positions the serialized values.

The view bytes must remain valid as long as this instance is used.

Implemented in Arcane::SerializedData.

References bytes().

Referenced by Arcane::Array2DataT< DataType >::allocateBufferForSerializedData(), Arcane::ArrayDataT< DataType >::allocateBufferForSerializedData(), Arcane::NumArrayDataT< DataType, RankValue >::allocateBufferForSerializedData(), and Arcane::ScalarDataT< DataType >::allocateBufferForSerializedData().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ shape()

virtual ArrayShape Arcane::ISerializedData::shape ( ) const
pure virtual

Shape of the array associated with the data.

Implemented in Arcane::SerializedData.

Referenced by Arcane::Array2DataT< DataType >::allocateBufferForSerializedData(), Arcane::ArrayDataT< DataType >::allocateBufferForSerializedData(), and bytes().

Here is the caller graph for this function:

◆ writableBytes()

virtual Span< Byte > Arcane::ISerializedData::writableBytes ( )
pure virtual

View of the serialized values.

Warning
This method returns a non-empty view only if one has called allocateMemory() or setWritableBytes(Span<Byte>) beforehand.

Implemented in Arcane::SerializedData.


The documentation for this class was generated from the following file: