Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-03-19 06:07:42

0001 #ifndef Notification_SimActivityRegistryEnroller_h
0002 #define Notification_SimActivityRegistryEnroller_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     Notification
0006 // Class  :     SimActivityRegistryEnroller
0007 //
0008 /**\class SimActivityRegistryEnroller SimActivityRegistryEnroller.h SimG4Core/Notification/interface/SimActivityRegistryEnroller.h
0009 
0010  Description: Based on what classes an object inherts, enrolls that object with the proper signal
0011 
0012  Usage:
0013     <usage>
0014 
0015 */
0016 //
0017 // Original Author:  Chris Jones
0018 //         Created:  Sun Nov 13 15:08:12 EST 2005
0019 //
0020 // user include files
0021 #include "SimG4Core/Notification/interface/Observer.h"
0022 #include "SimG4Core/Notification/interface/SimActivityRegistry.h"
0023 
0024 // forward declarations
0025 namespace enroller_helper {
0026   template <class T>
0027   struct Enrollment {
0028     static void enroll(SimActivityRegistry& iReg, Observer<const T*>* iObs) { iReg.connect(iObs); }
0029     static void enroll(SimActivityRegistry&, void*) {}
0030   };
0031 
0032   template <class T>
0033   static void enroll(SimActivityRegistry& iReg, T* iT) {}
0034 
0035   template <class T, class F, class... TVector>
0036   static void enroll(SimActivityRegistry& iReg, T* iT) {
0037     //Try to enroll the object if it inherits from the class at the
0038     // start of TVector
0039     Enrollment<F>::enroll(iReg, iT);
0040     enroll<T, TVector...>(iReg, iT);
0041   }
0042 
0043 }  // namespace enroller_helper
0044 
0045 class SimActivityRegistryEnroller {
0046 public:
0047   SimActivityRegistryEnroller() {}
0048 
0049   template <class T>
0050   static void enroll(SimActivityRegistry& iReg, T* iObj) {
0051     enroller_helper::enroll<T,
0052                             BeginOfJob,
0053                             DDDWorld,
0054                             BeginOfRun,
0055                             BeginOfEvent,
0056                             BeginOfTrack,
0057                             BeginOfStep,
0058                             G4Step,
0059                             EndOfTrack,
0060                             EndOfEvent,
0061                             EndOfRun>(iReg, iObj);
0062   }
0063 
0064   // stop default
0065   SimActivityRegistryEnroller(const SimActivityRegistryEnroller&) = delete;
0066   const SimActivityRegistryEnroller& operator=(const SimActivityRegistryEnroller&) = delete;
0067 };
0068 
0069 #endif