10 #ifndef runtimeValue_H_
11 #define runtimeValue_H_
17 #include <vlutil/vlString.h>
18 #include <vlutil/vlSmartPointers.h>
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;
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_
static DtString serializeList(const std::vector< T > &list)
Definition: runtimeValue.h:152
DtValue(const T &value)
Constructor pass in value.
Definition: runtimeValue.h:20
static const DtString & theType()
Static string which defines the type.
static DtValue< std::vector< T > > * deserializeMembersToPtr(const std::vector< DtString > &values)
Deserialize value list into a T type list pointer.
Definition: runtimeValue.h:145
virtual ~DtValue()
Destructor, no opp.
Definition: runtimeValue.h:27
#define DT_DLL_LGRUTIL
Definition: lgrUtil.h:19
static DT_DLL_LGRUTIL DtString(* theSerializeFunction)(const T &)
Pointer to serializeFunction.
Definition: runtimeValue.h:109
static int theTypeId()
Static function which defines the type.
virtual DtAnyValue * clone() const
Create a new copy of the DtValue;.
Definition: runtimeValue.h:32
DT_DLL_LGRUTIL unsigned int hash(const char *k)
Necessary non-coliding Hash function.
DtAnyValue()
Inline function provided to work around solaris compiler issue.
Definition: runtimeValue.h:36
DtAnyValue is a base class for Any Value type.
Definition: runtimeValue.h:30
std::shared_ptr< DtAnyValue > DtAnyValueSP
Definition: lgrCommand.h:104
T myValue
Storage of value;.
Definition: runtimeValue.h:115
DT_DLL_LGRUTIL std::vector< DtString > deserializeList(const DtString &)
Deserialize string value into string list.
static bool isType(const DtAnyValue *base)
Static boolean check if base value pointer is specific type.
Definition: runtimeValue.h:82
#define DtDeclareRuntimeType(type)
Helper macros.
Definition: runtimeValue.h:162
static DtValue< T > * deserialize(const DtString &value)
Deserialize value into a T type.
Definition: runtimeValue.h:51
static DtValue< std::vector< T > > deserialize(const DtString &)
Definition: runtimeValue.h:112
Contains MAKLogger::DtAbsoluteTime and MAKLogger::DtRelativeTime classes.
virtual int typeId() const =0
Contains IMPORT/EXPORT macros for lgrUtil library.
virtual const DtString & type() const
Get the type string.
Definition: runtimeValue.h:94
static DT_DLL_LGRUTIL T(* theDeserializeFunction)(const DtString &)
Pointer to deserializeFunction.
Definition: runtimeValue.h:112
static DtValue< T > * cast(DtAnyValue *base)
Cast to point of this type. If not valid type, returns 0.
Definition: runtimeValue.h:73
virtual ~DtAnyValue()
Inline function provided to work around solaris compiler issue.
Definition: runtimeValue.h:39
static std::vector< T > deserializeListMembers(const DtString &)
Deserialize a list to an array of native members.
Definition: runtimeValue.h:119
virtual bool sameType(const DtAnyValue *const base) const
Inline function provided to work around solaris compiler issue.
Definition: runtimeValue.h:44
Contains MAKLogger::DtBase64Data class.
virtual int typeId() const
Get the type id.
Definition: runtimeValue.h:88
virtual DtString serialize() const
Serialize the value into a string.
Definition: runtimeValue.h:38
A list of values.
Definition: runtimeValue.h:125
DtValue is a template class that provide value access.
Definition: runtimeValue.h:61
static std::vector< T > deserializeMembers(const std::vector< DtString > &values)
Deserialize string values into a T type list.
Definition: runtimeValue.h:128
DtAnyValue * DtWrapValue(const T &input)
Definition: runtimeValue.h:144