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 #ifndef __VALUE_HPP___
00043 #define __VALUE_HPP___
00044
00045 #include <iostream>
00046
00047 #include <openfluid/dllexport.hpp>
00048 #include <openfluid/base/FrameworkException.hpp>
00049
00050
00051 namespace openfluid { namespace core {
00052
00053 class NullValue;
00054 class BooleanValue;
00055 class DoubleValue;
00056 class IntegerValue;
00057 class StringValue;
00058
00059 class VectorValue;
00060 class MatrixValue;
00061 class MapValue;
00062
00063
00064 class DLLEXPORT Value
00065 {
00066 public:
00067
00068 enum Type { NONE, BOOLEAN, INTEGER, DOUBLE, STRING, VECTOR, MATRIX, MAP, NULLL };
00069
00070
00071
00072
00073 Value() {};
00074
00075
00076
00077
00078 Value(const Value& ) {};
00079
00080
00081
00082
00083 virtual Value& operator =(const Value& ) { return *this; }
00084
00085 virtual ~Value() {};
00086
00087 virtual Type getType() const = 0;
00088
00089 virtual Value* clone() const { throw openfluid::base::FrameworkException("Value::clone","Value is not cloneable"); };
00090
00091 inline virtual bool isSimple() const = 0;
00092
00093 inline virtual bool isCompound() const = 0;
00094
00095 virtual void writeToStream(std::ostream& OutStm) const = 0;
00096
00097 friend std::ostream& operator<<(std::ostream& OutStm, const Value& Val)
00098 { Val.writeToStream(OutStm); return OutStm; };
00099
00100
00101
00102
00103 inline bool isDoubleValue() const { return getType() == Value::DOUBLE; };
00104
00105 const DoubleValue& asDoubleValue() const;
00106
00107 DoubleValue& asDoubleValue();
00108
00109
00110
00111
00112 inline bool isIntegerValue() const { return getType() == Value::INTEGER; };
00113
00114 const IntegerValue& asIntegerValue() const;
00115
00116 IntegerValue& asIntegerValue();
00117
00118
00119
00120
00121 inline bool isBooleanValue() const { return getType() == Value::BOOLEAN; };
00122
00123 const BooleanValue& asBooleanValue() const;
00124
00125 BooleanValue& asBooleanValue();
00126
00127
00128
00129
00130 inline bool isStringValue() const { return getType() == Value::STRING; };
00131
00132 const StringValue& asStringValue() const;
00133
00134 StringValue& asStringValue();
00135
00136
00137
00138
00139 inline bool isNullValue() const { return getType() == Value::NULLL; };
00140
00141 const NullValue& asNullValue() const;
00142
00143 NullValue& asNullValue();
00144
00145
00146
00147
00148 inline bool isVectorValue() const { return getType() == Value::VECTOR; };
00149
00150 const VectorValue& asVectorValue() const;
00151
00152 VectorValue& asVectorValue();
00153
00154
00155
00156
00157 inline bool isMatrixValue() const { return getType() == Value::MATRIX; };
00158
00159 const MatrixValue& asMatrixValue() const;
00160
00161 MatrixValue& asMatrixValue();
00162
00163
00164
00165
00166 inline bool isMapValue() const { return getType() == Value::MAP; };
00167
00168 const MapValue& asMapValue() const;
00169
00170 MapValue& asMapValue();
00171
00172
00173
00174
00175 std::string toString() const;
00176
00177 static bool getValueTypeFromString(const std::string ValueTypeString, Value::Type& ValueType);
00178
00179 static std::string getStringFromValueType(const Value::Type ValueType);
00180
00181 };
00182
00183
00184 } }
00185
00186
00187 #endif