iCub-main
|
A template class for the factory pattern. More...
#include <FactoryT.h>
Public Member Functions | |
void | registerPrototype (T *prototype) |
Registers a prototype object that can be used to create clones. | |
T * | create (const K &key) |
Creates a new object given a specific type of key. | |
std::vector< K > | getKeys () |
Returns a vector of the registered keys. | |
Static Public Member Functions | |
static FactoryT< K, T > & | instance () |
An instance retrieval method that follows the Singleton pattern. | |
A template class for the factory pattern.
The factory should be used to create concrete instances of abstract, registered classes.
Definition at line 41 of file FactoryT.h.
|
inline |
Creates a new object given a specific type of key.
The receiving end takes ownership of the returned pointer.
key | a key that identifies the type of machine |
runtime | error if no object has been registered with the same key |
Definition at line 127 of file FactoryT.h.
|
inline |
Returns a vector of the registered keys.
Definition at line 143 of file FactoryT.h.
|
inlinestatic |
An instance retrieval method that follows the Singleton pattern.
Note that this implementation should not be considered thread safe and that problems may arise. However, due to the nature of the expected use this will not be likely to result in problems.
See http://www.oaklib.org/docs/oak/singleton.html for more information.
Definition at line 86 of file FactoryT.h.
|
inline |
Registers a prototype object that can be used to create clones.
Strictly speaking, for this application the object only has to be able to return a new object of its own type, regardless of the internal state of that object.
prototype | the prototype object |
runtime | error if the name of the prototype is empty |
runtime | error if another object is registered with the same name |
Definition at line 101 of file FactoryT.h.