Back to home page

EIC code displayed by LXR

 
 

    


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 //  AIDA Detector description implementation 
0006 //--------------------------------------------------------------------------
0007 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0008 // All rights reserved.
0009 //
0010 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0011 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0012 //
0013 // Author     : M.Frank
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 } // namespace std
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   /// Access debug level
0054   int MAKE_FUNC(getdebug,GAUDI_PLUGIN_SERVICE_VERSION) ()   {
0055     return (int)Gaudi::PluginService::Debug();
0056   }
0057   /// Set debug level
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   /// Access factory by name
0064 #if GAUDI_PLUGIN_SERVICE_VERSION==2
0065   std::any MAKE_FUNC(create,GAUDI_PLUGIN_SERVICE_VERSION)(const char* id, const char* /* sig */)   {
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   /// Add a new factory to the registry
0079   void MAKE_FUNC(add_factory,GAUDI_PLUGIN_SERVICE_VERSION)(const char* id, std::any&& stub, const char* /* sig */, const char* /* ret */)   {
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   /// Add a new factory to the registry
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