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 
55 {
56  friend class ValuesBuffer;
57 
58  private:
59 
60  TimeIndex_t m_Index;
61 
62  std::shared_ptr<Value> m_Value;
63 
64 
65  public:
66 
67  /**
68  Default constructor
69  */
70  IndexedValue() : m_Index(0),m_Value(new NullValue())
71  {
72 
73  }
74 
75  /**
76  Constructor from a time index and a value
77  */
78  IndexedValue(const TimeIndex_t& Ind, const Value& Val) : m_Index(Ind),m_Value(Val.clone())
79  {
80 
81  }
82 
83  /**
84  Copy constructor
85  */
86  IndexedValue(const IndexedValue& IndValue) : m_Index(IndValue.m_Index),m_Value(IndValue.m_Value.get()->clone())
87  { }
88 
89  /**
90  Returns the time index of the indexed value
91  @return the time index
92  */
93  inline TimeIndex_t getIndex() const
94  {
95  return m_Index;
96  }
97 
98  /**
99  Returns a pointer to the value of the indexed value
100  @return a pointer to the value
101  */
102  inline Value* value() const
103  {
104  return m_Value.get();
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()
112  {
113  return m_Value.get();
114  }
115 
116  /**
117  @deprecated Since version 2.1.0. Use openfluid::core::IndexedValue::value() const instead
118  */
119  [[deprecated]] inline Value* getValue() const
120  {
121  return m_Value.get();
122  }
123 
124  /**
125  @deprecated Since version 2.1.0. Use openfluid::core::IndexedValue::value() instead
126  */
127  [[deprecated]] inline Value* getValue()
128  {
129  return m_Value.get();
130  }
131 
132 
133  /**
134  Clears the content of the indexed value. The time index is set to 0,
135  and the value is set to an openfluid::core::NullValue.
136  */
137  inline void clear()
138  {
139  m_Index = 0;
140  m_Value.reset(new NullValue());
141  }
142 
143 };
144 
145 
146 /**
147  Indexed value list, ordered from oldest (front) to more recent (back)
148 */
149 typedef std::list<IndexedValue> IndexedValueList;
150 
151 
152 } } // namespaces
153 
154 
155 #endif /* __OPENFLUID_CORE_INDEXEDVALUE_HPP__ */
Definition: Value.hpp:64
IndexedValue()
Definition: IndexedValue.hpp:70
Definition: IndexedValue.hpp:54
IndexedValue(const TimeIndex_t &Ind, const Value &Val)
Definition: IndexedValue.hpp:78
Definition: NullValue.hpp:56
Value * getValue()
Definition: IndexedValue.hpp:127
Value * getValue() const
Definition: IndexedValue.hpp:119
Definition: ApplicationException.hpp:47
Value * value()
Definition: IndexedValue.hpp:111
Value * value() const
Definition: IndexedValue.hpp:102
std::uint64_t TimeIndex_t
Definition: TypeDefs.hpp:181
TimeIndex_t getIndex() const
Definition: IndexedValue.hpp:93
void clear()
Definition: IndexedValue.hpp:137
std::list< IndexedValue > IndexedValueList
Definition: IndexedValue.hpp:149
IndexedValue(const IndexedValue &IndValue)
Definition: IndexedValue.hpp:86
Definition: ValuesBuffer.hpp:52