DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
DD4hep.h
Go to the documentation of this file.
1 #ifndef GAUDIPLUGINSERVICE_INTERFACE_DD4HEP_H
2 #define GAUDIPLUGINSERVICE_INTERFACE_DD4HEP_H
3 
4 //==========================================================================
5 // AIDA Detector description implementation
6 //--------------------------------------------------------------------------
7 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
8 // All rights reserved.
9 //
10 // For the licensing terms see $DD4hepINSTALL/LICENSE.
11 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
12 //
13 // Author : M.Frank
14 //
15 //==========================================================================
16 #include <string>
17 #include <sstream>
18 #include <map>
19 #include <set>
20 #include <typeinfo>
21 #include <utility>
22 #if __cplusplus >= 201703
23 # include <any>
24 #else
25 # include <boost/any.hpp>
26 namespace std {
27  using boost::any;
28  using boost::any_cast;
29  using boost::bad_any_cast;
30 } // namespace std
31 #endif
32 
33 #ifdef __clang__
34 #pragma clang diagnostic push
35 #pragma clang diagnostic ignored "-Wkeyword-macro"
36 #pragma clang diagnostic pop
37 #endif
38 
39 #if GAUDI_PLUGIN_SERVICE_VERSION == 2
40 #define GAUDI_PLUGIN_SERVICE_V2 1
41 #include <Gaudi/PluginService.h>
42 #elif GAUDI_PLUGIN_SERVICE_VERSION == 1
43 #define private public
44 #define GAUDI_PLUGIN_SERVICE_V1 1
45 #include <Gaudi/PluginService.h>
46 #undef private
47 #endif
48 
49 #define MAKE_GAUDI_PLUGIN_SERVICE_ENTRY(n,v) dd4hep_pluginmgr_##n##_V##v
50 #define MAKE_FUNC(name,version) MAKE_GAUDI_PLUGIN_SERVICE_ENTRY(name,version)
51 
52 extern "C" {
55  return (int)Gaudi::PluginService::Debug();
56  }
58  int MAKE_FUNC(setdebug,GAUDI_PLUGIN_SERVICE_VERSION)(int value) {
61  return debug;
62  }
64 #if GAUDI_PLUGIN_SERVICE_VERSION==2
65  std::any MAKE_FUNC(create,GAUDI_PLUGIN_SERVICE_VERSION)(const char* id, const char* /* sig */) {
66  using namespace Gaudi::PluginService::v2;
67  const Details::Registry::FactoryInfo& info = Details::Registry::instance().getInfo(id, true);
68  return info.factory;
69  }
70 #elif GAUDI_PLUGIN_SERVICE_VERSION==1
71  std::any MAKE_FUNC(create,GAUDI_PLUGIN_SERVICE_VERSION)(const char* id, const char* sig) {
72  std::any ret;
73  ret = (void*)Gaudi::PluginService::Details::getCreator(id,sig);
74  return ret;
75  }
76 #endif
77 #if GAUDI_PLUGIN_SERVICE_VERSION==2
78  void MAKE_FUNC(add_factory,GAUDI_PLUGIN_SERVICE_VERSION)(const char* id, std::any&& stub, const char* /* sig */, const char* /* ret */) {
80  using namespace Gaudi::PluginService::v2;
81  Details::Registry::Properties props = {};
82  std::string lib_name = "";
83  Details::Registry::instance().add( id, {std::move(lib_name), std::move( stub ), std::move( props )} );
84  }
85 #elif GAUDI_PLUGIN_SERVICE_VERSION==1
86  void MAKE_FUNC(add_factory,GAUDI_PLUGIN_SERVICE_VERSION)(const char* id, std::any&& stub, const char* sig, const char* ret) {
88  Gaudi::PluginService::Details::Registry::instance().add(id, std::any_cast<void*>(stub), sig, ret, id);
89  }
90 #endif
91 }
92 
93 #endif
dd4hep::info
std::size_t info(const std::string &src, const std::string &msg)
Definition: RootDictionary.h:65
MAKE_FUNC
#define MAKE_FUNC(name, version)
Definition: DD4hep.h:50
dd4hep::debug
std::size_t debug(const std::string &src, const std::string &msg)
Definition: RootDictionary.h:64
GAUDI_PLUGIN_SERVICE_VERSION
#define GAUDI_PLUGIN_SERVICE_VERSION
Definition: DD4hepV1.cpp:13
Gaudi::PluginService::v2
Definition: PluginServiceV2.h:28
PluginService.h
Gaudi::PluginService::v1::SetDebug
GAUDIPS_API void SetDebug(int debugLevel)
Backward compatibility with Reflex.
Definition: PluginServiceV1.cpp:331
Gaudi::PluginService::v1::Details::getCreator
GAUDIPS_API void * getCreator(const std::string &id, const std::string &type)
Definition: PluginServiceV1.cpp:116
std
Definition: Plugins.h:30
Gaudi::PluginService::v1::Debug
GAUDIPS_API int Debug()
Backward compatibility with Reflex.
Definition: PluginServiceV1.cpp:342