Factory template class. More...
#include <Factory.h>
Classes | |
class | FactoryEntry |
FactoryEntry class. | |
Public Types | |
enum | ReturnCode { FACTORY_OK, FACTORY_ERROR, ALREADY_EXISTS, NOT_FOUND, INVALID_ARG, UNKNOWN_ERROR } |
typedef std::map< Identifier, FactoryEntry > | FactoryMap |
typedef FactoryMap::iterator | FactoryMapIt |
typedef std::map < AbstractClass *, FactoryEntry > | ObjectMap |
typedef ObjectMap::iterator | ObjectMapIt |
Public Member Functions | |
bool | hasFactory (const Identifier &id) |
Factory presence check. | |
std::vector< Identifier > | getIdentifiers () |
Get factory ID list. | |
ReturnCode | addFactory (const Identifier &id, Creator creator, Destructor destructor) |
Add factory. | |
ReturnCode | removeFactory (const Identifier &id) |
Remove factory. | |
AbstractClass * | createObject (const Identifier &id) |
Create factory object. | |
ReturnCode | deleteObject (const Identifier &id, AbstractClass *&obj) |
Delete factory object. | |
ReturnCode | deleteObject (AbstractClass *&obj) |
Delete factory object. | |
std::vector< AbstractClass * > | createdObjects () |
Getting created objects. | |
bool | isProducerOf (AbstractClass *obj) |
Whether a object is a product of this factory. | |
ReturnCode | objectToIdentifier (AbstractClass *obj, Identifier &id) |
Getting class identifier (ID) from a object. | |
Creator | objectToCreator (AbstractClass *obj) |
Getting destructor of the object. | |
Destructor | objectToDestructor (AbstractClass *obj) |
Getting destructor of the object. |
Factory template class.
typedef std::map<Identifier, FactoryEntry> coil::Factory< AbstractClass, Identifier, Compare, Creator, Destructor >::FactoryMap |
typedef FactoryMap::iterator coil::Factory< AbstractClass, Identifier, Compare, Creator, Destructor >::FactoryMapIt |
typedef std::map<AbstractClass*, FactoryEntry> coil::Factory< AbstractClass, Identifier, Compare, Creator, Destructor >::ObjectMap |
typedef ObjectMap::iterator coil::Factory< AbstractClass, Identifier, Compare, Creator, Destructor >::ObjectMapIt |
enum coil::Factory::ReturnCode |
ReturnCode coil::Factory< AbstractClass, Identifier, Compare, Creator, Destructor >::addFactory | ( | const Identifier & | id, | |
Creator | creator, | |||
Destructor | destructor | |||
) | [inline] |
Add factory.
Add a factory.
id | Factory ID. | |
creator | Functor for creator. | |
destructor | Functor for destructor. |
std::vector<AbstractClass*> coil::Factory< AbstractClass, Identifier, Compare, Creator, Destructor >::createdObjects | ( | ) | [inline] |
Getting created objects.
This operation returns a list of created objects by the factory.
AbstractClass* coil::Factory< AbstractClass, Identifier, Compare, Creator, Destructor >::createObject | ( | const Identifier & | id | ) | [inline] |
Create factory object.
Create a factory object.
id | Factory ID. |
ReturnCode coil::Factory< AbstractClass, Identifier, Compare, Creator, Destructor >::deleteObject | ( | AbstractClass *& | obj | ) | [inline] |
ReturnCode coil::Factory< AbstractClass, Identifier, Compare, Creator, Destructor >::deleteObject | ( | const Identifier & | id, | |
AbstractClass *& | obj | |||
) | [inline] |
std::vector<Identifier> coil::Factory< AbstractClass, Identifier, Compare, Creator, Destructor >::getIdentifiers | ( | ) | [inline] |
Get factory ID list.
Return a list of factory ID.
bool coil::Factory< AbstractClass, Identifier, Compare, Creator, Destructor >::hasFactory | ( | const Identifier & | id | ) | [inline] |
bool coil::Factory< AbstractClass, Identifier, Compare, Creator, Destructor >::isProducerOf | ( | AbstractClass * | obj | ) | [inline] |
Whether a object is a product of this factory.
obj | A target object |
Creator coil::Factory< AbstractClass, Identifier, Compare, Creator, Destructor >::objectToCreator | ( | AbstractClass * | obj | ) | [inline] |
Getting destructor of the object.
This operation returns a constructor of the object created by the factory. obj must be a product of the factory. User must check if the object is a product of the factory by using isProducerOf()-function, before using this function.
Destructor coil::Factory< AbstractClass, Identifier, Compare, Creator, Destructor >::objectToDestructor | ( | AbstractClass * | obj | ) | [inline] |
Getting destructor of the object.
This operation returns a destructor of the object created by the factory. obj must be a product of the factory. User must check if the object is a product of the factory by using isProducerOf()-function, before using this function.
ReturnCode coil::Factory< AbstractClass, Identifier, Compare, Creator, Destructor >::objectToIdentifier | ( | AbstractClass * | obj, | |
Identifier & | id | |||
) | [inline] |
Getting class identifier (ID) from a object.
This operation returns a class identifier (ID) from a object.
obj | [in] An object to investigate its class ID. | |
id | [out] Class identifier (ID) |
ReturnCode coil::Factory< AbstractClass, Identifier, Compare, Creator, Destructor >::removeFactory | ( | const Identifier & | id | ) | [inline] |
Remove factory.
Remove a factory.
id | Factory ID. |