refining the factory model
Status: Alpha
Brought to you by:
madduck
|
From: stephan b. <st...@s1...> - 2004-12-28 16:46:57
|
Yo, libfactory! martin, i know you're on holiday, but i want to go ahead and send this while i'm thinking about it... As part of the pclasses.com/s11n.net colaboration, Christian Prochnow (project lead) asked me if i would like to rewrite their Factory layer for their 1.x ==> 2.x rewrite. Maybe they were just kidding, but i happily accepted. i looked over their Factory implementation, then took what i learned from their code and applied it to the basic model laid out by s11n's factory. So far, i'm extremely pleased with the results. i've gotten some great re-use out of the Factory class in the rest of the P tree, replacing the various P1.x Factories/PluginManagers with simple subclasses or typedefs of this implementation. Currently it provides the plugin support for MimeTypes, Serializers, and arbitrary client-side types, and will later support the IOManger layer, to dispatch to i/o handlers based on URL protocols. Attached is what the base factory looks like. i've also included a couple supplemental headers it currently needs. You'll notice that it doesn't have dll support. That's all fine and good, because clients can plug in their own by providing a template specialization of FactoryInstanceHook<FactoryT>. This how i've done it in the P tree: the DLL-aware layer (not part of the core module) plugs in it's own handler, such that Factory<T>::instance() returns a DLL-aware Factory instance. The factory registration supermacro is in FactoryReg.h. i really like P's "SharedLib" abstraction, and will implement something similar to abstract away the platform-specific details of opening a DLL for libfactory. P currently supports 5 or 6 different DLL loaders using their model, and i believe i can support libltdl, libdl and Win32 (the others are obscure platforms i won't have access to). Please give a look to the Factory class and let me know if this seems like a usable model for libfactory. As part of s11n 1.1 i will be cleaning up the factory interface so we can plug in libfac to it. See ya! -- ----- st...@s1... http://s11n.net "...pleasure is a grace and is not obedient to the commands of the will." -- Alan W. Watts |