Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
SimpleProperty.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/* SimpleProperty.h (C) 2000-2025 */
9/* */
10/* Basic implementation of a property. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_SIMPLEPROPERTY_H
13#define ARCANE_CORE_SIMPLEPROPERTY_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
18#include "arcane/utils/String.h"
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23namespace Arcane
24{
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29template <class T>
31{
32 public:
33
34 typedef const T& ConstReferenceType;
35 typedef T& ReferenceType;
36 typedef T ValueType;
37};
38
39/*---------------------------------------------------------------------------*/
40/*---------------------------------------------------------------------------*/
41
42template <>
44{
45 public:
46
47 typedef const String& ConstReferenceType;
48 typedef String& ReferenceType;
49 typedef String ValueType;
50};
51
52/*---------------------------------------------------------------------------*/
53/*---------------------------------------------------------------------------*/
54
55/*!
56 * \internal
57 * \brief Basic implementation of a read-only property.
58 */
59template <class T>
60class SimpleReadOnlyPropertyT
61{
62 public:
63
64 typedef typename SimplePropertyTraitsT<T>::ConstReferenceType ConstReferenceType;
65 typedef typename SimplePropertyTraitsT<T>::ReferenceType ReferenceType;
66 typedef typename SimplePropertyTraitsT<T>::ValueType ValueType;
67
68 public:
69
70 SimpleReadOnlyPropertyT()
71 : m_value(T())
72 {}
73 SimpleReadOnlyPropertyT(ConstReferenceType v)
74 : m_value(v)
75 {}
76
77 public:
78
79 ConstReferenceType get() const { return m_value; }
80
81 protected:
82
83 ValueType m_value;
84};
85
86/*---------------------------------------------------------------------------*/
87/*---------------------------------------------------------------------------*/
88
89/*!
90 * \internal
91 * \brief Basic implementation of a property.
92 */
93template <class T>
94class SimplePropertyT
95: public SimpleReadOnlyPropertyT<T>
96{
97 public:
98
99 typedef typename SimplePropertyTraitsT<T>::ConstReferenceType ConstReferenceType;
100 typedef typename SimplePropertyTraitsT<T>::ReferenceType ReferenceType;
101 typedef typename SimplePropertyTraitsT<T>::ValueType ValueType;
102
103 public:
104
105 SimplePropertyT()
106 : SimpleReadOnlyPropertyT<T>()
107 {}
108 SimplePropertyT(ConstReferenceType v)
109 : SimpleReadOnlyPropertyT<T>(v)
110 {}
111
112 public:
113
114 inline ConstReferenceType get() const { return this->m_value; }
115 inline ReferenceType get() { return this->m_value; }
116 inline void put(ConstReferenceType v) { this->m_value = v; }
117};
118
119/*---------------------------------------------------------------------------*/
120/*---------------------------------------------------------------------------*/
121
122} // namespace Arcane
123
124/*---------------------------------------------------------------------------*/
125/*---------------------------------------------------------------------------*/
126
127#endif
Arcane configuration file.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --