Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
IData.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* IData.h (C) 2000-2025 */
9/* */
10/* Interface of a data item. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_IDATA_H
13#define ARCANE_CORE_IDATA_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace Arcane
23{
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
33class ARCANE_CORE_EXPORT IData
34{
36
37 public:
38
39 virtual ~IData() = default;
40
41 public:
42
44 virtual eDataType dataType() const = 0;
45
47 virtual Integer dimension() const = 0;
48
50 virtual Integer multiTag() const = 0;
51
53 ARCCORE_DEPRECATED_2020("Use cloneRef() instead")
54 virtual IData* clone() = 0;
55
57 ARCCORE_DEPRECATED_2020("Use cloneEmptyRef() instead")
58 virtual IData* cloneEmpty() = 0;
59
61 virtual Ref<IData> cloneRef() = 0;
62
64 virtual Ref<IData> cloneEmptyRef() = 0;
65
68
70 virtual void serialize(ISerializer* sbuf, IDataOperation* operation) = 0;
71
79 virtual void resize(Integer new_size) = 0;
80
86 virtual void serialize(ISerializer* sbuf, Int32ConstArrayView ids, IDataOperation* operation) = 0;
87
89 virtual void fillDefault() = 0;
90
92 virtual void setName(const String& name) = 0;
93
107 virtual Ref<ISerializedData> createSerializedDataRef(bool use_basic_type) const = 0;
108
115 virtual void assignSerializedData(const ISerializedData* sdata) = 0;
116
124
130 virtual void copy(const IData* data) = 0;
131
139 virtual void swapValues(IData* data) = 0;
140
147 virtual void computeHash(IHashAlgorithm* algo, ByteArray& output) const = 0;
148
163 virtual ArrayShape shape() const = 0;
164
166 virtual void setShape(const ArrayShape& new_shape) = 0;
167
168 public:
169
171 virtual void setAllocationInfo(const DataAllocationInfo& v) = 0;
172
175
176 public:
177
179 virtual void visit(IDataVisitor* visitor) = 0;
180
187 virtual void visitScalar(IScalarDataVisitor* visitor) = 0;
188
195 virtual void visitArray(IArrayDataVisitor* visitor) = 0;
196
203 virtual void visitArray2(IArray2DataVisitor* visitor) = 0;
204
214 virtual void visitMultiArray2(IMultiArray2DataVisitor* visitor);
215
218};
219
220/*---------------------------------------------------------------------------*/
221/*---------------------------------------------------------------------------*/
222
227: public IData
228{
229 public:
230
231 virtual void visit(IDataVisitor* visitor) = 0;
233 virtual void visit(IScalarDataVisitor* visitor) = 0;
234};
235
236/*---------------------------------------------------------------------------*/
237/*---------------------------------------------------------------------------*/
238
243template <class DataType>
245: public IScalarData
246{
247 public:
248
249 typedef IScalarDataT<DataType> ThatClass;
250
251 public:
252
254 virtual DataType& value() = 0;
255
257 virtual const DataType& value() const = 0;
258
260 ARCCORE_DEPRECATED_2020("Use cloneTrueRef() instead")
261 virtual ThatClass* cloneTrue() = 0;
262
264 ARCCORE_DEPRECATED_2020("Use cloneTrueEmpty() instead")
265 virtual ThatClass* cloneTrueEmpty() = 0;
266
268 virtual Ref<ThatClass> cloneTrueRef() = 0;
269
271 virtual Ref<ThatClass> cloneTrueEmptyRef() = 0;
272};
273
274/*---------------------------------------------------------------------------*/
275/*---------------------------------------------------------------------------*/
276
281: public IData
282{
283 public:
284
285 virtual void visit(IDataVisitor* visitor) = 0;
287 virtual void visit(IArrayDataVisitor* visitor) = 0;
288};
289
290/*---------------------------------------------------------------------------*/
291/*---------------------------------------------------------------------------*/
292
297template <class DataType>
299: public IArrayData
300{
301 public:
302
303 typedef IArrayDataT<DataType> ThatClass;
304
305 public:
306
308 ARCCORE_DEPRECATED_2021("Use view() instead.")
309 virtual Array<DataType>& value() = 0;
310
312 ARCCORE_DEPRECATED_2021("Use view() instead.")
313 virtual const Array<DataType>& value() const = 0;
314
315 public:
316
318 virtual ConstArrayView<DataType> view() const = 0;
319
321 virtual ArrayView<DataType> view() = 0;
322
324 ARCCORE_DEPRECATED_2020("Use cloneTrueRef() instead")
325 virtual ThatClass* cloneTrue() = 0;
326
328 ARCCORE_DEPRECATED_2020("Use cloneTrueEmptyRef() instead")
329 virtual ThatClass* cloneTrueEmpty() = 0;
330
332 virtual Ref<ThatClass> cloneTrueRef() = 0;
333
335 virtual Ref<ThatClass> cloneTrueEmptyRef() = 0;
336
338 virtual IArrayDataInternalT<DataType>* _internal() = 0;
339};
340
341/*---------------------------------------------------------------------------*/
342/*---------------------------------------------------------------------------*/
343
348: public IData
349{
350};
351
352/*---------------------------------------------------------------------------*/
353/*---------------------------------------------------------------------------*/
354
360: public IData
361{
362};
363
364/*---------------------------------------------------------------------------*/
365/*---------------------------------------------------------------------------*/
366
371template <class DataType>
373: public IArray2Data
374{
375 public:
376
377 typedef IArray2DataT<DataType> ThatClass;
378
380 ARCCORE_DEPRECATED_2021("Use view() instead.")
381 virtual Array2<DataType>& value() = 0;
382
384 ARCCORE_DEPRECATED_2021("Use view() instead.")
385 virtual const Array2<DataType>& value() const = 0;
386
387 public:
388
390 virtual ConstArray2View<DataType> view() const = 0;
391
393 virtual Array2View<DataType> view() = 0;
394
396 ARCCORE_DEPRECATED_2020("Use cloneTrueRef() instead")
397 virtual ThatClass* cloneTrue() = 0;
398
400 ARCCORE_DEPRECATED_2020("Use cloneTrueEmptyRef() instead")
401 virtual ThatClass* cloneTrueEmpty() = 0;
402
404 virtual Ref<ThatClass> cloneTrueRef() = 0;
405
407 virtual Ref<ThatClass> cloneTrueEmptyRef() = 0;
408
410 virtual IArray2DataInternalT<DataType>* _internal() = 0;
411};
412
413/*---------------------------------------------------------------------------*/
414/*---------------------------------------------------------------------------*/
415
421template <class DataType>
423: public IMultiArray2Data
424{
425 public:
426
427 typedef IMultiArray2DataT<DataType> ThatClass;
428
431
433 virtual const MultiArray2<DataType>& value() const = 0;
434
436 virtual ThatClass* cloneTrue() = 0;
437
439 virtual ThatClass* cloneTrueEmpty() = 0;
440};
441
442/*---------------------------------------------------------------------------*/
443/*---------------------------------------------------------------------------*/
444
445} // End namespace Arcane
446
447/*---------------------------------------------------------------------------*/
448/*---------------------------------------------------------------------------*/
449
450#endif
Declarations of Arcane's general types.
#define ARCCORE_DECLARE_REFERENCE_COUNTED_INCLASS_METHODS()
Macro to declare the virtual methods managing reference counters.
Class representing a classic 2D array.
Array shape.
Definition ArrayShape.h:42
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.
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.
Definition IData.h:374
virtual Ref< ThatClass > cloneTrueRef()=0
virtual Array2< T > & value()=0
virtual IArray2DataInternalT< T > * _internal()=0
virtual ThatClass * cloneTrue()=0
virtual ConstArray2View< T > view() const=0
virtual Ref< ThatClass > cloneTrueEmptyRef()=0
virtual ThatClass * cloneTrueEmpty()=0
Interface of the visitor pattern for a 2D array data item.
Interface of a 2D array data item.
Definition IData.h:349
Interface for an array data of type T.
Interface of a 1D array data item of type T.
Definition IData.h:300
virtual IArrayDataInternalT< T > * _internal()=0
virtual ThatClass * cloneTrueEmpty()=0
virtual ThatClass * cloneTrue()=0
virtual Ref< ThatClass > cloneTrueRef()=0
virtual Ref< ThatClass > cloneTrueEmptyRef()=0
virtual ConstArrayView< T > view() const=0
virtual Array< T > & value()=0
Interface of the visitor pattern for an array data item.
Interface of a 1D array data item.
Definition IData.h:282
virtual void visit(IDataVisitor *visitor)=0
Applies the visitor to the data.
virtual void visit(IArrayDataVisitor *visitor)=0
Applies the visitor to the data.
Internal part of IData.
Interface of an operation on a data.
Interface of the visitor pattern for a data item.
Interface of a data item.
Definition IData.h:34
virtual Ref< ISerializedData > createSerializedDataRef(bool use_basic_type) const =0
Serialize the data.
virtual void allocateBufferForSerializedData(ISerializedData *sdata)=0
Allocate memory to read the serialized values sdata.
virtual void copy(const IData *data)=0
Copy the data data into the current instance.
virtual DataAllocationInfo allocationInfo() const =0
Allocation information.
virtual void serialize(ISerializer *sbuf, IDataOperation *operation)=0
Serializes the data by applying the operation.
virtual IData * clone()=0
Clone the data. The created instance must be destroyed by the 'delete' operator.
virtual void swapValues(IData *data)=0
Swap the values of data with those of the instance.
virtual IData * cloneEmpty()=0
Clone the data but without elements. The created instance must be destroyed by the 'delete' operator.
virtual void computeHash(IHashAlgorithm *algo, ByteArray &output) const =0
Compute a hash key on this data.
virtual void visitArray2(IArray2DataVisitor *visitor)=0
Apply the visitor to the data.
virtual void setName(const String &name)=0
Sets the name of the data (internal).
virtual IDataInternal * _commonInternal()=0
virtual void visit(IDataVisitor *visitor)=0
Applies the visitor to the data.
virtual Integer dimension() const =0
Dimension. 0 for a scalar, 1 for a mono-dim array, 2 for a bi-dim array.
virtual void visitArray(IArrayDataVisitor *visitor)=0
Apply the visitor to the data.
virtual Integer multiTag() const =0
Multi-tag. 0 if not multiple, 1 if multiple, 2 if multiple for MultiArray variables (obsolete).
virtual void fillDefault()=0
Fills the data with its default value.
virtual void setAllocationInfo(const DataAllocationInfo &v)=0
Sets the allocation information.
virtual void visitMultiArray2(IMultiArray2DataVisitor *visitor)
Apply the visitor to the data.
Definition core/Data.cc:56
virtual Ref< IData > cloneRef()=0
Clone the data.
virtual void visitScalar(IScalarDataVisitor *visitor)=0
Apply the visitor to the data.
virtual eDataType dataType() const =0
Data type.
virtual Ref< IData > cloneEmptyRef()=0
Clone the data but without elements.
virtual void resize(Integer new_size)=0
Resize the data.
virtual void setShape(const ArrayShape &new_shape)=0
Sets the array shape.
virtual void assignSerializedData(const ISerializedData *sdata)=0
Assign the serialized values sdata to the data.
virtual DataStorageTypeInfo storageTypeInfo() const =0
Information about the data container type.
virtual ArrayShape shape() const =0
Array shape for a 1D or 2D data item.
Interface of a hashing algorithm.
Interface of a multi-sized 2D array data item of type T.
Definition IData.h:424
virtual ThatClass * cloneTrue()=0
Clone the data.
virtual ThatClass * cloneTrueEmpty()=0
Clone the data but without elements.
virtual const MultiArray2< DataType > & value() const =0
Data value.
virtual MultiArray2< DataType > & value()=0
Data value.
Interface of the visitor pattern for a variable-sized 2D array data item.
Interface of a multi 2D array data item.
Definition IData.h:361
Interface of a scalar data item of type T.
Definition IData.h:246
virtual ThatClass * cloneTrue()=0
virtual DataType & value()=0
Data value.
virtual Ref< ThatClass > cloneTrueRef()=0
virtual ThatClass * cloneTrueEmpty()=0
virtual const DataType & value() const =0
Data value.
virtual Ref< ThatClass > cloneTrueEmptyRef()=0
Interface of the visitor pattern for a scalar data item.
Interface of a scalar data item.
Definition IData.h:228
virtual void visit(IDataVisitor *visitor)=0
Applies the visitor to the data.
virtual void visit(IScalarDataVisitor *visitor)=0
Applies the visitor to the data.
Interface of a serialized data.
Base class for multi-sized 2D arrays.
Definition MultiArray2.h:60
Reference to an instance.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
Array< Byte > ByteArray
Dynamic one-dimensional array of characters.
Definition UtilsTypes.h:121
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
Definition UtilsTypes.h:482
eDataType
Data type.
Definition DataTypes.h:41