|
Boost Users : |
Subject: Re: [Boost-users] how to make a vector to derivedClass::create() methods
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-02-09 11:00:38
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<typename BaseType, typename keyType>
> 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
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net