#ifndef BE7ED734_3D5C_4600_89C3_4082EB263BE0 #define BE7ED734_3D5C_4600_89C3_4082EB263BE0 /* ******************************************************************************* * INCLUDE ******************************************************************************* */ #include #include namespace Util { /* ******************************************************************************* * CLASS DECLARE ******************************************************************************* */ template class BuilderSet { private: class IBuilder { public: using Ptr = Poco::SharedPtr; virtual ~IBuilder() { } virtual T* build(TArgs... args) = 0; }; template class Builder: public IBuilder { public: C* build(TArgs... args) override { C* p = new C(args...); return p; } }; using Builders = std::map; public: static T* build(TArgs... args) { TKey key = TSelector::select(args...); return _builders[key]->build(args...); } template static void registerClass(TKey key) { _builders[key] = new Builder(); } private: static Builders _builders; }; template typename BuilderSet::Builders BuilderSet::_builders; } #endif