From: stephan b. <sg...@us...> - 2004-12-25 16:37:57
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31576/include/pclasses Modified Files: Factory.h Log Message: More tweaking of the interface. Index: Factory.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Factory.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- Factory.h 25 Dec 2004 02:45:48 -0000 1.9 +++ Factory.h 25 Dec 2004 16:37:47 -0000 1.10 @@ -51,7 +51,7 @@ The type returned by create() and operator(). */ - typedef T * result_type; + typedef T * ResultType; /** A typedef for the second template parameter for this @@ -72,7 +72,7 @@ The caller owns the returned pointer, which may be 0. */ - static result_type create() + static ResultType create() { return new actual_type; } @@ -80,7 +80,7 @@ /** Same as create(). */ - result_type operator()() + ResultType operator()() { return create(); } @@ -195,7 +195,7 @@ Same as (InterfaceT *), for conformance with the Adaptable Unary Functor model. */ - typedef InterfaceT * result_type; + typedef InterfaceT * ResultType; /** @@ -222,13 +222,13 @@ todo: implement proper functor support. */ - typedef result_type ( *factory_type ) (); + typedef ResultType ( *factory_func_type ) (); /** Internal container type used for mapping keys to factories. */ - typedef std::map < key_type, factory_type > FactoryMap; + typedef std::map < key_type, factory_func_type > FactoryMap; /** @@ -238,7 +238,7 @@ Subtypes are free to implement, e.g., DLL lookups. */ - virtual result_type create( const key_type & key ) + virtual ResultType create( const key_type & key ) { typename FactoryMap::const_iterator it = factoryMap().find( key ); if ( it != factoryMap().end() ) // found a factory? @@ -261,7 +261,7 @@ Subclasses are free to dictate a must-destroy() policy if they wish. */ - virtual void destroy( result_type obj ) + virtual void destroy( ResultType obj ) { delete obj; } @@ -269,7 +269,7 @@ /** Returns this->create(key). */ - result_type operator()( const key_type & key ) + ResultType operator()( const key_type & key ) { return this->internal( key ); } @@ -284,7 +284,7 @@ value_type. See the FactoryCreateHook class for a factory which does this subtype-to-base conversion. */ - void registerFactory( const key_type & key, factory_type fp ) + virtual void registerFactory( const key_type & key, factory_func_type fp ) { // CERR << "registerFactory("<<key<<",facfunc)\n"; factoryMap().insert( FactoryMap::value_type( key, fp ) ); @@ -342,6 +342,11 @@ template <typename InterfaceT> struct NamedTypeFactory : public Factory< InterfaceT, Sharing::FactoryContext, std::string > { + typedef Factory< InterfaceT, Sharing::FactoryContext, std::string > ParentType; + + typedef typename ParentType::ResultType ResultType; + typedef typename ParentType::factory_func_type factory_func_type; + virtual ~NamedTypeFactory(){} }; |