AMDG Victor Whiskey Yankee wrote:
Thank you Steve for your solution, it is working fine. I have a nice thread-safe singleton factory now, and it is generic using templates.
I am now trying to make my derived classes register with the factory automatically, but cannot figure it out. I basically have this:
template
class GenericFactory { public: GenericFactory(); boost::shared_ptr<BaseType> create(const keyType& typeName);
template<typeName DerivedType> void registrate(const keyType& _key); };
As said, I can register my derived classes with the above just fnie.
I have tried writing a help class like I've seened "RegisterInFactory", but it escapes me.
Your thinking of this? struct RegisterDerived { RegisterDerived() { factory.register<Derived>("Derived") } } registerDerived; In Christ, Steven Watanabe