ML Reference
|
This file declares the class RuntimeDict, which manages a set of instances of class RuntimeTypes
.
More...
#include <mlRuntimeDict.h>
Public Member Functions | |
RuntimeDict (MLuint32 tableSize=211) | |
Creates new dictionary (as a hash table) with the given tableSize (tableSize should be prime number). | |
~RuntimeDict () | |
Destructor. Removes dictionary and all stored runtime types. | |
void | clear (bool applyFinalCheck=false) |
Clears all dictionary entries and stored runtime types. | |
RuntimeDictEntry * | insert (const RuntimeType *runtimeType) |
Inserts an new type into the runtime dictionary. | |
const RuntimeType * | remove (const char *className) |
Removes the element for the given className className . | |
const RuntimeType * | get (const char *className) const |
Returns the runtime type for a given className (or NULL if not element present). | |
void * | createInstanceFromName (const char *className) const ML_RETURN_VALUE_SHOULD_BE_USED |
Returns a pointer to a newly created instance of the runtime type or NULL if such an instance cannot be created (e.g., if type is not available or the class name is wrong). | |
const RuntimeType * | first () |
Returns the first runtime type in the dictionary (or NULL in case of an empty dictionary). | |
const RuntimeType * | next () |
Returns the next runtime type in the dictionary (or NULL in case of no further elements). | |
void | destroyRuntimeTypesOfDll (const char *dllName) |
Deletes all RuntimeTypes from the runtime dictionary which belong to the the dll with name dllName . | |
std::list< const RuntimeType * > | getAllDerivedFrom (const RuntimeType *parentType, bool onlyFromDifferentDlls=false) |
Returns a list of all runtime types derived from parentType . | |
std::list< const RuntimeType * > | getAllRuntimeTypesOfDll (const char *dllName) |
Returns a list of all runtime types implemented by dll with name dllName . |
This file declares the class RuntimeDict, which manages a set of instances of class RuntimeTypes
.
The class Runtime
uses one global instance of this class for the runtime type system of the ml. See also classes Runtime
and RuntimeType
. Thread-safety: This class is reentrant.
Definition at line 39 of file mlRuntimeDict.h.
ml::RuntimeDict::RuntimeDict | ( | MLuint32 | tableSize = 211 | ) |
Creates new dictionary (as a hash table) with the given tableSize
(tableSize
should be prime number).
Must be greater 1.
ml::RuntimeDict::~RuntimeDict | ( | ) |
Destructor. Removes dictionary and all stored runtime types.
void ml::RuntimeDict::clear | ( | bool | applyFinalCheck = false | ) |
Clears all dictionary entries and stored runtime types.
If applyFinalCheck
is enabled, a report is generated as fatal error if any runtime type still contains non zero instance counters. Otherwise no check is performed.
void* ml::RuntimeDict::createInstanceFromName | ( | const char * | className | ) | const |
Returns a pointer to a newly created instance of the runtime type or NULL if such an instance cannot be created (e.g., if type is not available or the class name is wrong).
Empty className
strings or NULL pointers are handled as ML_BAD_PARAMETER error. NULL is returned then. The caller is responsible for deleting the returned object.
void ml::RuntimeDict::destroyRuntimeTypesOfDll | ( | const char * | dllName | ) |
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
.
const RuntimeType* ml::RuntimeDict::first | ( | ) |
const RuntimeType* ml::RuntimeDict::get | ( | const char * | className | ) | const |
Returns the runtime type for a given className
(or NULL if not element present).
Empty className
strings or NULL pointers are handled as ML_BAD_PARAMETER error. NULL is returned then.
std::list<const RuntimeType*> ml::RuntimeDict::getAllDerivedFrom | ( | const RuntimeType * | parentType, |
bool | onlyFromDifferentDlls = false |
||
) |
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. 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, the types are considered from different dlls.
std::list<const RuntimeType *> ml::RuntimeDict::getAllRuntimeTypesOfDll | ( | const char * | dllName | ) |
Returns a list of all runtime types implemented by dll with name dllName
.
The returned list will be empty if no type is found or if dllName
is NULL or invalid.
RuntimeDictEntry* ml::RuntimeDict::insert | ( | const RuntimeType * | runtimeType | ) |
Inserts an new type into the runtime dictionary.
Double insertation of types is prohibited and handled with a ML_PROGRAMMING_ERROR error and a NULL return since a type cannot be inserted twice. NULL as runtimeType
is handled with ML_BAD_PARAMETER error and also NULL is returned.
const RuntimeType* ml::RuntimeDict::next | ( | ) |
const RuntimeType* ml::RuntimeDict::remove | ( | const char * | className | ) |
Removes the element for the given className className
.
The entry in the dictionary is removed and the type is returned. Note that the calling instance is responsible for deleting the returned RuntimeType instance. Empty className
strings or NULL pointers are handled as ML_BAD_PARAMETER error. NULL is returned then.