codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#ifndef _ABSTRACT_FACTORY_CLASS_H #define _ABSTRACT_FACTORY_CLASS_H #include "applogic/web/Compliance/tools/TypesCollection.h" template<class T> class AbstractProductCreator { public: virtual T* Create(TypeMapping<T>) = 0; virtual ~AbstractProductCreator() {} }; template < class TCollection, template<class> class Unit = AbstractProductCreator > class AbstractFactory : public GenFractalHierarchy<TCollection, Unit> { public: typedef TCollection ProductList; template<class T> T* Create() { Unit<T>& unit = *(this); return unit.template Create(TypeMapping<T>()); } }; //Default Product creator using "new" template<class ProductImpl, class Base> class ProductCreatorUsingNew: public Base { private: typedef typename Base::ProductList BaseProductList; protected: typedef typename BaseProductList::Tail ProductList; public: typedef typename BaseProductList::Head AbstractProduct; ProductImpl* Create(TypeMapping<AbstractProduct>) { return new ProductImpl; } }; //A Factory implementing the AbstractFactory Interface template < class AbstractFactory, template<class, class> class ProductCreatorUnit = ProductCreatorUsingNew, class TCollection = typename AbstractFactory::ProductList > class AbstractFactoryImpl : public GenStraightHierarchy<typename Compliance::Reverse<TCollection>::Result, ProductCreatorUnit, AbstractFactory> { public: typedef typename AbstractFactory::ProductList ProductList; typedef TCollection ProductImplList; }; #endif
Private
[
?
]
Run code
Submit