Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00056 #ifndef __MAPVALUE_HPP__
00057 #define __MAPVALUE_HPP__
00058
00059
00060 #include <map>
00061 #include <boost/shared_ptr.hpp>
00062
00063 #include <openfluid/core/CompoundValue.hpp>
00064 #include <openfluid/core/DoubleValue.hpp>
00065 #include <openfluid/core/IntegerValue.hpp>
00066 #include <openfluid/core/BooleanValue.hpp>
00067 #include <openfluid/core/StringValue.hpp>
00068 #include <openfluid/core/MatrixValue.hpp>
00069 #include <openfluid/core/VectorValue.hpp>
00070 #include <openfluid/dllexport.hpp>
00071
00072
00073 namespace openfluid { namespace core {
00074
00149 class DLLEXPORT MapValue : public CompoundValue
00150 {
00151 public:
00152 typedef std::map<std::string,boost::shared_ptr<Value> > Map_t;
00153
00154
00155 private:
00156
00157 Map_t m_Value;
00158
00159 public:
00160
00164 MapValue() : CompoundValue() {};
00165
00169 MapValue(const MapValue& Val);
00170
00171 MapValue(const Map_t& Val) : CompoundValue(), m_Value(Val) {};
00172
00173 Value& operator =(const Value& Other);
00174
00175 ~MapValue();
00176
00177 inline Type getType() const { return Value::MAP; };
00178
00179 Value* clone() const { return new MapValue(*this); };
00180
00181 void writeToStream(std::ostream& OutStm) const;
00182
00188 void set(const std::string& Key, Value* Element);
00189
00195 inline void setDouble(const std::string& Key, const double& Val)
00196 { set(Key,new DoubleValue(Val)); };
00197
00204 inline void setInteger(const std::string& Key, const long& Val)
00205 { set(Key,new IntegerValue(Val)); };
00206
00212 inline void setBoolean(const std::string& Key, const bool& Val)
00213 { set(Key,new BooleanValue(Val)); };
00214
00220 inline void setString(const std::string& Key, const std::string& Val)
00221 { set(Key,new StringValue(Val)); };
00222
00228 inline void setVectorValue(const std::string& Key, const VectorValue& Val)
00229 { set(Key,new VectorValue(Val)); };
00230
00236 inline void setMatrixValue(const std::string& Key, const MatrixValue& Val)
00237 { set(Key,new MatrixValue(Val)); };
00238
00243 Value& operator[](const std::string& Key);
00244
00250 Value& get(const std::string& Key);
00251
00257 inline double getDouble(const std::string& Key) { return get(Key).asDoubleValue().get(); };
00258
00264 inline long getInteger(const std::string& Key) { return get(Key).asIntegerValue().get(); };
00265
00271 inline bool getBoolean(const std::string& Key) { return get(Key).asBooleanValue().get(); };
00272
00278 inline std::string getString(const std::string& Key) { return get(Key).asStringValue().get(); };
00279
00285 inline VectorValue getVectorValue(const std::string& Key) { return get(Key).asVectorValue(); };
00286
00292 inline MatrixValue getMatrixValue(const std::string& Key) { return get(Key).asMatrixValue(); };
00293
00298 bool remove(const std::string& Key);
00299
00304 inline unsigned long getSize() const { return m_Value.size(); };
00305
00310 unsigned long size() const { return m_Value.size(); };
00311
00317 inline bool isKeyExist(const std::string& Key) const { return (m_Value.find(Key) != m_Value.end()); };
00318
00322 void clear();
00323
00324 };
00325
00326
00327 } }
00328
00329
00330
00331
00332
00333
00334 #endif