MIRA
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Friends | List of all members
ClassFactory Class Reference

What should i say, the class factory. More...

#include <factory/Factory.h>

Inheritance diagram for ClassFactory:
Inheritance graph
[legend]

Public Types

typedef Base::Type Type
 

Public Member Functions

 ClassFactory ()
 
 ~ClassFactory ()
 

Static Public Member Functions

template<typename CLASS >
static CLASS * newInstance (std::string const &classIdentifier)
 Create new instance of the class defined by class identifier. More...
 
template<typename CLASS >
static CLASS * newInstance (std::string const &classIdentifier, int paramCount,...)
 Create new instance of the class defined by class identifier. More...
 
template<typename CLASS >
static CLASS * newInstance (std::string const &classIdentifier, int paramCount, std::va_list list)
 
static bool isClassRegistered (std::string const &classIdentifier)
 Return true if a class with the desired identifier is registered. More...
 
static ClassProxy getClassByIdentifier (std::string const &classIdentifier)
 Return the Class object for the desired Class. More...
 
static std::vector< ClassProxygetClassByMeta (std::string const &metaKey, std::string const &metaValue)
 Return list of Class objects matching the meta criterion. More...
 
template<class T >
static std::vector< ClassProxygetClassByMeta (T funcPtr)
 Return list of Class objects returning true for the given comparison function. More...
 
static std::map< std::string, ClassProxygetDerivedClasses ()
 Return list of registered classes. More...
 
static void registerClass (boost::shared_ptr< Class > iClass)
 Register Class. More...
 
static void registerClass (boost::shared_ptr< Class > iClass, boost::shared_ptr< Class > baseClass)
 Register Class. More...
 
static void unregisterClass (Class *iClass)
 Unregister Class. More...
 
static void postRegisterBaseClasses (std::string const &iClass, std::vector< std::string > const &parents)
 Register Parent - Child relationship. More...
 
static void finalizePostRegister ()
 Propagate all children to indirect parents and add meta information of parent classes to children. More...
 
static Typeinstance ()
 Returns a reference to the singleton instance. More...
 
static bool isDestroyed ()
 Returns true, if the singleton was already destroyed. More...
 

Protected Member Functions

void propagateChild (ClassProxy &child, Class &parent)
 Auxiliary function to propagate child classes to indirect parents. More...
 
bool internalClassRegister (boost::shared_ptr< Class > iClass)
 Internal function to register a class. More...
 

Static Protected Member Functions

static TypemakeInstance ()
 
static void destroyInstance (void)
 

Friends

class ClassProxy
 
class LightFactoryMutexGetter
 
class VacantClass
 

Detailed Description

What should i say, the class factory.

The class factory is capable to construct instances of registered classes using the factory macros. Class objects can be accessed using the identifier or the meta information of the class.

Member Typedef Documentation

◆ Type

typedef Base::Type Type
inherited

Constructor & Destructor Documentation

◆ ClassFactory()

ClassFactory ( )
inline

◆ ~ClassFactory()

Member Function Documentation

◆ newInstance() [1/3]

CLASS * newInstance ( std::string const &  classIdentifier)
inlinestatic

Create new instance of the class defined by class identifier.

The created class is casted to the class type defined by CLASS.

Exceptions
XFactoryBadCastIf dynamic cast to desired class type fails
XFactoryUnknownIf the given identifier is unknown
XFactoryLogicalIf the class creation fails.

◆ newInstance() [2/3]

CLASS * newInstance ( std::string const &  classIdentifier,
int  paramCount,
  ... 
)
inlinestatic

Create new instance of the class defined by class identifier.

Additional constructor parameters can be passed using the va_list. The created class is casted to the class type defined by CLASS.

Exceptions
XFactoryBadCastIf dynamic cast to desired class type fails
XFactoryUnknownIf the given identifier is unknown
XFactoryLogicalIf the class creation fails.

◆ newInstance() [3/3]

CLASS * newInstance ( std::string const &  classIdentifier,
int  paramCount,
std::va_list  list 
)
inlinestatic

◆ isClassRegistered()

static bool isClassRegistered ( std::string const &  classIdentifier)
inlinestatic

Return true if a class with the desired identifier is registered.

◆ getClassByIdentifier()

static ClassProxy getClassByIdentifier ( std::string const &  classIdentifier)
inlinestatic

Return the Class object for the desired Class.

See also
Class::getClassByIdentifier()

◆ getClassByMeta() [1/2]

static std::vector<ClassProxy> getClassByMeta ( std::string const &  metaKey,
std::string const &  metaValue 
)
inlinestatic

Return list of Class objects matching the meta criterion.

See also
Class::getClassByMeta(std::string const& metaKey, std::string const& metaValue )

◆ getClassByMeta() [2/2]

static std::vector<ClassProxy> getClassByMeta ( funcPtr)
inlinestatic

Return list of Class objects returning true for the given comparison function.

See also
Class::getClassByMeta( T funcPtr, std::vector<ClassProxy>& pResult )

◆ getDerivedClasses()

static std::map<std::string, ClassProxy > getDerivedClasses ( )
inlinestatic

Return list of registered classes.

◆ registerClass() [1/2]

static void registerClass ( boost::shared_ptr< Class iClass)
static

Register Class.

You normally don't have to call this function. Use the Macros instead.

Exceptions
XFactoryLogicalIf class identifier is already in use

◆ registerClass() [2/2]

static void registerClass ( boost::shared_ptr< Class iClass,
boost::shared_ptr< Class baseClass 
)
static

Register Class.

You normally don't have to call this function. Use the Macros instead.

Exceptions
XFactoryLogicalIf class identifier is already in use
XFactoryLogicalIf base class and class do have the same identifiers.

◆ unregisterClass()

static void unregisterClass ( Class iClass)
static

Unregister Class.

Remove the class from the list of known classes and reduce the class tree.

◆ postRegisterBaseClasses()

static void postRegisterBaseClasses ( std::string const &  iClass,
std::vector< std::string > const &  parents 
)
static

Register Parent - Child relationship.

You normally don't have to call this function. Use the Macros instead.

Exceptions
XFactoryUnknownif one ore more identifiers are unknown

◆ finalizePostRegister()

static void finalizePostRegister ( )
static

Propagate all children to indirect parents and add meta information of parent classes to children.

You normally don't have to call this function. Use the Macros instead.

◆ propagateChild()

void propagateChild ( ClassProxy child,
Class parent 
)
protected

Auxiliary function to propagate child classes to indirect parents.

◆ internalClassRegister()

bool internalClassRegister ( boost::shared_ptr< Class iClass)
protected

Internal function to register a class.

Used by registerClass() with and without parent.

◆ instance()

static Type& instance ( )
inlinestaticinherited

Returns a reference to the singleton instance.

Exceptions
XLogicalIf the singleton was already destroyed (dead reference) or not yet created (when using ExplicitInstantiation).

◆ isDestroyed()

static bool isDestroyed ( )
inlinestaticinherited

Returns true, if the singleton was already destroyed.

Trying to access it will result in an exception.

◆ makeInstance()

static Type* makeInstance ( )
inlinestaticprotectedinherited

◆ destroyInstance()

static void destroyInstance ( void  )
inlinestaticprotectedinherited

Friends And Related Function Documentation

◆ ClassProxy

friend class ClassProxy
friend

◆ LightFactoryMutexGetter

friend class LightFactoryMutexGetter
friend

◆ VacantClass

friend class VacantClass
friend

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