MeVisLab Toolbox Reference
ml::RuntimeType Class Reference

RuntimeType contains type and inheritance information of a class and a static dictionary with information on all created instances of RuntimeType. More...

#include <mlRuntimeType.h>

Public Types

typedef void * RuntimeTypeCreateCB()
 A type of a callback function to create an instance of a class handled by the Runtime class. More...
 

Public Member Functions

Specific information about the runtime type.
ML_UTILS_EXPORT RuntimeType (const RuntimeType *parent=nullptr, const char *className=nullptr, RuntimeTypeCreateCB *callback=nullptr, const char *dllName=nullptr)
 Constructor. More...
 
ML_UTILS_EXPORT ~RuntimeType ()
 Destructor. Cleans up all stuff. More...
 
ML_UTILS_EXPORT bool isDerivedFrom (const RuntimeType *runtimeType) const
 Returns true if this (runtime)type is derived from the argument (runtime)type runtimeType. More...
 
const char * getName () const
 Returns the null terminated string name of the class. Returns "BadType" on error. More...
 
const char * getDllName () const
 Returns the null terminated string name of the source dll or "" if it is unknown. More...
 
const RuntimeTypegetParent () const
 Returns the parent (runtime)type of the type, i.e., the type it is derived from or NULL if not derived from any other type. More...
 
bool canCreateInstance () const
 Returns true if this (runtime)type knows how to create an instance of the class. More...
 
void * createInstance () const
 Creates and returns an instance of the of the class (NULL if such an instance is unavailable). More...
 
RuntimeTypeCreateCBgetCallback () const
 Returns the callback used to create an instance of the object or NULL on abstract classes. More...
 
MLint getId () const
 Returns the id which describes at which place the type was registered in the Runtime Type System. More...
 

Detailed Description

RuntimeType contains type and inheritance information of a class and a static dictionary with information on all created instances of RuntimeType.

RuntimeType thus represents the TYPE on an associated class.

Thread-safety: This class is reentrant.

An instance of RuntimeType is associated with a class (e.g., an image processing module like AddModule) and contains

  • the typename of the class ("AddModule")
  • the class, of which it is derived ("Module")
  • a callback function to create an new instance of the class (a new instance of AddModule)

This class has (static) access to a static dictionary, in which entries for all created instances of RuntimeType can be found.

Note that this class does not have a copy constructor or an assignment operator since a RuntimeType needs to be unique in the dictionary. Create a new type with other name if needed.

Definition at line 53 of file mlRuntimeType.h.

Member Typedef Documentation

◆ RuntimeTypeCreateCB

typedef void* ml::RuntimeType::RuntimeTypeCreateCB()

A type of a callback function to create an instance of a class handled by the Runtime class.

Definition at line 57 of file mlRuntimeType.h.

Constructor & Destructor Documentation

◆ RuntimeType()

ML_UTILS_EXPORT ml::RuntimeType::RuntimeType ( const RuntimeType parent = nullptr,
const char *  className = nullptr,
RuntimeTypeCreateCB callback = nullptr,
const char *  dllName = nullptr 
)

Constructor.

Passes the string name of the class type className and the name of dll in dllName. If no dllName is passed, the name of the last most loaded dll is used. If className is passed as NULL, an invalid default bad type is constructed.

◆ ~RuntimeType()

ML_UTILS_EXPORT ml::RuntimeType::~RuntimeType ( )

Destructor. Cleans up all stuff.

Member Function Documentation

◆ canCreateInstance()

bool ml::RuntimeType::canCreateInstance ( ) const
inline

Returns true if this (runtime)type knows how to create an instance of the class.

Definition at line 94 of file mlRuntimeType.h.

Referenced by ml::CopyBase< BASE_DERIVED_CLASS >::checkObjectType(), and ml::ListTemplate< T >::clone().

◆ createInstance()

void* ml::RuntimeType::createInstance ( ) const
inline

Creates and returns an instance of the of the class (NULL if such an instance is unavailable).

Definition at line 98 of file mlRuntimeType.h.

Referenced by ml::ListTemplate< T >::clone().

◆ getCallback()

RuntimeTypeCreateCB* ml::RuntimeType::getCallback ( ) const
inline

Returns the callback used to create an instance of the object or NULL on abstract classes.

Definition at line 101 of file mlRuntimeType.h.

◆ getDllName()

const char* ml::RuntimeType::getDllName ( ) const
inline

Returns the null terminated string name of the source dll or "" if it is unknown.

Definition at line 87 of file mlRuntimeType.h.

◆ getId()

MLint ml::RuntimeType::getId ( ) const
inline

Returns the id which describes at which place the type was registered in the Runtime Type System.

Definition at line 104 of file mlRuntimeType.h.

◆ getName()

const char* ml::RuntimeType::getName ( ) const
inline

Returns the null terminated string name of the class. Returns "BadType" on error.

Definition at line 84 of file mlRuntimeType.h.

Referenced by ml::CopyBase< BASE_DERIVED_CLASS >::checkObjectType(), and ml::ListContainerTemplate< T >::ListContainerTemplate().

◆ getParent()

const RuntimeType* ml::RuntimeType::getParent ( ) const
inline

Returns the parent (runtime)type of the type, i.e., the type it is derived from or NULL if not derived from any other type.

Definition at line 91 of file mlRuntimeType.h.

◆ isDerivedFrom()

ML_UTILS_EXPORT bool ml::RuntimeType::isDerivedFrom ( const RuntimeType runtimeType) const

Returns true if this (runtime)type is derived from the argument (runtime)type runtimeType.

Note that a type is always considered as derived from itself, i.e., a type A is derived from a type A. If a NULL pointer is passed, false is returned.

Referenced by ml::CopyBase< BASE_DERIVED_CLASS >::checkObjectType().


The documentation for this class was generated from the following file: