Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
VariableRefArray.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/* VariableRefArray.h (C) 2000-2025 */
9/* */
10/* Class managing a reference to a 1D array variable. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_VARIABLEREFARRAY_H
13#define ARCANE_CORE_VARIABLEREFARRAY_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/core/VariableRef.h"
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace Arcane
23{
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28template <typename DataType> class VariableRefArrayLockT;
29
30/*---------------------------------------------------------------------------*/
31/*---------------------------------------------------------------------------*/
32
33/*!
34 * \brief Array variable.
35 */
36template <typename T>
38: public VariableRef
39, public ArrayView<T>
40{
41 public:
42
43 typedef T DataType;
44 typedef Array<T> ValueType;
45 typedef typename ArrayView<T>::const_reference ConstReturnReferenceType;
46 typedef typename ArrayView<T>::reference ReturnReferenceType;
47
48 //! Type of the variable elements
49 typedef DataType ElementType;
50 //! Type of the base class
52 //! Type of the class managing the variable value
54 //! Type of the array allowing access to the variable
56
57 typedef VariableArrayT<DataType> PrivatePartType;
58
59 typedef VariableRefArrayT<DataType> ThatClass;
60
61 typedef VariableRefArrayLockT<DataType> LockType;
62
63 public:
64
65 //! Constructs a reference to a 1D array variable specified in \a vb
66 ARCANE_CORE_EXPORT explicit VariableRefArrayT(const VariableBuildInfo& vb);
67 //! Constructs a reference from \a rhs
68 ARCANE_CORE_EXPORT VariableRefArrayT(const VariableRefArrayT<DataType>& rhs);
69 //! Constructs a reference from \a var
70 explicit ARCANE_CORE_EXPORT VariableRefArrayT(IVariable* var);
71
72 //! Positions the instance's reference to the variable \a rhs.
73 ARCANE_CORE_EXPORT void refersTo(const VariableRefArrayT<DataType>& rhs);
74
75 ARCANE_CORE_EXPORT ~VariableRefArrayT() override; //!< Frees resources
76
77 public:
78
79 //! Resizes the array to contain \a new_size elements
80 virtual ARCANE_CORE_EXPORT void resize(Integer new_size);
81
82 //! Resizes the array to contain \a new_size elements
83 virtual ARCANE_CORE_EXPORT void resizeWithReserve(Integer new_size, Integer nb_additional);
84
85 public:
86
87 virtual bool isArrayVariable() const { return true; }
88 Integer arraySize() const override { return this->size(); }
89 ARCANE_CORE_EXPORT void updateFromInternal() override;
90
91 public:
92
93 ArrayView<DataType> asArray() { return (*this); }
94 ConstArrayView<DataType> asArray() const { return (*this); }
95
96 public:
97
98 ARCCORE_DEPRECATED_2021("This method is internal to Arcane")
99 LockType ARCANE_CORE_EXPORT lock();
100
101 public:
102
103 /*!
104 \brief Returns the container of this variable's values.
105 *
106 Calling this method is only possible for private variables
107 (PPrivate property). For others, an exception is
108 raised (you must use lock()).
109 */
110 ARCCORE_DEPRECATED_2021("Use _internalTrueData() instead.")
111 ARCANE_CORE_EXPORT ContainerType& internalContainer();
112
113 public:
114
115 //! \internal
116 ARCANE_CORE_EXPORT IArrayDataInternalT<T>* _internalTrueData();
117
118 public:
119
120 static ARCANE_CORE_EXPORT VariableTypeInfo _internalVariableTypeInfo();
121 static ARCANE_CORE_EXPORT VariableInfo _internalVariableInfo(const VariableBuildInfo& vbi);
122
123 private:
124
125 PrivatePartType* m_private_part;
126
127 private:
128
129 static VariableFactoryRegisterer m_auto_registerer;
130 static VariableRef* _autoCreate(const VariableBuildInfo& vb);
131};
132
133/*---------------------------------------------------------------------------*/
134/*---------------------------------------------------------------------------*/
135
136} // End namespace Arcane
137
138/*---------------------------------------------------------------------------*/
139/*---------------------------------------------------------------------------*/
140
141#endif
constexpr ArrayView() noexcept
Constructs an empty view.
const value_type & const_reference
Constant reference type of an array element.
value_type & reference
Reference type of an array element.
constexpr Integer size() const noexcept
Returns the size of the array.
Base class for 1D data vectors.
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 updateFromInternal() override
Updates from the internal part.
VariableRefArrayT(const VariableRefArrayT< DataType > &rhs)
Constructs a reference from rhs.
Integer arraySize() const override
If the variable is an array, returns its dimension, otherwise returns 0.
VariableRefArrayT(IVariable *var)
Constructs a reference from var.
DataType ElementType
Type of the variable elements.
VariableRefArrayT(const VariableBuildInfo &vb)
Constructs a reference to a 1D array variable specified in vb.
virtual void resizeWithReserve(Integer new_size, Integer nb_additional)
Resizes the array to contain new_size elements.
ArrayView< DataType > ArrayBase
Type of the array allowing access to the variable.
~VariableRefArrayT() override
Frees resources.
virtual void resize(Integer new_size)
Resizes the array to contain new_size elements.
Array< DataType > ContainerType
Type of the class managing the variable value.
VariableRef BaseClass
Type of the base class.
void refersTo(const VariableRefArrayT< DataType > &rhs)
Positions the instance's reference to the variable rhs.
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.