From: stephan b. <st...@s1...> - 2004-12-23 04:54:42
|
include/pclasses/Factory.h i haven't tested it, nor fully instantiated all of the template code yet (my build tree only halfway works), but it is syntactically okay and almost fully documented. The P-side interface is essentially 3 functions: template <class Base> void P::CL::registerBase( string [, factory_func] ); template <class Base, class SubT> void P::CL::registerSubtype( string [, factory_func] ); template <class Base> Base * P::CL::classload( string ); Those funcs use a Factory<>::instance(). The factory uses P::Hook::FactoryInstanceHook<FactoryT> to provide a shared object. This allows clients to specialize that type to customize the object returned by Factory::instance(). e.g., they can add DLL support to the core API without the core knowing it. Clients can also specialize P::Hook::FactoryCreateHook<Base,Sub> to completely override the default new-object implementations. This is necessary when, e.g, Base is abstract (and therefor 'new Base' won't work). See the docs for full details. i don't like the CL namespace, and may rename registerXXX() to P::cl_registerXXX(). Opinions? i did a complete re-think of the s11n CL layer in this port, so there may be several bugs laying around. -- ----- st...@s1... http://s11n.net "...pleasure is a grace and is not obedient to the commands of the will." -- Alan W. Watts |