Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
Properties.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/* Properties.h (C) 2000-2025 */
9/* */
10/* List of properties. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_PROPERTIES_H
13#define ARCANE_CORE_PROPERTIES_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
18#include "arcane/utils/AutoRef.h"
19#include "arcane/core/SharedReference.h"
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25namespace Arcane
26{
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
31class PropertiesImpl;
32class IPropertyMng;
33
35: public SharedReference
36{
37};
38
39/*---------------------------------------------------------------------------*/
40/*---------------------------------------------------------------------------*/
41
42/*!
43 * \brief List of properties.
44 *
45 * This class manages a list of properties. A property is
46 * characterized by a name and a value of a given type.
47 * The name must not contain the character '.' which serves as a delimiter
48 * for property hierarchies.
49 *
50 * The set*() functions allow positioning a property. The
51 * get*() functions allow retrieving the value.
52 *
53 * For scalar properties, there are three ways to retrieve a
54 * value. These three methods are equivalent unless the property has not been set.
55 * - via an overload of the get() method. If the property has not been set,
56 * the passed argument value is unchanged and the method returns false.
57 * - via an explicit call (e.g., getBool()). If the property has not been set,
58 * the value obtained with the default constructor for the relevant type is used.
59 * - via an explicit call with a possible default value (e.g., getBoolWithDefault()).
60 * If the property has not been set, the default value passed as an argument is
61 * used.
62 *
63 */
64class ARCANE_CORE_EXPORT Properties
65{
66 public:
67
68 //! Creates or retrieves a list of properties with name \a name
70
71 //! Creates or retrieves a list of properties with name \a name and child of \a parent_property
72 Properties(const Properties& parent_property, const String& name);
73
74 //! Copy constructor
75 Properties(const Properties& rhs);
76 //! Copy assignment operator
77 const Properties& operator=(const Properties& rhs);
78 //! Destroys the reference to this property
79 virtual ~Properties();
80
81 public:
82
83 //! Sets a boolean property of name \a name and value \a value.
84 void setBool(const String& name, bool value);
85
86 //! Sets a boolean property of name \a name and value \a value.
87 void set(const String& name, bool value);
88
89 //! Value of the property named \a name.
90 bool getBool(const String& name) const;
91
92 //! Value of the property named \a name.
93 bool getBoolWithDefault(const String& name, bool default_value) const;
94
95 //! Value of the property named \a name.
96 bool get(const String& name, bool& value) const;
97
98 //! Sets an Int32 property of name \a name and value \a value.
99 void setInt32(const String& name, Int32 value);
100
101 //! Sets an Int32 property of name \a name and value \a value.
102 void set(const String& name, Int32 value);
103
104 //! Value of the property named \a name.
105 Int32 getInt32(const String& name) const;
106
107 //! Value of the property named \a name.
108 Int32 getInt32WithDefault(const String& name, Int32 default_value) const;
109
110 //! Value of the property named \a name.
111 bool get(const String& name, Int32& value) const;
112
113 //! Sets an Int64 property of name \a name and value \a value.
114 void setInt64(const String& name, Int64 value);
115
116 //! Sets an Int64 property of name \a name and value \a value.
117 void set(const String& name, Int64 value);
118
119 //! Value of the property named \a name.
120 Int64 getInt64(const String& name) const;
121
122 //! Value of the property named \a name.
123 Int64 getInt64WithDefault(const String& name, Int64 default_value) const;
124
125 //! Value of the property named \a name.
126 bool get(const String& name, Int64& value) const;
127
128 //! Sets an Integer property of name \a name and value \a value.
129 void setInteger(const String& name, Integer value);
130
131 //! Value of the property named \a name.
132 Integer getInteger(const String& name) const;
133
134 //! Value of the property named \a name.
135 Integer getIntegerWithDefault(const String& name, Integer default_value) const;
136
137 //! Sets a Real property of name \a name and value \a value.
138 void setReal(const String& name, Real value);
139
140 //! Sets a Real property of name \a name and value \a value.
141 void set(const String& name, Real value);
142
143 //! Value of the property named \a name.
144 Real getReal(const String& name) const;
145
146 //! Value of the property named \a name.
147 Real getRealWithDefault(const String& name, Real default_value) const;
148
149 //! Value of the property named \a name.
150 bool get(const String& name, Real& value) const;
151
152 //! Sets a String property of name \a name and value \a value.
153 void setString(const String& name, const String& value);
154
155 //! Sets a String property of name \a name and value \a value.
156 void set(const String& name, const String& value);
157
158 //! Value of the property named \a name.
159 String getString(const String& name) const;
160
161 //! Value of the property named \a name.
162 String getStringWithDefault(const String& name, const String& default_value) const;
163
164 //! Value of the property named \a name.
165 bool get(const String& name, String& value) const;
166
167 //! Sets a BoolUniqueArray property of name \a name and value \a value.
168 void set(const String& name, BoolConstArrayView value);
169
170 //! Value of the property named \a name.
171 void get(const String& name, BoolArray& value) const;
172
173 //! Sets an Int32UniqueArray property of name \a name and value \a value.
174 void set(const String& name, Int32ConstArrayView value);
175
176 //! Value of the property named \a name.
177 void get(const String& name, Int32Array& value) const;
178
179 //! Sets an Int64UniqueArray property of name \a name and value \a value.
180 void set(const String& name, Int64ConstArrayView value);
181
182 //! Value of the property named \a name.
183 void get(const String& name, Int64Array& value) const;
184
185 //! Sets a RealUniqueArray property of name \a name and value \a value.
186 void set(const String& name, RealConstArrayView value);
187
188 //! Value of the property named \a name.
189 void get(const String& name, RealArray& value) const;
190
191 //! Sets a StringUniqueArray property of name \a name and value \a value.
192 void set(const String& name, StringConstArrayView value);
193
194 //! Value of the property named \a name.
195 void get(const String& name, StringArray& value) const;
196
197 public:
198
199 //! Prints the properties and their values to the stream \a o
200 void print(std::ostream& o) const;
201
202 //! Performs the serialization of the properties
203 void serialize(ISerializer* serializer);
204
205 //! Name of the property.
206 const String& name() const;
207
208 //! Full name of the property.
209 const String& fullName() const;
210
211 IPropertyMng* propertyMng() const;
212
213 /*!
214 * \brief Destroys the associated values of properties linked to this reference.
215 */
216 void destroy();
217
218 //! \internal
219 PropertiesImpl* impl() const { return m_p; }
220
221 //! \internal
222 PropertiesImplBase* baseImpl() const { return m_ref.get(); }
223
224 private:
225
226 PropertiesImpl* m_p;
228
229 private:
230
232};
233
234/*---------------------------------------------------------------------------*/
235/*---------------------------------------------------------------------------*/
236
237} // End namespace Arcane
238
239/*---------------------------------------------------------------------------*/
240/*---------------------------------------------------------------------------*/
241
242#endif
Declarations of Arcane's general types.
Declarations of types used in Arcane.
Encapsulation of a pointer with a reference counter.
Definition AutoRef.h:43
Interface of the property manager.
Int64 getInt64(const String &name) const
Value of the property named name.
bool get(const String &name, bool &value) const
Value of the property named name.
bool getBoolWithDefault(const String &name, bool default_value) const
Value of the property named name.
const String & name() const
Name of the property.
Int32 getInt32WithDefault(const String &name, Int32 default_value) const
Value of the property named name.
Int32 getInt32(const String &name) const
Value of the property named name.
Integer getInteger(const String &name) const
Value of the property named name.
Integer getIntegerWithDefault(const String &name, Integer default_value) const
Value of the property named name.
bool getBool(const String &name) const
Value of the property named name.
void setInteger(const String &name, Integer value)
Sets an Integer property of name name and value value.
void setInt64(const String &name, Int64 value)
Sets an Int64 property of name name and value value.
void destroy()
Destroys the associated values of properties linked to this reference.
Real getReal(const String &name) const
Value of the property named name.
void setInt32(const String &name, Int32 value)
Sets an Int32 property of name name and value value.
Int64 getInt64WithDefault(const String &name, Int64 default_value) const
Value of the property named name.
void set(const String &name, bool value)
Sets a boolean property of name name and value value.
String getString(const String &name) const
Value of the property named name.
Real getRealWithDefault(const String &name, Real default_value) const
Value of the property named name.
const Properties & operator=(const Properties &rhs)
Copy assignment operator.
String getStringWithDefault(const String &name, const String &default_value) const
Value of the property named name.
void serialize(ISerializer *serializer)
Performs the serialization of the properties.
Properties(IPropertyMng *pm, const String &name)
Creates or retrieves a list of properties with name name.
void setBool(const String &name, bool value)
Sets a boolean property of name name and value value.
void setString(const String &name, const String &value)
Sets a String property of name name and value value.
const String & fullName() const
Full name of the property.
void print(std::ostream &o) const
Prints the properties and their values to the stream o.
void setReal(const String &name, Real value)
Sets a Real property of name name and value value.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Array< Int64 > Int64Array
Dynamic one-dimensional array of 64-bit integers.
Definition UtilsTypes.h:125
ConstArrayView< String > StringConstArrayView
C equivalent of a 1D array of strings.
Definition UtilsTypes.h:492
Array< String > StringArray
Dynamic one-dimensional array of strings.
Definition UtilsTypes.h:145
Array< bool > BoolArray
Dynamic one-dimensional array of booleans.
Definition UtilsTypes.h:143
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
Definition UtilsTypes.h:482
ConstArrayView< bool > BoolConstArrayView
C equivalent of a 1D array of booleans.
Definition UtilsTypes.h:490
ConstArrayView< Int64 > Int64ConstArrayView
C equivalent of a 1D array of 64-bit integers.
Definition UtilsTypes.h:480
double Real
Type representing a real number.
Array< Int32 > Int32Array
Dynamic one-dimensional array of 32-bit integers.
Definition UtilsTypes.h:127
Array< Real > RealArray
Dynamic one-dimensional array of reals.
Definition UtilsTypes.h:135
std::int32_t Int32
Signed integer type of 32 bits.
ConstArrayView< Real > RealConstArrayView
C equivalent of a 1D array of reals.
Definition UtilsTypes.h:488