13 #ifndef ML_RUNTIME_TYPE_H
14 #define ML_RUNTIME_TYPE_H
27 ML_UTILS_START_NAMESPACE
70 const char *className =
nullptr,
71 RuntimeTypeCreateCB *callback =
nullptr,
72 const char *dllName =
nullptr);
84 inline const char*
getName()
const {
return _className ? _className :
"BadType"; }
87 inline const char*
getDllName()
const {
return _dllName ? _dllName :
""; }
98 inline void*
createInstance()
const {
return _callback ? (*_callback)() :
nullptr; }
101 inline RuntimeTypeCreateCB *
getCallback()
const {
return _callback; }
122 RuntimeTypeCreateCB* _callback;
125 ML_UTILS_END_NAMESPACE
134 inline ostream&
operator<<(ostream& s,
const ML_UTILS_NAMESPACE::RuntimeType &rt)
137 <<
" Name :" << rt.getName()
138 <<
" DllName :" << rt.getDllName()
139 <<
" Parent: " << (rt.getParent() ? rt.getParent()->getName() :
"NULL")
140 <<
" Abstract: " << (rt.getCallback() ?
"No" :
"Yes")
RuntimeType contains type and inheritance information of a class and a static dictionary with informa...
void * createInstance() const
Creates and returns an instance of the of the class or NULL if such an instance is unavailable.
void * RuntimeTypeCreateCB()
A type of a callback function to create an instance of a class handled by the Runtime class.
RuntimeTypeCreateCB * getCallback() const
Returns the callback used to create an instance of the object or NULL on abstract classes.
MLint getId() const
Returns the ID that describes where the type was registered in the Runtime Type System.
bool canCreateInstance() const
Returns true if this (runtime) type knows how to create an instance of the class.
const char * getDllName() const
Returns the NULL-terminated string name of the source DLL or "" if it is unknown.
ML_UTILS_EXPORT RuntimeType(const RuntimeType *parent=nullptr, const char *className=nullptr, RuntimeTypeCreateCB *callback=nullptr, const char *dllName=nullptr)
Constructor.
ML_UTILS_EXPORT bool isDerivedFrom(const RuntimeType *runtimeType) const
Returns true if this (runtime) type is derived from the argument (runtime) type runtimeType.
const RuntimeType * getParent() const
Returns the parent (runtime) type of the type, i.e., the type it is derived from or NULL if not deriv...
const char * getName() const
Returns the NULL-terminated string name of the class. Returns 'BadType' on error.
ML_UTILS_EXPORT ~RuntimeType()
Destructor. Cleans up all elements.
MLEXPORT std::ostream & operator<<(std::ostream &s, const ml::Field &v)
Overloads the operator '<<' for stream output of Field objects.
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...