File indexing completed on 2025-01-18 09:14:59
0001 #ifndef GAUDIPLUGINSERVICE_INTERFACE_DD4HEP_H
0002 #define GAUDIPLUGINSERVICE_INTERFACE_DD4HEP_H
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include <string>
0017 #include <sstream>
0018 #include <map>
0019 #include <set>
0020 #include <typeinfo>
0021 #include <utility>
0022 #if __cplusplus >= 201703
0023 # include <any>
0024 #else
0025 # include <boost/any.hpp>
0026 namespace std {
0027 using boost::any;
0028 using boost::any_cast;
0029 using boost::bad_any_cast;
0030 }
0031 #endif
0032
0033 #ifdef __clang__
0034 #pragma clang diagnostic push
0035 #pragma clang diagnostic ignored "-Wkeyword-macro"
0036 #pragma clang diagnostic pop
0037 #endif
0038
0039 #if GAUDI_PLUGIN_SERVICE_VERSION == 2
0040 #define GAUDI_PLUGIN_SERVICE_V2 1
0041 #include <Gaudi/PluginService.h>
0042 #elif GAUDI_PLUGIN_SERVICE_VERSION == 1
0043 #define private public
0044 #define GAUDI_PLUGIN_SERVICE_V1 1
0045 #include <Gaudi/PluginService.h>
0046 #undef private
0047 #endif
0048
0049 #define MAKE_GAUDI_PLUGIN_SERVICE_ENTRY(n,v) dd4hep_pluginmgr_##n##_V##v
0050 #define MAKE_FUNC(name,version) MAKE_GAUDI_PLUGIN_SERVICE_ENTRY(name,version)
0051
0052 extern "C" {
0053
0054 int MAKE_FUNC(getdebug,GAUDI_PLUGIN_SERVICE_VERSION) () {
0055 return (int)Gaudi::PluginService::Debug();
0056 }
0057
0058 int MAKE_FUNC(setdebug,GAUDI_PLUGIN_SERVICE_VERSION)(int value) {
0059 int debug = (int)Gaudi::PluginService::Debug();
0060 Gaudi::PluginService::SetDebug(value);
0061 return debug;
0062 }
0063
0064 #if GAUDI_PLUGIN_SERVICE_VERSION==2
0065 std::any MAKE_FUNC(create,GAUDI_PLUGIN_SERVICE_VERSION)(const char* id, const char* ) {
0066 using namespace Gaudi::PluginService::v2;
0067 const Details::Registry::FactoryInfo& info = Details::Registry::instance().getInfo(id, true);
0068 return info.factory;
0069 }
0070 #elif GAUDI_PLUGIN_SERVICE_VERSION==1
0071 std::any MAKE_FUNC(create,GAUDI_PLUGIN_SERVICE_VERSION)(const char* id, const char* sig) {
0072 std::any ret;
0073 ret = (void*)Gaudi::PluginService::Details::getCreator(id,sig);
0074 return ret;
0075 }
0076 #endif
0077 #if GAUDI_PLUGIN_SERVICE_VERSION==2
0078
0079 void MAKE_FUNC(add_factory,GAUDI_PLUGIN_SERVICE_VERSION)(const char* id, std::any&& stub, const char* , const char* ) {
0080 using namespace Gaudi::PluginService::v2;
0081 Details::Registry::Properties props = {};
0082 std::string lib_name = "";
0083 Details::Registry::instance().add( id, {std::move(lib_name), std::move( stub ), std::move( props )} );
0084 }
0085 #elif GAUDI_PLUGIN_SERVICE_VERSION==1
0086
0087 void MAKE_FUNC(add_factory,GAUDI_PLUGIN_SERVICE_VERSION)(const char* id, std::any&& stub, const char* sig, const char* ret) {
0088 Gaudi::PluginService::Details::Registry::instance().add(id, std::any_cast<void*>(stub), sig, ret, id);
0089 }
0090 #endif
0091 }
0092
0093 #endif