MeVisLab Toolbox Reference
ml::Runtime Class Reference

This class contains the runtime system of the ML. More...

#include <mlRuntime.h>

Static Public Member Functions

static void init ()
 Initializes runtime type dictionary.
 
static void destroy ()
 Destroys runtime type dictionary.
 
static const RuntimeTypefromName (const char *name)
 Returns the (runtime)type of a class given by its name using the runtime type dictionary.
 
static const RuntimeTypeinitType (const RuntimeType *classType, const char *parentName, const char *classPrefix, const char *className, RuntimeType::RuntimeTypeCreateCB *createCB, const char *classNameReplacement=nullptr)
 Initializes a new type and tests for double init call.
 
static void destroyType (const char *name)
 Destroys a dictionary entry with a given name.
 
static const RuntimeTypebadType ()
 Returns a global badtype instance of RuntimeType.
 
static void setRecentlyLoadedDllName (const char *name)
 Sets the name of the most recently loaded dll.
 
static const chargetRecentlyLoadedDllName ()
 Returns the name of the most recently loaded dll.
 
static void destroyRuntimeTypesOfDll (const char *dllName)
 Deletes all RuntimeTypes from the runtime dictionary which belong to the the dll with name dllName.
 
static std::vector< const RuntimeType * > getAllDerivedFrom (const RuntimeType *parentType, bool onlyFromDifferentDlls=false)
 Returns a list of all runtime types derived from parentType.
 
static std::vector< const RuntimeType * > getAllTypes ()
 Returns all types that are registered in the typesystem.
 
static const char_getCheckedTypeIdName (const RuntimeType *classType, const char *className)
 Helper function for the runtime interface in Runtime-derived classes to perform some check without having to implement the check code again in classes.
 

Static Protected Member Functions

static const RuntimeTypecreateType (const char *parentName, const char *name, RuntimeType::RuntimeTypeCreateCB *callback)
 Creates a new (runtime)type, representing a class with parent class name parentName, typename name and a callback function callback to create an instance of this class.
 

Detailed Description

This class contains the runtime system of the ML.

It manages a dictionary of runtime types, it can create and remove runtime types. This class contains only static components and must be initialized with init() and destroyed with destroy().

Thread-safety: This class is not thread-safe and should only be used from the main thread. The same applies to the initClass() method of classes derived from the ml::Base class.

Definition at line 49 of file mlRuntime.h.

Member Function Documentation

◆ _getCheckedTypeIdName()

static const char * ml::Runtime::_getCheckedTypeIdName ( const RuntimeType * classType,
const char * className )
static

Helper function for the runtime interface in Runtime-derived classes to perform some check without having to implement the check code again in classes.

It returns the null terminated type name of the runtime type given by classType or the string "<Name of Uninitialized Type>" if the type is still NULL/uninitialized. That case will also cause an ML error message with code ML_TYPE_NOT_REGISTERED. Not for public use!

◆ badType()

static const RuntimeType * ml::Runtime::badType ( )
static

Returns a global badtype instance of RuntimeType.

◆ createType()

static const RuntimeType * ml::Runtime::createType ( const char * parentName,
const char * name,
RuntimeType::RuntimeTypeCreateCB * callback )
staticprotected

Creates a new (runtime)type, representing a class with parent class name parentName, typename name and a callback function callback to create an instance of this class.

The callback may be NULL for abstract types. The type is inserted into the runtime dictionary to be accessible later. When inserting, it is tested whether a same named type exists and if it existed, this function returns NULL because same named types are not supported by the runtime type system. Also an error is send with ML_PRINT_ERROR(). Notifies MLNotify on valid insertion. See mlMLNotify.h for more infos.

◆ destroy()

static void ml::Runtime::destroy ( )
static

Destroys runtime type dictionary.

◆ destroyRuntimeTypesOfDll()

static void ml::Runtime::destroyRuntimeTypesOfDll ( const char * dllName)
static

Deletes all RuntimeTypes from the runtime dictionary which belong to the the dll with name dllName.

This call is ignored if no types are found or a NULL name is passed as dllName.

◆ destroyType()

static void ml::Runtime::destroyType ( const char * name)
static

Destroys a dictionary entry with a given name.

Nothing is done if type is not found. Notifies notify. See mlMLNotify.h for more infos.

◆ fromName()

static const RuntimeType * ml::Runtime::fromName ( const char * name)
static

Returns the (runtime)type of a class given by its name using the runtime type dictionary.

NULL is returned if no runtime type with name is found.

◆ getAllDerivedFrom()

static std::vector< const RuntimeType * > ml::Runtime::getAllDerivedFrom ( const RuntimeType * parentType,
bool onlyFromDifferentDlls = false )
static

Returns a list of all runtime types derived from parentType.

The returned list will be empty if no type is found or if parentType is NULL. parentType itself will not be part of the result. If onlyFromDifferentDlls is false (the default), all derived types are added; if it is true, only types with differing dllNames are added. If dllNames strings are not set, empty or different then the types are considered from different dlls.

◆ getAllTypes()

static std::vector< const RuntimeType * > ml::Runtime::getAllTypes ( )
static

Returns all types that are registered in the typesystem.

◆ getRecentlyLoadedDllName()

static const char * ml::Runtime::getRecentlyLoadedDllName ( )
static

Returns the name of the most recently loaded dll.

Returns NULL if no dll has been loaded.

◆ init()

static void ml::Runtime::init ( )
static

Initializes runtime type dictionary.

◆ initType()

static const RuntimeType * ml::Runtime::initType ( const RuntimeType * classType,
const char * parentName,
const char * classPrefix,
const char * className,
RuntimeType::RuntimeTypeCreateCB * createCB,
const char * classNameReplacement = nullptr )
static

Initializes a new type and tests for double init call.

classType is the still uninitialized pointer to the badType() runtime type instance. parentName is the string name of the parent class type. classPrefix is the string name of a prefix which will be added as prefix before className. className is the string name of the class type itself and createCB is the callback to create an instance of the type. For abstract types it may be NULL. classNameReplacement is an alternative name which can be specified to register the class className under another name, for example to avoid the collision with another initialized version of className; must be NULL if replacement is not desired. All strings must be null-terminated or - if permitted - NULL. Return value is the initialized runtime type on success; classType if type is already initialized, badType() if same type name already exists.

◆ setRecentlyLoadedDllName()

static void ml::Runtime::setRecentlyLoadedDllName ( const char * name)
static

Sets the name of the most recently loaded dll.

Clears name if NULL is passed. Only to be called from the ML!


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