V-Gears 0
Free Final Fantasy VII engine.
ObjectFactory< KeyType, BaseType > Class Template Reference

Generic factory for a class and its subclasses. More...

#include <ObjectFactory.h>

Public Member Functions

template<typename Type >
void AddEntry (const KeyType &key)
 Register a new entry. More...
 
BaseType * Create (const KeyType &key) const
 Creates an instance of some registered class. More...
 

Private Types

typedef BaseType *(* CreateFunc) ()
 Function pointer to the object creation function. More...
 
typedef std::map< KeyType, CreateFuncRegistryMap
 Type used to store registered entries. More...
 

Private Attributes

RegistryMap registry_
 Map from an identifier to a creation function. More...
 

Detailed Description

template<typename KeyType, typename BaseType>
class ObjectFactory< KeyType, BaseType >

Generic factory for a class and its subclasses.

Member Typedef Documentation

◆ CreateFunc

template<typename KeyType , typename BaseType >
typedef BaseType *(* ObjectFactory< KeyType, BaseType >::CreateFunc) ()
private

Function pointer to the object creation function.

◆ RegistryMap

template<typename KeyType , typename BaseType >
typedef std::map<KeyType, CreateFunc> ObjectFactory< KeyType, BaseType >::RegistryMap
private

Type used to store registered entries.

Member Function Documentation

◆ AddEntry()

template<typename KeyType , typename BaseType >
template<typename Type >
void ObjectFactory< KeyType, BaseType >::AddEntry ( const KeyType &  key)
inline

Register a new entry.

Parameters
[in]keyThe key to register the class under.

◆ Create()

template<typename KeyType , typename BaseType >
BaseType * ObjectFactory< KeyType, BaseType >::Create ( const KeyType &  key) const
inline

Creates an instance of some registered class.

Parameters
[in]keyThe key associated with the desired class.
Returns
NULL if the name is not registered, else an instance of the associated class.

Member Data Documentation

◆ registry_

template<typename KeyType , typename BaseType >
RegistryMap ObjectFactory< KeyType, BaseType >::registry_
private

Map from an identifier to a creation function.


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