#include <Factory.h>
Public Methods | |
| bool | registerCreator (const IdentifierType &id, ProductCreator creator) |
| bool | unregisterCreator (const IdentifierType &id) |
| bool | isRegistered (const IdentifierType &id) |
| AbstractProduct * | createObject (const IdentifierType &id) |
Protected Types | |
| typedef std::map< IdentifierType, ProductCreator > | CreatorMap |
Protected Attributes | |
| CreatorMap | mCreatorMap |
AbstractProduct: The base class for the hierarchy for the object factory IndentifierType: The id for indexing the creators (must be sortable) ProductCreator: The callable entity that creates objects. Must support: AbstractProduct* operator(); (ex: functions, functors, classes) default: Simple function of type: AbstractProduct* func() { } FactoryErrorPolicy: The handler for failed lookups. Must support: FactoryErrorImpl<IdentifierType, AbstractProduct> fErrorImpl; AbstractProduct* p = fErrorImpl.onUnknownType(id)
Definition at line 85 of file Factory.h.
|
|||||
|
|
|
||||||||||||||||
|
Definition at line 88 of file Factory.h. References mCreatorMap.
00089 {
00090 // XXX: It would probably be better to use CreatorMap::value_type here.
00091 std::pair<const IdentifierType, ProductCreator> p = std::make_pair(id, creator);
00092 return mCreatorMap.insert(p).second;
00093 }
|
|
||||||||||
|
Definition at line 95 of file Factory.h. References mCreatorMap, and unregisterCreator. Referenced by unregisterCreator.
00096 {
00097 return (mCreatorMap.erase(id) == 1); // return (num_erased == 1)
00098 }
|
|
||||||||||
|
Definition at line 99 of file Factory.h. References mCreatorMap.
00100 {
00101 return ( mCreatorMap.find(id) != mCreatorMap.end());
00102 }
|
|
||||||||||
|
Definition at line 104 of file Factory.h. References mCreatorMap.
00105 {
00106 typename CreatorMap::const_iterator i = mCreatorMap.find(id);
00107 if(i != mCreatorMap.end())
00108 {
00109 return (i->second)();
00110 }
00111
00112 return onUnknownType(id); // Calls template method from FactoryErrorPolicy<>
00113 }
|
|
|||||
|
Definition at line 119 of file Factory.h. Referenced by createObject, isRegistered, registerCreator, and unregisterCreator. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002