From: stephan b. <st...@s1...> - 2004-12-25 17:24:08
|
How about this idea: Dispatch DLL loads based on the extension of the actual file. Platforms which support more than one loader/binary format could use this to load different lib formats. Also, client code could subclasses SharedLib to provide DLL-like interfaces into non-DLL structures, like XML files or app-specific plugin interfaces. The implementation for this is trivial: SharedLibDispatcher : public PluginManager<SharedLib> { // this class inherits: // void registerFactory( const string & extension, // SharedLib * (*factory_func)() ); virtual SharedLib * create(const string &); // ^^^ overridden, assuming string is a file name, loads // the proper extension handler, and returns that handler ... // plus convenience funcs for finding DLLs via // path searching. }; One implication is that we would need to: a) change SharedLib to be default constructable (so we can instantiate it via a generic factory) and add API to be able to open the lib post-ctor. We should do this, anyway. or b) refactor the factory support ("refactorying") to somehow support passing args to ctors via factories. So far i don't have an idea for how to generically pass args to ctors via factories. or c) It wouldn't be hard to implement a custom factory interface which forces passing one argument to the ctor. In this case we would pass a string (the file name): class Factory<InterfaceT,[ContextT,?]KeyT,Arg1T> { void registerFactory( const KeyT & key, InterfaceT * (*fac_func) (Arg1T) ); InterfaceT * create( const KeyT & key, Arg1T arg ); ... }; ??? -- ----- st...@s1... http://s11n.net "...pleasure is a grace and is not obedient to the commands of the will." -- Alan W. Watts |