10 #ifndef runtimeValue_H_
11 #define runtimeValue_H_
17 #include <vlutil/vlString.h>
18 #include <vlutil/vlSmartPointers.h>
44 virtual bool sameType(
const DtAnyValue*
const base)
const
45 {
return this->typeId() == base->
typeId(); }
47 virtual const DtString& type()
const = 0;
48 virtual DtString serialize()
const = 0;
50 virtual int typeId()
const = 0;
91 operator const T()
const;
94 virtual int typeId()
const;
124 template <
typename T>
143 template <
typename T>
154 #define DT_UNIQUE_INT (hash(__FILE__)+__LINE__)
162 #define DtDeclareRuntimeType(type)\
164 DT_DLL_LGRUTIL int DtValue< type >::theTypeId(); \
166 DT_DLL_LGRUTIL const DtString& DtValue< type >::theType();\
168 DT_DLL_LGRUTIL int DtValue< std::vector<type> >::theTypeId(); \
170 DT_DLL_LGRUTIL const DtString& DtValue< std::vector<type> >::theType();
175 #define DtDefineRuntimeType(type) \
177 int DtValue<type>::theTypeId() \
179 static int id = DT_UNIQUE_INT; return id; \
183 const DtString& DtValue<type>::theType() \
185 static DtString typeName(#type); \
190 DtString (*DtValue<type>::theSerializeFunction)(const type&) = 0; \
192 type (*DtValue<type>::theDeserializeFunction)(const DtString&) = 0; \
195 int DtValue<std::vector<type> >::theTypeId() \
197 static int id = DT_UNIQUE_INT; return id; \
201 const DtString& DtValue<std::vector<type> >::theType() \
203 static DtString typeName("std::vector<" #type ">"); \
208 DtString (*DtValue<std::vector<type> >::theSerializeFunction)( \
209 const std::vector<type>&) = 0; \
212 std::vector<type> (*DtValue<std::vector<type> >::theDeserializeFunction) \
213 (const DtString&) = 0;
216 #define DtDefineSerializableRuntimeType(type) \
218 int DtValue<type>::theTypeId() \
220 static int id = DT_UNIQUE_INT; return id; \
224 const DtString& DtValue<type>::theType() \
226 static DtString typeName(#type); \
230 int DtValue<std::vector<type> >::theTypeId() \
232 static int id = DT_UNIQUE_INT; return id; \
236 const DtString& DtValue<std::vector<type> >::theType() \
238 static DtString typeName("std::vector<" #type ">" ); \
242 DtString serializeList##type(const std::vector<type>& input) \
244 return DtValueList<type>::serializeList(input); \
248 std::vector<type> deserializeList##type(const DtString& input) \
250 return DtValueList<type>::deserializeListMembers(input); \
254 DtString (*DtValue<std::vector<type> >::theSerializeFunction)( \
255 const std::vector<type>&) = serializeList##type; \
258 std::vector<type> (*DtValue<std::vector<type> >::theDeserializeFunction) \
259 (const DtString&) = deserializeList##type;
273 #define runtimeValue_INC_
274 #include "runtimeValue.inl"
275 #undef runtimeValue_INC_