1 #ifndef _GAUDI_PLUGIN_SERVICE_DETAILS_H_
2 #define _GAUDI_PLUGIN_SERVICE_DETAILS_H_
22 #if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
27 # define GAUDIPS_HASCLASSVISIBILITY
30 #if defined(GAUDIPS_HASCLASSVISIBILITY)
31 # define GAUDIPS_IMPORT __attribute__((visibility("default")))
32 # define GAUDIPS_EXPORT __attribute__((visibility("default")))
33 # define GAUDIPS_LOCAL __attribute__((visibility("hidden")))
35 # define GAUDIPS_IMPORT
36 # define GAUDIPS_EXPORT
37 # define GAUDIPS_LOCAL
40 #ifdef GaudiPluginService_EXPORTS
41 #define GAUDIPS_API GAUDIPS_EXPORT
43 #define GAUDIPS_API GAUDIPS_IMPORT
46 namespace Gaudi {
namespace PluginService {
58 static typename S::ReturnType
create() {
63 static typename S::ReturnType
create(
typename S::Arg1Type a1) {
68 static typename S::ReturnType
create(
typename S::Arg1Type a1,
69 typename S::Arg2Type a2) {
74 static typename S::ReturnType
create(
typename S::Arg1Type a1,
75 typename S::Arg2Type a2,
76 typename S::Arg3Type a3) {
77 return new T(a1, a2, a3);
101 union {
void* src; F dst; } p2p;
109 std::string
demangle(
const std::type_info&
id);
112 template <
typename T>
125 const std::string& t=
"",
126 const std::string& rt=
"",
127 const std::string& cn=
"",
129 library(lib), ptr(p),
type(t), rtype(rt), className(cn), properties(props) {}
151 template <
typename F,
typename T,
typename I>
153 union {
typename F::FuncType src;
void* dst; } p2p;
155 std::ostringstream o; o << id;
156 return add(o.str(), p2p.dst,
157 typeid(
typename F::FuncType).name(),
158 typeid(
typename F::ReturnType).name(),
163 void*
get(
const std::string& id,
const std::string&
type)
const;
166 const FactoryInfo& getInfo(
const std::string&
id)
const;
170 addProperty(
const std::string&
id,
171 const std::string& k,
172 const std::string& v);
175 std::set<KeyType> loadedFactories()
const;
195 add(
const std::string&
id,
void *factory,
196 const std::string&
type,
const std::string& rtype,
197 const std::string& className,
198 const Properties& props = Properties());
216 #if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
218 mutable std::recursive_mutex m_mutex;
230 inline void info(
const std::string&
msg) { report(Info, msg); }
232 inline void warning(
const std::string&
msg) { report(Warning, msg); }
233 inline void error(
const std::string&
msg) { report(Error, msg); }
235 virtual void report(
Level lvl,
const std::string&
msg);
253 #define _INTERNAL_FACTORY_REGISTER_CNAME(name, serial) \
254 _register_ ## _ ## serial
256 #define _INTERNAL_DECLARE_FACTORY_WITH_CREATOR(type, typecreator, \
257 id, factory, serial) \
259 class _INTERNAL_FACTORY_REGISTER_CNAME(type, serial) { \
261 typedef factory s_t; \
262 typedef typecreator f_t; \
263 static s_t::FuncType creator() { return &f_t::create<s_t>; } \
264 _INTERNAL_FACTORY_REGISTER_CNAME(type, serial) () { \
265 using ::Gaudi::PluginService::Details::Registry; \
266 Registry::instance().add<s_t, type>(id, creator()); \
268 } _INTERNAL_FACTORY_REGISTER_CNAME(s_ ## type, serial); \
271 #define _INTERNAL_DECLARE_FACTORY(type, id, factory, serial) \
272 _INTERNAL_DECLARE_FACTORY_WITH_CREATOR(type, \
273 ::Gaudi::PluginService::Details::Factory<type>, \
276 #endif //_GAUDI_PLUGIN_SERVICE_DETAILS_H_