Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
VariableRefArray2.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/* VariableRefArray2.h (C) 2000-2025 */
9/* */
10/* Class managing a reference to a 2D array variable. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_VARIABLEREFARRAY2_H
13#define ARCANE_CORE_VARIABLEREFARRAY2_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/Array2View.h"
18#include "arcane/core/VariableRef.h"
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23namespace Arcane
24{
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29/*!
30 * \brief Two-dimensional array variable.
31 *
32 * This variable manages classic 2D arrays.
33 */
34template <typename T>
36: public VariableRef
37, public Array2View<T>
38{
39 public:
40
41 typedef T DataType;
42 typedef Array2<T> ValueType;
43 typedef ConstArrayView<T> ConstReturnReferenceType;
44 typedef ArrayView<T> ReturnReferenceType;
45
46 //! Type of the variable elements
47 typedef DataType ElementType;
48 //! Type of the base class
50 //! Type of the class managing the variable value
52 //! Type of the array used to access the variable
54
55 typedef Array2VariableT<DataType> PrivatePartType;
56
57 typedef VariableRefArray2T<DataType> ThatClass;
58
59 public:
60
61 //! Constructs a reference to a 2D array variable specified in \a vb
62 ARCANE_CORE_EXPORT VariableRefArray2T(const VariableBuildInfo& vb);
63 //! Constructs a reference from \a rhs
64 ARCANE_CORE_EXPORT VariableRefArray2T(const VariableRefArray2T<DataType>& rhs);
65 //! Constructs a reference from \a var
66 explicit ARCANE_CORE_EXPORT VariableRefArray2T(IVariable* var);
67 /*!
68 * \brief Copy assignment operator.
69 * \deprecated Use refersTo() instead.
70 */
71 ARCCORE_DEPRECATED_2021("Use refersTo() instead.")
72 ARCANE_CORE_EXPORT void operator=(const VariableRefArray2T<DataType>& rhs);
73 virtual ARCANE_CORE_EXPORT ~VariableRefArray2T(); //!< Frees resources
74
75 public:
76
77 /*!
78 * \brief Reallocates the number of elements in the first dimension of the array.
79 *
80 * The number of elements in the second dimension is set to zero.
81 * \warning reallocation does not preserve previous values.
82 */
83 virtual ARCANE_CORE_EXPORT void resize(Integer new_size);
84
85 /*!
86 * \brief Reallocates the number of elements in the array.
87 *
88 * Reallocates the array with \a dim1_size as the size of the first
89 * dimension and \a dim2_size as the size of the second.
90 * \warning reallocation does not preserve previous values.
91 */
92 ARCANE_CORE_EXPORT void resize(Integer dim1_size, Integer dim2_size);
93
94 //! Fills the variable with the value \a value
95 ARCANE_CORE_EXPORT void fill(const DataType& value);
96
97 //! Positions the instance reference to the variable \a rhs.
98 ARCANE_CORE_EXPORT void refersTo(const VariableRefArray2T<DataType>& rhs);
99
100 public:
101
102 virtual bool isArrayVariable() const { return true; }
103 virtual Integer arraySize() const { return this->dim1Size(); }
104 Integer size() const { return this->dim1Size(); }
105 virtual ARCANE_CORE_EXPORT void updateFromInternal();
106
107 /*!
108 \brief Returns the container of the variable's values.
109 *
110 Calling this method is only possible for private variables (PPrivate property).
111 */
112 ARCCORE_DEPRECATED_2021("Use _internalTrueData() instead.")
113 ARCANE_CORE_EXPORT ContainerType& internalContainer();
114
115 public:
116
117 //! \internal
118 ARCANE_CORE_EXPORT IArray2DataInternalT<T>* _internalTrueData();
119
120 public:
121
122 static ARCANE_CORE_EXPORT VariableTypeInfo _internalVariableTypeInfo();
123 static ARCANE_CORE_EXPORT VariableInfo _internalVariableInfo(const VariableBuildInfo& vbi);
124
125 private:
126
127 PrivatePartType* m_private_part;
128
129 private:
130
131 static VariableFactoryRegisterer m_auto_registerer;
132 static VariableRef* _autoCreate(const VariableBuildInfo& vb);
133};
134
135/*---------------------------------------------------------------------------*/
136/*---------------------------------------------------------------------------*/
137
138} // End namespace Arcane
139
140/*---------------------------------------------------------------------------*/
141/*---------------------------------------------------------------------------*/
142
143#endif
constexpr Array2View(T *ptr, Integer dim1_size, Integer dim2_size)
Class representing a classic 2D array.
Modifiable view of an array of type T.
Constant view of an array of type T.
Interface of a variable.
Definition IVariable.h:40
Parameters necessary for building a variable.
Information characterizing a variable.
void refersTo(const VariableRefArray2T< DataType > &rhs)
DataType ElementType
Type of the variable elements.
VariableRefArray2T(const VariableBuildInfo &vb)
Constructs a reference to a 2D array variable specified in vb.
virtual void resize(Integer new_size)
void fill(const DataType &value)
virtual Integer arraySize() const
If the variable is an array, returns its dimension, otherwise returns 0.
VariableRefArray2T(const VariableRefArray2T< DataType > &rhs)
Constructs a reference from rhs.
Array2< DataType > ContainerType
Type of the class managing the variable value.
VariableRef BaseClass
Type of the base class.
virtual void updateFromInternal()
Updates from the internal part.
VariableRefArray2T(IVariable *var)
Constructs a reference from var.
Array2View< DataType > ArrayBase
Type of the array used to access the variable.
VariableRef(const VariableBuildInfo &vbi)
Constructs a reference to a variable with the infos vbi.
Information characterizing the type of a variable.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.