#include <factory.h>
Implemented using the Singleton pattern.
Singleton means that only one instance of the object exists, ever. This is accomplished with the static Instance() method. -jh
Definition at line 70 of file factory.h.
Public Types | |
| typedef std::map< classIDKey, BASE_CREATE_FN > | FN_REGISTRY |
| FN_REGISTRY is the registry of all the BASE_CREATE_FN pointers registered. | |
Public Member Functions | |
| void | regCreateFn (const classIDKey &, BASE_CREATE_FN) |
| Classes derived from manufacturedObj call this function once per program to register the class ID key, and a pointer to the function that creates the class. | |
| std::auto_ptr< manufacturedObj > | create (const classIDKey &className) const |
| Create a new class of the type specified by className. | |
Static Public Member Functions | |
| genericFactory & | instance () |
| Singleton access. | |
Public Attributes | |
| FN_REGISTRY | registry |
Private Types | |
| typedef std::auto_ptr< manufacturedObj >(* | BASE_CREATE_FN )() |
| returns an auto_ptr to a manufactuedObj. | |
Private Member Functions | |
| genericFactory () | |
| Singleton implementation - private ctor & copying, with no implementation on the copying. | |
| genericFactory (const genericFactory &) | |
| Not implemented. | |
| genericFactory & | operator= (const genericFactory &) |
| Not implemented. | |
|
|||||
|
returns an auto_ptr to a manufactuedObj. Note that we use no parameters, but you could add them easily enough to allow overloaded ctors. typedef std::auto_ptr<manufacturedObj> (*BASE_CREATE_FN)(int); Definition at line 79 of file factory.h. Referenced by genericFactory< manufacturedObj, classIDKey >::regCreateFn(). |
|
|||||
|
FN_REGISTRY is the registry of all the BASE_CREATE_FN pointers registered. Functions are registered using the regCreateFn member function.
|
|
|||||||||
|
Singleton implementation - private ctor & copying, with no implementation on the copying.
|
|
||||||||||
|
Not implemented.
|
|
||||||||||
|
Create a new class of the type specified by className.
Definition at line 170 of file factory.h. References genericFactory< manufacturedObj, classIDKey >::registry. |
|
|||||||||
|
Singleton access.
Definition at line 147 of file factory.h. Referenced by registerInFactory< ancestorType, manufacturedObj, classIDKey >::registerInFactory(). |
|
||||||||||
|
Not implemented.
|
|
||||||||||||||||
|
Classes derived from manufacturedObj call this function once per program to register the class ID key, and a pointer to the function that creates the class. This simply associates the classIDKey with the function used to create the class. The return value is a dummy value, which is used to allow static initialization of the registry. See example implementations in base.cpp and derived.cpp. Definition at line 160 of file factory.h. References genericFactory< manufacturedObj, classIDKey >::BASE_CREATE_FN, and genericFactory< manufacturedObj, classIDKey >::registry. Referenced by registerInFactory< ancestorType, manufacturedObj, classIDKey >::registerInFactory(). |
|
|||||
|
Definition at line 96 of file factory.h. Referenced by genericFactory< manufacturedObj, classIDKey >::create(), and genericFactory< manufacturedObj, classIDKey >::regCreateFn(). |
1.3.4