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@supagro.inra.fr>
36  */
37 
38 
39 
40 #ifndef __OPENFLUID_CORE_INDEXEDVALUE_HPP__
41 #define __OPENFLUID_CORE_INDEXEDVALUE_HPP__
42 
44 #include <openfluid/core/Value.hpp>
47 
48 #include <list>
49 #include <memory>
50 
51 
52 namespace openfluid { namespace core {
53 
54 
56 {
57  friend class ValuesBuffer;
58 
59  private:
60 
61  TimeIndex_t m_Index;
62 
63  std::shared_ptr<Value> m_Value;
64 
65 
66  public:
67 
68  /**
69  Default constructor
70  */
71  IndexedValue() : m_Index(0),m_Value(new NullValue())
72  { }
73 
74  /**
75  Constructor from a time index and a value
76  */
77  IndexedValue(const TimeIndex_t& Ind, const Value& Val) : m_Index(Ind),m_Value(Val.clone())
78  { }
79 
80  /**
81  Copy constructor
82  */
83  IndexedValue(const IndexedValue& IndValue) : m_Index(IndValue.m_Index),m_Value(IndValue.m_Value.get()->clone())
84  { }
85 
86  /**
87  Returns the time index of the indexed value
88  @return the time index
89  */
90  inline TimeIndex_t getIndex() const
91  { return m_Index; }
92 
93  /**
94  Returns a pointer to the value of the indexed value
95  @return a pointer to the value
96  */
97  inline Value* value() const
98  { return m_Value.get(); }
99 
100  /**
101  Returns a pointer to the value of the indexed value
102  @return a pointer to the value
103  */
104  inline Value* value()
105  { return m_Value.get(); }
106 
107  /**
108  @deprecated Since version 2.1.0. Use openfluid::core::IndexedValue::value() const instead
109  */
111  { return m_Value.get(); }
112 
113  /**
114  @deprecated Since version 2.1.0. Use openfluid::core::IndexedValue::value() instead
115  */
117  { return m_Value.get(); }
118 
119 
120  /**
121  Clears the content of the indexed value. The time index is set to 0,
122  and the value is set to an openfluid::core::NullValue.
123  */
124  inline void clear()
125  { m_Index = 0; m_Value.reset(new NullValue()); }
126 
127 };
128 
129 
130 /**
131  Indexed value list, ordered from oldest (front) to more recent (back)
132 */
133 typedef std::list<IndexedValue> IndexedValueList;
134 
135 
136 } } // namespaces
137 
138 
139 #endif /* __OPENFLUID_CORE_INDEXEDVALUE_HPP__ */
Definition: Value.hpp:64
Value * value()
Definition: IndexedValue.hpp:104
Definition: IndexedValue.hpp:55
void clear()
Definition: IndexedValue.hpp:124
IndexedValue()
Definition: IndexedValue.hpp:71
Value * getValue() OPENFLUID_DEPRECATED
Definition: IndexedValue.hpp:116
SpatialUnit Unit OPENFLUID_DEPRECATED
Definition: SpatialUnit.hpp:304
Value * value() const
Definition: IndexedValue.hpp:97
TimeIndex_t getIndex() const
Definition: IndexedValue.hpp:90
Definition: ValuesBuffer.hpp:50
IndexedValue(const IndexedValue &IndValue)
Definition: IndexedValue.hpp:83
Definition: ApplicationException.hpp:47
Definition: NullValue.hpp:58
IndexedValue(const TimeIndex_t &Ind, const Value &Val)
Definition: IndexedValue.hpp:77
Value * getValue() const OPENFLUID_DEPRECATED
Definition: IndexedValue.hpp:110
unsigned long long TimeIndex_t
Definition: DateTime.hpp:62
std::list< IndexedValue > IndexedValueList
Definition: IndexedValue.hpp:133