Manual for OpenFLUID 2.1.10

IndexedValue.hpp
Go to the documentation of this file.
1 /*
2 
3  This file is part of OpenFLUID software
4  Copyright(c) 2007, INRA - Montpellier SupAgro
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 
46 #include <openfluid/core/Value.hpp>
49 
50 
51 namespace openfluid { namespace core {
52 
53 /**
54  @cond OpenFLUID:completion
55  {
56  "contexts" : ["ANYWARE"],
57  "menupath" : ["Compute code", "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::shared_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 
84  /**
85  Constructor from a time index and a value
86  */
87  IndexedValue(const TimeIndex_t& Ind, const Value& Val) : m_Index(Ind),m_Value(Val.clone())
88  {
89 
90  }
91 
92  /**
93  Copy constructor
94  */
95  IndexedValue(const IndexedValue& IndValue) : m_Index(IndValue.m_Index),m_Value(IndValue.m_Value.get()->clone())
96  { }
97 
98  /**
99  Returns the time index of the indexed value
100  @return the time index
101  */
102  inline TimeIndex_t getIndex() const
103  {
104  return m_Index;
105  }
106 
107  /**
108  Returns a pointer to the value of the indexed value
109  @return a pointer to the value
110  */
111  inline Value* value() const
112  {
113  return m_Value.get();
114  }
115 
116  /**
117  Returns a pointer to the value of the indexed value
118  @return a pointer to the value
119  */
120  inline Value* value()
121  {
122  return m_Value.get();
123  }
124 
125  /**
126  @deprecated Since version 2.1.0. Use openfluid::core::IndexedValue::value() const instead
127  */
128  [[deprecated]] inline Value* getValue() const
129  {
130  return m_Value.get();
131  }
132 
133  /**
134  @deprecated Since version 2.1.0. Use openfluid::core::IndexedValue::value() instead
135  */
136  [[deprecated]] inline Value* getValue()
137  {
138  return m_Value.get();
139  }
140 
141 
142  /**
143  Clears the content of the indexed value. The time index is set to 0,
144  and the value is set to an openfluid::core::NullValue.
145  */
146  inline void clear()
147  {
148  m_Index = 0;
149  m_Value.reset(new NullValue());
150  }
151 
152 };
153 
154 
155 /**
156  Indexed value list, ordered from oldest (front) to more recent (back)
157 
158  @cond OpenFLUID:completion
159  {
160  "contexts" : ["ANYWARE"],
161  "menupath" : ["Compute code", "Types", "Values"],
162  "title" : "List of IndexedValue",
163  "text" : "openfluid::core::IndexedValueList %%SEL_START%%IndexedValList%%SEL_END%%"
164  }
165  @endcond
166 */
167 typedef std::list<IndexedValue> IndexedValueList;
168 
169 
170 } } // namespaces
171 
172 
173 #endif /* __OPENFLUID_CORE_INDEXEDVALUE_HPP__ */
Definition: ApplicationException.hpp:47
std::list< IndexedValue > IndexedValueList
Definition: IndexedValue.hpp:167
Definition: Value.hpp:64
TimeIndex_t getIndex() const
Definition: IndexedValue.hpp:102
Value * getValue() const
Definition: IndexedValue.hpp:128
Value * value()
Definition: IndexedValue.hpp:120
IndexedValue(const TimeIndex_t &Ind, const Value &Val)
Definition: IndexedValue.hpp:87
Definition: IndexedValue.hpp:63
Value * getValue()
Definition: IndexedValue.hpp:136
IndexedValue(const IndexedValue &IndValue)
Definition: IndexedValue.hpp:95
void clear()
Definition: IndexedValue.hpp:146
std::uint64_t TimeIndex_t
Definition: TypeDefs.hpp:298
IndexedValue()
Definition: IndexedValue.hpp:79
Definition: ValuesBuffer.hpp:52
Definition: NullValue.hpp:65
Value * value() const
Definition: IndexedValue.hpp:111