#include <DoBase.hpp>
Public Member Functions | |
DynObjType *docall | doGetType (const DynI **pself) const |
Main interface | |
template<class T> | |
DynData (T t) | |
int | GetType () |
template<class T> | |
bool | IsA () const |
template<class T> | |
T | Get () const |
Protected Attributes | |
int | m_type |
union { | |
char m_data [DYNDATA_MAX_SIZE] | |
const char * m_str | |
}; |
DynData::DynData | ( | T | t | ) | [inline] |
Constructor, takes arbitrary type.
DynObjType* docall DynData::doGetType | ( | const DynI ** | pself | ) | const [virtual] |
Returns type of this object. Each type that wants to make itself known should override this method. DynI knows its own type so we get the type without any lookup. It is faster and works without registration.
pself | allows fetching the actual 'this' used inside doGetType (from a side base, this will be different to the 'this' of the caller). |
Reimplemented from DynI.
int DynData::GetType | ( | ) | [inline] |
Returns current type id.
bool DynData::IsA | ( | ) | const [inline] |
Check if the DynData can return requested type without loosing precision. This mainly follows C++ casting rules.
T DynData::Get | ( | ) | const [inline] |
Cast to requested type. This can be applied after checking the IsA function above. If type is not supported a run-time assert happens.