ML Reference
ml::RuntimeDict Class Reference

This file declares the class RuntimeDict, which manages a set of instances of class RuntimeTypes. More...

#include <mlRuntimeDict.h>

List of all members.

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 RuntimeTyperemove (const char *className)
 Removes the element for the given className className.
const RuntimeTypeget (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 RuntimeTypefirst ()
 Returns the first runtime type in the dictionary (or NULL in case of an empty dictionary).
const RuntimeTypenext ()
 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.

Detailed Description

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.


Constructor & Destructor Documentation

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.


Member Function Documentation

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 ( )

Returns the first runtime type in the dictionary (or NULL in case of an empty dictionary).

Note that the application must verify that no other operations like inserts/removes/clears are called between first() and next() calls.

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 ( )

Returns the next runtime type in the dictionary (or NULL in case of no further elements).

Note that the application must verify that no other operations like inserts/removes/clears are called between first() and next() calls.

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.


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