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