Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 09:58:02

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 //  \author   Markus Frank
0011 //  \date     2016-01-29
0012 //  \version  1.0
0013 //
0014 //==========================================================================
0015 #ifndef DD4HEP_PLUGINCREATORS_H 
0016 #define DD4HEP_PLUGINCREATORS_H 1
0017 
0018 // Framework include files
0019 #include <DD4hep/Primitives.h>
0020 
0021 // C/C++ include files
0022 #include <string>
0023 
0024 /// Namespace for the AIDA detector description toolkit
0025 namespace dd4hep {
0026   
0027   // Forward declarations
0028   class Detector;
0029 
0030   /// Handler for factories of type: ConstructionFactory
0031   /** Signature: void* create(const char* arg);
0032    *
0033    *  An exception is thrown in the event the object cannot be created.
0034    *  The object is properly casted before given to the caller.
0035    */
0036   void* createPlugin(const std::string& factory, Detector& description, void* (*cast)(void*));
0037   void* createPlugin(const std::string& factory, Detector& description, const std::string& arg, void* (*cast)(void*));
0038   void* createPlugin(const std::string& factory, Detector& description, int argc, char** argv, void* (*cast)(void*));
0039   void* createProcessor(Detector& description, int argc, char** argv, void* (*cast)(void*));
0040 
0041   /// Handler for factories of type: ConstructionFactory with casted return type
0042   template <typename T> T* createPlugin(const std::string& factory, Detector& description)   {
0043     struct __cast{ static void* cast(void* p) { return &dynamic_cast<T&>(*(T*)p); } };
0044     return (T*)createPlugin(factory, description, __cast::cast);
0045   }
0046   /// Handler for factories of type: ConstructionFactory with casted return type
0047   template <typename T> T* createPlugin(const std::string& factory, Detector& description, const std::string& arg)   {
0048     struct __cast{ static void* cast(void* p) { return &dynamic_cast<T&>(*(T*)p); } };
0049     return (T*)createPlugin(factory, description, arg, __cast::cast);
0050   }
0051   /// Handler for factories of type: ConstructionFactory with casted return type
0052   template <typename T> T* createPlugin(const std::string& factory, Detector& description, int argc, const void** argv)   {
0053     struct __cast{ static void* cast(void* p) { return &dynamic_cast<T&>(*(T*)p); } };
0054     return (T*)createPlugin(factory, description, argc, (char**)argv, __cast::cast);
0055   }
0056 
0057   /// Handler for factories of type: ConstructionFactory with casted return type
0058   template <typename T> T* createProcessor(Detector& description, int argc, char** argv)   {
0059     struct __cast{ static void* cast(void* p) { return &dynamic_cast<T&>(*(T*)p); } };
0060     return (T*)createProcessor(description, argc, argv, __cast::cast);
0061   }
0062 
0063   /// Handler for factories of type: ConstructionFactory with casted return type
0064   template <typename T> T* createProcessor(Detector& description, int argc, const void** argv)   {
0065     struct __cast{ static void* cast(void* p) { return &dynamic_cast<T&>(*(T*)p); } };
0066     return (T*)createProcessor(description, argc, (char**)argv, __cast::cast);
0067   }
0068 
0069 } /* End namespace dd4hep      */
0070 
0071 #endif // DD4HEP_PLUGINCREATORS_H