Variables.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 Variables.hpp
34 
35  @author Jean-Christophe Fabre <jean-christophe.fabre@supagro.inra.fr>
36 */
37 
38 #ifndef __OPENFLUID_CORE_VARIABLES_HPP__
39 #define __OPENFLUID_CORE_VARIABLES_HPP__
40 
41 #include <openfluid/core/TypeDefs.hpp>
43 #include <openfluid/dllexport.hpp>
44 
45 
46 namespace openfluid { namespace core {
47 
48 
50 {
51  private:
52 
53  typedef std::map<VariableName_t, std::pair<ValuesBuffer,Value::Type> > VariablesMap_t;
54 
55  VariablesMap_t m_Data;
56 
57 
58  public:
59 
60  Variables();
61 
62  ~Variables();
63 
64  bool createVariable(const VariableName_t& aName);
65 
66  bool createVariable(const VariableName_t& aName, const Value::Type& aType);
67 
68  bool modifyValue(const VariableName_t& aName, const TimeIndex_t& anIndex,
69  const Value& aValue);
70 
71  bool modifyCurrentValue(const VariableName_t& aName, const Value& aValue);
72 
73  bool appendValue(const VariableName_t& aName, const TimeIndex_t& anIndex, const Value& aValue);
74 
75  bool getValue(const VariableName_t& aName, const TimeIndex_t& anIndex,Value* aValue) const;
76 
77  const Value* value(const VariableName_t& aName, const TimeIndex_t& anIndex) const;
78 
79  const Value* currentValue(const VariableName_t& aName) const;
80 
81  bool getCurrentValue(const VariableName_t& aName, Value* aValue) const;
82 
83  bool getLatestIndexedValue(const VariableName_t& aName, IndexedValue& IndValue) const;
84 
85  bool getLatestIndexedValues(const VariableName_t& aName, const TimeIndex_t& anIndex,
86  IndexedValueList& IndValueList) const;
87 
88  bool getIndexedValues(const VariableName_t& aName,
89  const TimeIndex_t& aBeginIndex, const TimeIndex_t& anEndIndex,
90  IndexedValueList& IndValueList) const;
91 
92  bool getCurrentValueIfIndex(const VariableName_t& aName, const TimeIndex_t& Index, Value* aValue) const;
93 
94  Value* currentValueIfIndex(const VariableName_t& aName, const TimeIndex_t& Index) const;
95 
96  bool isVariableExist(const VariableName_t& aName) const;
97 
98  bool isVariableExist(const VariableName_t& aName, const TimeIndex_t& anIndex) const;
99 
100  bool isVariableExist(const VariableName_t& aName, const TimeIndex_t& anIndex,
101  Value::Type ValueType) const;
102 
103  bool isTypedVariableExist(const VariableName_t& aName, const Value::Type& VarType) const;
104 
105  bool isTypedVariableExist(const VariableName_t& aName, const TimeIndex_t& anIndex,
106  const Value::Type& VarType) const;
107 
108  std::vector<VariableName_t> getVariablesNames() const;
109 
110  int getVariableValuesCount(const VariableName_t& aName) const;
111 
112  bool checkAllVariablesCount(unsigned int Count, VariableName_t& ErrorVarName) const;
113 
114  void clear();
115 
116  void displayContent(const VariableName_t& aName, std::ostream& OStream) const;
117 
118 };
119 
120 
121 } } // namespaces
122 
123 
124 #endif /* __VARIABLES_H_ */
unsigned long long TimeIndex_t
Definition: DateTime.hpp:62
#define OPENFLUID_API
Definition: dllexport.hpp:87
Type
Definition: Value.hpp:68
Definition: ApplicationException.hpp:47
std::string VariableName_t
Definition: TypeDefs.hpp:86
Definition: Variables.hpp:49
Definition: Value.hpp:64
Definition: IndexedValue.hpp:55
std::list< IndexedValue > IndexedValueList
Definition: IndexedValue.hpp:133