Documentation for OpenFLUID 2.2.2
Loading...
Searching...
No Matches
IndexedValue.hpp
Go to the documentation of this file.
1/*
2
3 This file is part of OpenFLUID software
4 Copyright(c) 2021-2026, INRAE
5
6
7 == GNU General Public License Usage ==
8
9 OpenFLUID is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 OpenFLUID is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with OpenFLUID. If not, see <http://www.gnu.org/licenses/>.
21
22
23 == Other Usage ==
24
25 Other Usage means a use of OpenFLUID that is inconsistent with the GPL
26 license, and requires a written agreement between You and INRA.
27 Licensees for Other Usage of OpenFLUID may use this file in accordance
28 with the terms contained in the written agreement between You and INRA.
29
30*/
31
32/**
33 @file IndexedValue.hpp
34
35 @author Jean-Christophe FABRE <jean-christophe.fabre@inra.fr>
36*/
37
38
39#ifndef __OPENFLUID_CORE_INDEXEDVALUE_HPP__
40#define __OPENFLUID_CORE_INDEXEDVALUE_HPP__
41
42
43#include <list>
44#include <memory>
45
49
50
51namespace openfluid { namespace core {
52
53/**
54 @cond OpenFLUID:completion
55 {
56 "contexts" : ["ANYWARE"],
57 "menupath" : ["Types", "Values"],
58 "title" : "IndexedValue",
59 "text" : "openfluid::core::IndexedValue %%SEL_START%%IndexedVal%%SEL_END%%"
60 }
61 @endcond
62*/
64{
65 friend class ValuesBuffer;
66
67 private:
68
69 TimeIndex_t m_Index;
70
71 std::unique_ptr<Value> m_Value;
72
73
74 public:
75
76 /**
77 Default constructor
78 */
79 IndexedValue() : m_Index(0),m_Value(new NullValue())
80 { }
81
82 /**
83 Copy constructor
84 */
85 IndexedValue(const IndexedValue& IndValue) : m_Index(IndValue.m_Index),m_Value(IndValue.m_Value.get()->clone())
86 { }
87
88 /**
89 Move constructor
90 */
91 IndexedValue(IndexedValue&& IndValue) : m_Index(IndValue.m_Index),m_Value(std::move(IndValue.m_Value))
92 { }
93
94 /**
95 Constructor from a time index and a value
96 */
97 IndexedValue(const TimeIndex_t& Ind, const Value& Val) : m_Index(Ind),m_Value(Val.clone())
98 { }
99
101 {
102 if (this != &Other)
103 {
104 m_Index = Other.m_Index;
105 m_Value = std::move(Other.m_Value);
106
107 Other.m_Index = 0;
108 }
109
110 return *this;
111 }
112
113 /**
114 Returns the time index of the indexed value
115 @return the time index
116 */
117 inline TimeIndex_t getIndex() const
118 {
119 return m_Index;
120 }
121
122 /**
123 Returns a pointer to the value of the indexed value
124 @return a pointer to the value
125 */
126 inline Value* value() const
127 {
128 return m_Value.get();
129 }
130
131 /**
132 Returns a pointer to the value of the indexed value
133 @return a pointer to the value
134 */
135 inline Value* value()
136 {
137 return m_Value.get();
138 }
139
140 /**
141 @deprecated Since version 2.1.0. Use openfluid::core::IndexedValue::value() const instead
142 */
143 [[deprecated]] inline Value* getValue() const
144 {
145 return m_Value.get();
146 }
147
148 /**
149 @deprecated Since version 2.1.0. Use openfluid::core::IndexedValue::value() instead
150 */
151 [[deprecated]] inline Value* getValue()
152 {
153 return m_Value.get();
154 }
155
156
157 /**
158 Clears the content of the indexed value. The time index is set to 0,
159 and the value is set to an openfluid::core::NullValue.
160 */
161 inline void clear()
162 {
163 m_Index = 0;
164 m_Value.reset(new NullValue());
165 }
166
167};
168
169
170/**
171 Indexed value list, ordered from oldest (front) to more recent (back)
172
173 @cond OpenFLUID:completion
174 {
175 "contexts" : ["ANYWARE"],
176 "menupath" : ["Types", "Values"],
177 "title" : "List of IndexedValue",
178 "text" : "openfluid::core::IndexedValueList %%SEL_START%%IndexedValList%%SEL_END%%"
179 }
180 @endcond
181*/
182typedef std::list<IndexedValue> IndexedValueList;
183
184
185} } // namespaces
186
187
188#endif /* __OPENFLUID_CORE_INDEXEDVALUE_HPP__ */
Definition IndexedValue.hpp:64
TimeIndex_t getIndex() const
Definition IndexedValue.hpp:117
IndexedValue & operator=(IndexedValue &&Other)
Definition IndexedValue.hpp:100
void clear()
Definition IndexedValue.hpp:161
Value * getValue() const
Definition IndexedValue.hpp:143
IndexedValue(const IndexedValue &IndValue)
Definition IndexedValue.hpp:85
IndexedValue(const TimeIndex_t &Ind, const Value &Val)
Definition IndexedValue.hpp:97
Value * getValue()
Definition IndexedValue.hpp:151
Value * value()
Definition IndexedValue.hpp:135
IndexedValue()
Definition IndexedValue.hpp:79
IndexedValue(IndexedValue &&IndValue)
Definition IndexedValue.hpp:91
Value * value() const
Definition IndexedValue.hpp:126
Definition NullValue.hpp:66
Definition Value.hpp:63
Definition ValuesBuffer.hpp:53
std::uint64_t TimeIndex_t
Definition TypeDefs.hpp:298
std::list< IndexedValue > IndexedValueList
Definition IndexedValue.hpp:182
Definition ApplicationException.hpp:47