DD4hep  1.36.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 #include <any>
23 
24 #ifdef __clang__
25 #pragma clang diagnostic push
26 #pragma clang diagnostic ignored "-Wkeyword-macro"
27 #pragma clang diagnostic pop
28 #endif
29 
30 #if GAUDI_PLUGIN_SERVICE_VERSION == 2
31 #define GAUDI_PLUGIN_SERVICE_V2 1
32 #include <Gaudi/PluginService.h>
33 #elif GAUDI_PLUGIN_SERVICE_VERSION == 1
34 #define private public
35 #define GAUDI_PLUGIN_SERVICE_V1 1
36 #include <Gaudi/PluginService.h>
37 #undef private
38 #endif
39 
40 #define MAKE_GAUDI_PLUGIN_SERVICE_ENTRY(n,v) dd4hep_pluginmgr_##n##_V##v
41 #define MAKE_FUNC(name,version) MAKE_GAUDI_PLUGIN_SERVICE_ENTRY(name,version)
42 
43 extern "C" {
46  return (int)Gaudi::PluginService::Debug();
47  }
49  int MAKE_FUNC(setdebug,GAUDI_PLUGIN_SERVICE_VERSION)(int value) {
52  return debug;
53  }
55 #if GAUDI_PLUGIN_SERVICE_VERSION==2
56  std::any MAKE_FUNC(create,GAUDI_PLUGIN_SERVICE_VERSION)(const char* id, const char* /* sig */) {
57  using namespace Gaudi::PluginService::v2;
58  const Details::Registry::FactoryInfo& info = Details::Registry::instance().getInfo(id, true);
59  return info.factory;
60  }
61 #elif GAUDI_PLUGIN_SERVICE_VERSION==1
62  std::any MAKE_FUNC(create,GAUDI_PLUGIN_SERVICE_VERSION)(const char* id, const char* sig) {
63  std::any ret;
64  ret = (void*)Gaudi::PluginService::Details::getCreator(id,sig);
65  return ret;
66  }
67 #endif
68 #if GAUDI_PLUGIN_SERVICE_VERSION==2
69  void MAKE_FUNC(add_factory,GAUDI_PLUGIN_SERVICE_VERSION)(const char* id, std::any&& stub, const char* /* sig */, const char* /* ret */) {
71  using namespace Gaudi::PluginService::v2;
72  Details::Registry::Properties props = {};
73  std::string lib_name = "";
74  Details::Registry::instance().add( id, {std::move(lib_name), std::move( stub ), std::move( props )} );
75  }
76 #elif GAUDI_PLUGIN_SERVICE_VERSION==1
77  void MAKE_FUNC(add_factory,GAUDI_PLUGIN_SERVICE_VERSION)(const char* id, std::any&& stub, const char* sig, const char* ret) {
79  Gaudi::PluginService::Details::Registry::instance().add(id, std::any_cast<void*>(stub), sig, ret, id);
80  }
81 #endif
82 }
83 
84 #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:41
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:329
Gaudi::PluginService::v1::Details::getCreator
GAUDIPS_API void * getCreator(const std::string &id, const std::string &type)
Definition: PluginServiceV1.cpp:116
Gaudi::PluginService::v1::Debug
GAUDIPS_API int Debug()
Backward compatibility with Reflex.
Definition: PluginServiceV1.cpp:340