Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

genericFactory< manufacturedObj, classIDKey > Class Template Reference

#include <factory.h>

List of all members.


Detailed Description

template<class manufacturedObj, typename classIDKey = defaultIDKeyType>
class genericFactory< manufacturedObj, classIDKey >

The abstract factory itself.

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

genericFactoryinstance ()
 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.

genericFactoryoperator= (const genericFactory &)
 Not implemented.


Member Typedef Documentation

template<class manufacturedObj, typename classIDKey = defaultIDKeyType>
genericFactory< manufacturedObj, classIDKey >::BASE_CREATE_FN [private]
 

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().

template<class manufacturedObj, typename classIDKey = defaultIDKeyType>
typedef std::map<classIDKey, BASE_CREATE_FN> genericFactory< manufacturedObj, classIDKey >::FN_REGISTRY
 

FN_REGISTRY is the registry of all the BASE_CREATE_FN pointers registered.

Functions are registered using the regCreateFn member function.

Note:
Made public to be able to list elements in factory. -jh

Definition at line 95 of file factory.h.


Constructor & Destructor Documentation

template<class manufacturedObj, typename classIDKey>
genericFactory< manufacturedObj, classIDKey >::genericFactory  )  [private]
 

Singleton implementation - private ctor & copying, with no implementation on the copying.

Definition at line 139 of file factory.h.

template<class manufacturedObj, typename classIDKey = defaultIDKeyType>
genericFactory< manufacturedObj, classIDKey >::genericFactory const genericFactory< manufacturedObj, classIDKey > &   )  [private]
 

Not implemented.


Member Function Documentation

template<class manufacturedObj, typename classIDKey>
std::auto_ptr< manufacturedObj > genericFactory< manufacturedObj, classIDKey >::create const classIDKey &  className  )  const
 

Create a new class of the type specified by className.

Definition at line 170 of file factory.h.

References genericFactory< manufacturedObj, classIDKey >::registry.

template<class manufacturedObj, typename classIDKey>
genericFactory< manufacturedObj, classIDKey > & genericFactory< manufacturedObj, classIDKey >::instance  )  [static]
 

Singleton access.

Note:
Not thread-safe.

Definition at line 147 of file factory.h.

Referenced by registerInFactory< ancestorType, manufacturedObj, classIDKey >::registerInFactory().

template<class manufacturedObj, typename classIDKey = defaultIDKeyType>
genericFactory& genericFactory< manufacturedObj, classIDKey >::operator= const genericFactory< manufacturedObj, classIDKey > &   )  [private]
 

Not implemented.

template<class manufacturedObj, typename classIDKey>
void genericFactory< manufacturedObj, classIDKey >::regCreateFn const classIDKey &  clName,
BASE_CREATE_FN  func
 

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().


Member Data Documentation

template<class manufacturedObj, typename classIDKey = defaultIDKeyType>
FN_REGISTRY genericFactory< manufacturedObj, classIDKey >::registry
 

Definition at line 96 of file factory.h.

Referenced by genericFactory< manufacturedObj, classIDKey >::create(), and genericFactory< manufacturedObj, classIDKey >::regCreateFn().


The documentation for this class was generated from the following file:
Generated on Mon Jun 28 15:02:17 2004 for Advanced Surface Library by doxygen 1.3.4