![]() |
MAK RTIspy API Documentation for HLA Evolved
|
The DtPluggableFactory class provides a singleton factory class It returns a shared pointer to the created product objects since the caller takes ownership of the created objects. More...
Collaboration diagram for DtPluggableFactory< Key, Product, ProductCreatorParameter >:Public Types | |
| typedef DtBoost::shared_ptr < Product > | DtFactoryProductSP |
| typedef DtFactoryProductSP(* | DtCreatorFn )() |
| typedef DtFactoryProductSP(* | DtParamCreatorFn )(ProductCreatorParameter) |
| typedef std::map< Key, DtCreatorFn > | DtKeyToCreatorMap |
| typedef std::map< Key, DtParamCreatorFn > | DtKeyToParamCreatorMap |
Static Public Member Functions | |
| static bool | isCreatable (const Key &key) |
| static DtFactoryProductSP | create (const Key &key) |
| Returns null if no creator available. | |
| static DtFactoryProductSP | create (const Key &key, ProductCreatorParameter parameter) |
| Returns null if no creator available. | |
| static MAKRti::DtString | registerCreator (const Key &key, DtCreatorFn creator) |
| Overwrites any previously registered creator for key. | |
| static MAKRti::DtString | registerCreator (const Key &key, DtParamCreatorFn creator) |
| Overwrites any previously registered creator for key. | |
Private Member Functions | |
| DtPluggableFactory () | |
| Pluggable factories should not be manually created - they are singletons. | |
| bool | productHasCreator (const Key &key) |
| DtFactoryProductSP | createProduct (const Key &key) |
| DtFactoryProductSP | createProduct (const Key &key, ProductCreatorParameter param) |
| MAKRti::DtString | registerProductCreator (const Key &key, DtCreatorFn creator) |
| MAKRti::DtString | registerProductCreator (const Key &key, DtParamCreatorFn creator) |
Static Private Member Functions | |
| static DtPluggableFactory< Key, Product, ProductCreatorParameter > * | factory () |
Private Attributes | |
| DtKeyToCreatorMap | theCreators |
| DtKeyToParamCreatorMap | theParamCreators |
The DtPluggableFactory class provides a singleton factory class It returns a shared pointer to the created product objects since the caller takes ownership of the created objects.
Since the Factory is implemented as Template, it may not be used across dll boundaries directly. Instead, the user must create a concrete class that wraps the factory and exists entirely within one dll or execution module (it is not safe within static libraries if multiple dlls may link the library). Ex. In .h: class CreatableBaseClass { public: static CreatableBaseClassSP create( unsigned int key ); protected: typedef DtPluggableFactory< unsigned int, CreatableBaseClass, void > DtFactory; }
In .cxx CreatableBaseClassSP CreatableBaseClass::create( unsigned int key ) { if ( !DtFactory::isCreatable( key ) ) throw DtInvalidFactoryKeyException(); return DtFactory::create( key ); }
NOTE: Since the Factory uses stl containers, all Keys must have full value and comparison semantics (ie - const char* is not a good idea, since it doesn't have operator== for other string types use a class like MAKRti::DtString instead)
The factory may be used as a stand-alone factory. In that case, all product classes must register their creators at runtime. Derive product classes from the DtPluggableFactoryProduct template to ease registration by doing the register at static initialization time.
| typedef DtFactoryProductSP(* DtPluggableFactory< Key, Product, ProductCreatorParameter >::DtCreatorFn)() |
| typedef DtBoost::shared_ptr<Product> DtPluggableFactory< Key, Product, ProductCreatorParameter >::DtFactoryProductSP |
| typedef std::map< Key, DtCreatorFn > DtPluggableFactory< Key, Product, ProductCreatorParameter >::DtKeyToCreatorMap |
| typedef std::map< Key, DtParamCreatorFn > DtPluggableFactory< Key, Product, ProductCreatorParameter >::DtKeyToParamCreatorMap |
| typedef DtFactoryProductSP(* DtPluggableFactory< Key, Product, ProductCreatorParameter >::DtParamCreatorFn)(ProductCreatorParameter) |
| DtPluggableFactory< Key, Product, ProductCreatorParameter >::DtPluggableFactory | ( | ) | [private] |
Pluggable factories should not be manually created - they are singletons.
| DtPluggableFactory< Key, Product, ProductCreatorParameter >::DtFactoryProductSP DtPluggableFactory< Key, Product, ProductCreatorParameter >::create | ( | const Key & | key | ) | [static] |
Returns null if no creator available.
Referenced by DtSpyXmlBlock::createChildren().
| DtPluggableFactory< Key, Product, ProductCreatorParameter >::DtFactoryProductSP DtPluggableFactory< Key, Product, ProductCreatorParameter >::create | ( | const Key & | key, |
| ProductCreatorParameter | parameter | ||
| ) | [static] |
Returns null if no creator available.
| DtPluggableFactory< Key, Product, ProductCreatorParameter >::DtFactoryProductSP DtPluggableFactory< Key, Product, ProductCreatorParameter >::createProduct | ( | const Key & | key | ) | [private] |
| DtPluggableFactory< Key, Product, ProductCreatorParameter >::DtFactoryProductSP DtPluggableFactory< Key, Product, ProductCreatorParameter >::createProduct | ( | const Key & | key, |
| ProductCreatorParameter | param | ||
| ) | [private] |
| DtPluggableFactory< Key, Product, ProductCreatorParameter > * DtPluggableFactory< Key, Product, ProductCreatorParameter >::factory | ( | ) | [static, private] |
| bool DtPluggableFactory< Key, Product, ProductCreatorParameter >::isCreatable | ( | const Key & | key | ) | [static] |
| bool DtPluggableFactory< Key, Product, ProductCreatorParameter >::productHasCreator | ( | const Key & | key | ) | [private] |
| MAKRti::DtString DtPluggableFactory< Key, Product, ProductCreatorParameter >::registerCreator | ( | const Key & | key, |
| DtCreatorFn | creator | ||
| ) | [static] |
Overwrites any previously registered creator for key.
| MAKRti::DtString DtPluggableFactory< Key, Product, ProductCreatorParameter >::registerCreator | ( | const Key & | key, |
| DtParamCreatorFn | creator | ||
| ) | [static] |
Overwrites any previously registered creator for key.
| MAKRti::DtString DtPluggableFactory< Key, Product, ProductCreatorParameter >::registerProductCreator | ( | const Key & | key, |
| DtCreatorFn | creator | ||
| ) | [private] |
| MAKRti::DtString DtPluggableFactory< Key, Product, ProductCreatorParameter >::registerProductCreator | ( | const Key & | key, |
| DtParamCreatorFn | creator | ||
| ) | [private] |
DtKeyToCreatorMap DtPluggableFactory< Key, Product, ProductCreatorParameter >::theCreators [private] |
DtKeyToParamCreatorMap DtPluggableFactory< Key, Product, ProductCreatorParameter >::theParamCreators [private] |