14 #ifndef DD4HEP_PLUGINS_INL
15 #define DD4HEP_PLUGINS_INL
19 #if !defined(DD4HEP_PARSERS_NO_ROOT) && ROOT_VERSION_CODE < ROOT_VERSION(6,0,0)
26 #define Reflex_CollectionProxy 1
30 #include "Reflex/PluginService.h"
31 #include "Reflex/Reflex.h"
32 #include "Reflex/Builder/ReflexBuilder.h"
44 {
return ROOT::Reflex::PluginService::Create<R>(name); }
47 {
return ROOT::Reflex::PluginService::Create<R>(name,a0); }
49 template <
typename R,
typename A0,
typename A1>
51 {
return ROOT::Reflex::PluginService::Create<R>(name, a0, a1); }
53 template <
typename R,
typename A0,
typename A1,
typename A2>
55 {
return ROOT::Reflex::PluginService::Create<R>(name, a0, a1, a2); }
57 template <
typename R,
typename A0,
typename A1,
typename A2,
typename A3>
59 {
return ROOT::Reflex::PluginService::Create<R>(name, a0, a1, a2, a3); }
61 template <
typename R,
typename A0,
typename A1,
typename A2,
typename A3,
typename A4>
63 {
return ROOT::Reflex::PluginService::Create<R>(name, a0, a1, a2, a3, a4); }
65 template <
typename R,
typename A0,
typename A1,
typename A2,
typename A3,
typename A4,
typename A5>
67 {
return ROOT::Reflex::PluginService::Create<R>(name, a0, a1, a2, a3, a4, a5); }
77 namespace plugin_signatures_namespace {
86 template <
typename T>
union FuncPtr {
87 FuncPtr(
T t) { fcn = t; }
92 template <
typename T> FuncPtr<T> __func(
T t) {
return FuncPtr<T>(t); }
103 template <
typename R>
void* instantiate_creator ()
104 {
return __func(PluginService::Create<R>).ptr; }
106 template <
typename R,
typename A0>
void* instantiate_creator(A0)
107 {
return __func(PluginService::Create<R,A0>).ptr; }
109 template <
typename R,
typename A0,
typename A1>
void* instantiate_creator(A0,A1)
110 {
return __func(PluginService::Create<R,A0,A1>).ptr; }
112 template <
typename R,
typename A0,
typename A1,
typename A2>
113 void* instantiate_creator(A0,A1,A2)
114 {
return __func(PluginService::Create<R,A0,A1,A2>).ptr; }
116 template <
typename R,
typename A0,
typename A1,
typename A2,
typename A3>
117 void* instantiate_creator(A0,A1,A2,A3)
118 {
return __func(PluginService::Create<R,A0,A1,A2,A3>).ptr; }
120 template <
typename R,
typename A0,
typename A1,
typename A2,
typename A3,
typename A4>
121 void* instantiate_creator(A0,A1,A2,A3,A4)
122 {
return __func(PluginService::Create<R,A0,A1,A2,A3,A4>).ptr; }
124 template <
typename R,
typename A0,
typename A1,
typename A2,
typename A3,
typename A4,
typename A5>
125 void* instantiate_creator(A0,A1,A2,A3,A4,A5)
126 {
return __func(PluginService::Create<R,A0,A1,A2,A3,A4,A5>).ptr; }
130 ROOT::Reflex::Type typ = ROOT::Reflex::TypeBuilder(name.c_str(),ROOT::Reflex::PUBLIC);
131 ROOT::Reflex::Type sig = ROOT::Reflex::FunctionDistiller < SIGNATURE > ::Get();
132 std::string fname = (std::string(PLUGINSVC_FACTORY_NS
"::") + ROOT::Reflex::PluginService::FactoryName(name));
133 ROOT::Reflex::FunctionBuilder func(sig, fname.c_str(), stub, 0,
"", ROOT::Reflex::PUBLIC);
134 func.AddProperty(
"name", name).AddProperty(
"id", name);
136 std::string sig_name = sig.Name();
137 printout(
INFO,
"PluginService",
"+++ Declared factory for id %s with signature %s.",fname.c_str(),sig_name.c_str());
145 #define DD4HEP_IMPLEMENT_PLUGIN_REGISTRY(R, ARGS) namespace DD4hep { \
146 template <> void PluginRegistry< R ARGS >::add(const char* n, stub_t f) \
147 { plugin_signatures_namespace::reflex_plugin< R ARGS >(n,f); } \
148 namespace plugin_signatures_namespace { template void* instantiate_creator<R> ARGS ; }}
152 #endif // DD4HEP_PLUGINS_INL
static R Create(const std::string &id, Args...args)
Factory template for the plugin mechanism.
int printout(PrintLevel severity, const char *src, const char *fmt,...)
Calls the display action with a given severity level.