1 #ifndef FWCore_PluginManager_PluginFactory_h
2 #define FWCore_PluginManager_PluginFactory_h
37 template <
typename R,
typename... Args>
39 friend class DummyFriend;
49 virtual std::unique_ptr<R>
create(Args...)
const = 0;
52 template <
class TPlug>
53 struct PMaker :
public PMakerBase {
56 return std::make_unique<TPlug>(std::forward<Args>(
args)...);
70 if (
found ==
nullptr) {
87 #define FWCORE_CONCATENATE_HIDDEN(a, b) a##b
88 #define FWCORE_CONCATENATE(a, b) FWCORE_CONCATENATE_HIDDEN(a, b)
89 #define EDM_REGISTER_PLUGINFACTORY(_factory_, _category_) \
90 namespace edmplugin { \
92 edmplugin::PluginFactory<_factory_::TemplateArgType>* edmplugin::PluginFactory<_factory_::TemplateArgType>::get() { \
93 CMS_THREAD_SAFE static edmplugin::PluginFactory<_factory_::TemplateArgType> s_instance; \
97 const std::string& edmplugin::PluginFactory<_factory_::TemplateArgType>::category() const { \
98 static const std::string s_cat(_category_); \
102 enum { FWCORE_CONCATENATE(dummy_edm_register_pluginfactory_, __LINE__) }
104 #define EDM_REGISTER_PLUGINFACTORY2(_factory_, _category_) \
105 namespace edmplugin { \
107 edmplugin::PluginFactory<_factory_::TemplateArgType>* edmplugin::PluginFactory<_factory_::TemplateArgType>::get() { \
108 CMS_THREAD_SAFE static edmplugin::PluginFactory<_factory_::TemplateArgType> s_instance; \
109 return &s_instance; \
112 const std::string& edmplugin::PluginFactory<_factory_::TemplateArgType>::category() const { \
113 static const std::string s_cat(_category_); \
117 enum { FWCORE_CONCATENATE(dummy_edm_register_pluginfactory_2_, __LINE__) }
121 #define EDM_PLUGIN_SYM(x, y) EDM_PLUGIN_SYM2(x, y)
122 #define EDM_PLUGIN_SYM2(x, y) x##y
124 #define DEFINE_EDM_PLUGIN(factory, type, name) \
125 static const factory::PMaker<type> EDM_PLUGIN_SYM(s_maker, __LINE__)(name)
127 #define DEFINE_EDM_PLUGIN2(factory, type, name) \
128 static const factory::PMaker<type> EDM_PLUGIN_SYM(s_maker2, __LINE__)(name)
std::unique_ptr< R > create(Args...args) const override
static const char category[]
void registerPMaker(void *iPMaker, const std::string &iName)
std::unique_ptr< R > tryToCreate(const std::string &iName, Args...args) const
like above but returns 0 if iName is unknown
void registerPMaker(PMakerBase *iPMaker, const std::string &iName)
PMaker(const std::string &iName)
void * findPMaker(const std::string &iName) const
std::unique_ptr< R > create(const std::string &iName, Args...args) const
void * tryToFindPMaker(const std::string &iName) const
R *(Args...) TemplateArgType