Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:55:21

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     : M.Frank
0011 //
0012 //==========================================================================
0013 #ifndef DDDIGI_DIGIHANDLE_H
0014 #define DDDIGI_DIGIHANDLE_H
0015 
0016 // Framework include files
0017 #include <DD4hep/ComponentProperties.h>
0018 #include <DD4hep/Detector.h>
0019 
0020 // C/C++ include files
0021 #include <string>
0022 #include <memory>
0023 
0024 /// Namespace for the AIDA detector description toolkit
0025 namespace dd4hep {
0026 
0027   /// Namespace for the Digitization part of the AIDA detector description toolkit
0028   namespace digi  {
0029 
0030     /// Forward declarations
0031     class DigiKernel;
0032     class DigiAction;
0033     class DigiEventAction;
0034     class DigiSignalProcessor;
0035 
0036     /// Handle to Digi actions with built-in creation mechanism
0037     /**
0038      *  \author  M.Frank
0039      *  \version 1.0
0040      *  \ingroup DD4HEP_DIGITIZATION
0041      */
0042     class KernelHandle {
0043     public:
0044       /// Pointer to referenced object
0045       mutable DigiKernel* value;
0046       /// Default constructor
0047       explicit KernelHandle();
0048       /// Construction initialized with object pointer
0049       explicit KernelHandle(DigiKernel* k);
0050       /// Copy constructor
0051       KernelHandle(const KernelHandle& k) : value(k.value) {}
0052       /// Default destructor
0053       ~KernelHandle()                  {               }
0054       /// Conversion operator
0055       operator DigiKernel*() const   { return value; }
0056       /// Access to the underlying object
0057       DigiKernel* get() const        { return value; }
0058       /// Access to the underlying object
0059       DigiKernel* operator->() const { return value; }
0060       /// Property accessor
0061       Property& operator[](const std::string& property_name) const;
0062       /// Access to worker thread
0063       KernelHandle worker();
0064       /// Destroy referenced object (program termination)
0065       void destroy();
0066     };
0067 
0068     /// Handle to Digi actions with built-in creation mechanism
0069     /**
0070      *  \author  M.Frank
0071      *  \version 1.0
0072      *  \ingroup DD4HEP_DIGITIZATION
0073      */
0074     template <typename TYPE> class DigiHandle {
0075     protected:
0076       void checked_assign(TYPE* p);
0077       TYPE* null()  { return 0; }
0078     public:
0079       /// Pointer to referenced object
0080       mutable TYPE* value = 0;
0081       /// Default constructor
0082       explicit DigiHandle() = default;
0083       /// Construction initialized with object pointer
0084       DigiHandle(TYPE* typ);
0085       /// Cross type initialization
0086       template <typename T> DigiHandle(T* typ) : value(0) {
0087         checked_assign(dynamic_cast<TYPE*>(typ));
0088       }
0089       /// Copy constructor
0090       DigiHandle(const DigiHandle& handle);
0091       /// Move constructor
0092       DigiHandle(DigiHandle&& handle);
0093       /// Initializing constructor
0094       DigiHandle(const DigiKernel&, const char* type_name);
0095       /// Initializing constructor
0096       DigiHandle(const DigiKernel&, const std::string& type_name);
0097       /// Default destructor
0098       ~DigiHandle();
0099       /// Property accessor
0100       Property& operator[](const std::string& property_name) const;
0101       /// Assignment operator
0102       DigiHandle& operator=(const DigiHandle& handle);
0103       /// Move assignment operator
0104       DigiHandle& operator=(DigiHandle&& handle);
0105       /// Assignment operator
0106       DigiHandle& operator=(TYPE* ptr);
0107       /// Validity check
0108       bool operator!() const;
0109       /// Access to the underlying object
0110       DigiAction* action() const;
0111       /// Access to the underlying object
0112       TYPE* operator->() const;
0113       /// Conversion operator
0114       operator TYPE*() const;
0115       /// Access to the underlying object
0116       TYPE* get() const;
0117       /// Release the underlying object
0118       TYPE* release();
0119     };
0120 
0121   }    // End namespace digi
0122 }      // End namespace dd4hep
0123 
0124 #endif // DDDIGI_DIGIHANDLE_H