00001 #ifndef Watcher_SimWatcherMaker_h 00002 #define Watcher_SimWatcherMaker_h 00003 // -*- C++ -*- 00004 // 00005 // Package: Watcher 00006 // Class : SimWatcherMaker 00007 // 00016 // 00017 // Original Author: 00018 // Created: Tue Nov 22 13:03:44 EST 2005 00019 // $Id: SimWatcherMaker.h,v 1.2 2005/11/29 18:40:25 chrjones Exp $ 00020 // 00021 00022 // system include files 00023 #include <memory> 00024 00025 // user include files 00026 #include "SimG4Core/Watcher/interface/SimWatcherMakerBase.h" 00027 #include "SimG4Core/Notification/interface/SimActivityRegistryEnroller.h" 00028 00029 // forward declarations 00030 00031 template<class T> 00032 class SimWatcherMaker : public SimWatcherMakerBase 00033 { 00034 00035 public: 00036 SimWatcherMaker(){} 00037 00038 // ---------- const member functions --------------------- 00039 virtual void make(const edm::ParameterSet& p, 00040 SimActivityRegistry& reg, 00041 boost::shared_ptr<SimWatcher>& oWatcher, 00042 boost::shared_ptr<SimProducer>& oProd 00043 ) const 00044 { 00045 boost::shared_ptr<T> returnValue(new T(p)); 00046 SimActivityRegistryEnroller::enroll(reg, returnValue.get()); 00047 oWatcher = returnValue; 00048 00049 //If this is also a SimProducer, set the value 00050 oProd = this->getSimProducer(returnValue.get(), returnValue); 00051 } 00052 00053 private: 00054 boost::shared_ptr<SimProducer> 00055 getSimProducer(SimProducer*, boost::shared_ptr<T>& iProd) const{ 00056 return boost::shared_ptr<SimProducer>(iProd); 00057 } 00058 boost::shared_ptr<SimProducer> 00059 getSimProducer(void*, boost::shared_ptr<T>& iProd) const{ 00060 return boost::shared_ptr<SimProducer>(); 00061 } 00062 00063 }; 00064 00065 00066 #endif