From: stephan b. <st...@s1...> - 2005-05-27 14:12:35
|
On Wednesday 18 May 2005 16:28, Prochnow, Christian wrote: > i've rewritten the Factory and PluginManager! The old one had some > problems which could not be solved with the old implementation: ... i'm going through the code now, and i've got a couple of concerns: #1: return static_cast<Factory&>( FactoryBase::instance(typeid(InterfaceT).name(), typeid(ContextT).name(), &createHook)); typeid::name() OFFICIALLY provides undefined behaviour. Under gcc i have seen cases where typeid(T*).name() will return 2 different values, depending on whether T comes from a DLL or was statically linked. i spent months fighting with typeid::name() in s11n before finally dropping it altogether. i promise: it cannot be trusted at all. Also, why do you need the static cast there? #2: template <class TypeName> void registerType(const std::string& key, TypeName) { registerFactory(key, &typeCreateHook<TypeName>); } Why are we forced to pass a TypeName object? That is not at all suitable for large types. If i'm not mistaken, it also means that we cannot call registerType if TypeName is an incomplete type, where we can (i think) if the user does not pass a TypeName object. -- ----- st...@s1... http://s11n.net "...pleasure is a grace and is not obedient to the commands of the will." -- Alan W. Watts |