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>

Public Member Functions

 RuntimeDict ()
 Creates new dictionary.
 
 ~RuntimeDict ()
 Destructor. Removes dictionary and all stored runtime types.
 
void clear ()
 Clears all dictionary entries and stored runtime types.
 
bool insert (const RuntimeType *runtimeType)
 Inserts an new type into the runtime dictionary.
 
bool remove (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
 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).
 
void destroyRuntimeTypesOfDll (const char *dllName)
 Deletes all RuntimeTypes from the runtime dictionary which belong to the the dll with name dllName.
 
std::vector< const RuntimeType * > getAllDerivedFrom (const RuntimeType *parentType, bool onlyFromDifferentDlls=false)
 Returns a list of all runtime types derived from parentType.
 
std::vector< const RuntimeType * > getAllRuntimeTypesOfDll (const char *dllName)
 Returns a list of all runtime types implemented by dll with name dllName.
 
std::vector< const RuntimeType * > getAllTypes ()
 Returns all registered types.
 

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 43 of file mlRuntimeDict.h.

Constructor & Destructor Documentation

◆ RuntimeDict()

ml::RuntimeDict::RuntimeDict ( )

Creates new dictionary.

◆ ~RuntimeDict()

ml::RuntimeDict::~RuntimeDict ( )

Destructor. Removes dictionary and all stored runtime types.

Member Function Documentation

◆ clear()

void ml::RuntimeDict::clear ( )

Clears all dictionary entries and stored runtime types.

◆ createInstanceFromName()

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.

◆ destroyRuntimeTypesOfDll()

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.

◆ get()

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.

◆ getAllDerivedFrom()

std::vector< 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. 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, the types are considered from different dlls.

◆ getAllRuntimeTypesOfDll()

std::vector< 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.

◆ getAllTypes()

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

Returns all registered types.

◆ insert()

bool ml::RuntimeDict::insert ( const RuntimeType * runtimeType)

Inserts an new type into the runtime dictionary.

Double insertion of types is prohibited and handled with a ML_PROGRAMMING_ERROR error and a false return since a type cannot be inserted twice. NULL as runtimeType is handled with ML_BAD_PARAMETER error and also NULL is returned. Ownership of the type is passed to the dict, if the insertion fails, the type will be deleted.

◆ remove()

bool ml::RuntimeDict::remove ( const char * className)

Removes the element for the given className className.

The entry in the dictionary is removed (and deleted). If the entry does not exist, false is returned. 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: