CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/FWCore/Framework/src/WorkerT.cc

Go to the documentation of this file.
00001 #include "FWCore/Framework/src/WorkerT.h"
00002 #include "FWCore/Framework/interface/EventPrincipal.h"
00003 
00004 #include "FWCore/Framework/interface/EDProducer.h"
00005 #include "FWCore/Framework/interface/EDFilter.h"
00006 #include "FWCore/Framework/interface/EDAnalyzer.h"
00007 #include "FWCore/Framework/interface/OutputModule.h"
00008 #include "FWCore/Framework/interface/one/EDProducerBase.h"
00009 #include "FWCore/Framework/interface/one/EDFilterBase.h"
00010 
00011 namespace edm{
00012   UnscheduledHandler* getUnscheduledHandler(EventPrincipal const& ep) {
00013     return ep.unscheduledHandler().get();
00014   }
00015 
00016 
00017   template<typename T>
00018   inline
00019   WorkerT<T>::WorkerT(std::unique_ptr<T>&& ed, ModuleDescription const& md, WorkerParams const& wp) :
00020   Worker(md, wp),
00021   module_(std::move(ed)) {
00022     assert(module_.get() != 0);
00023     module_->setModuleDescription(md);
00024     module_->registerProductsAndCallbacks(module_.get(), wp.reg_);
00025   }
00026   
00027   template<typename T>
00028   WorkerT<T>::~WorkerT() {
00029   }
00030   
00031   template<typename T>
00032   inline
00033   bool
00034   WorkerT<T>::implDoBegin(EventPrincipal& ep, EventSetup const& c, CurrentProcessingContext const* cpc) {
00035     UnscheduledHandlerSentry s(getUnscheduledHandler(ep), cpc);
00036     boost::shared_ptr<Worker> sentry(this,[&ep](Worker* obj) {obj->postDoEvent(ep);});
00037     return module_->doEvent(ep, c, cpc);
00038   }
00039   
00040   template<typename T>
00041   inline
00042   bool
00043   WorkerT<T>::implDoEnd(EventPrincipal&, EventSetup const&, CurrentProcessingContext const*) {
00044     return false;
00045   }
00046   
00047   template<typename T>
00048   inline
00049   bool
00050   WorkerT<T>::implDoBegin(RunPrincipal& rp, EventSetup const& c, CurrentProcessingContext const* cpc) {
00051     module_->doBeginRun(rp, c, cpc);
00052     return true;
00053   }
00054   
00055   template<typename T>
00056   inline
00057   bool
00058   WorkerT<T>::implDoEnd(RunPrincipal& rp, EventSetup const& c, CurrentProcessingContext const* cpc) {
00059     module_->doEndRun(rp, c, cpc);
00060     return true;
00061   }
00062   
00063   template<typename T>
00064   inline
00065   bool
00066   WorkerT<T>::implDoBegin(LuminosityBlockPrincipal& lbp, EventSetup const& c, CurrentProcessingContext const* cpc) {
00067     module_->doBeginLuminosityBlock(lbp, c, cpc);
00068     return true;
00069   }
00070   
00071   template<typename T>
00072   inline
00073   bool
00074   WorkerT<T>::implDoEnd(LuminosityBlockPrincipal& lbp, EventSetup const& c, CurrentProcessingContext const* cpc) {
00075     module_->doEndLuminosityBlock(lbp, c, cpc);
00076     return true;
00077   }
00078   
00079   template<typename T>
00080   inline
00081   std::string
00082   WorkerT<T>::workerType() const {
00083     return module_->workerType();
00084   }
00085   
00086   template<typename T>
00087   inline
00088   void
00089   WorkerT<T>::implBeginJob() {
00090     module_->doBeginJob();
00091   }
00092   
00093   template<typename T>
00094   inline
00095   void
00096   WorkerT<T>::implEndJob() {
00097     module_->doEndJob();
00098   }
00099   
00100   template<typename T>
00101   inline
00102   void
00103   WorkerT<T>::implRespondToOpenInputFile(FileBlock const& fb) {
00104     module_->doRespondToOpenInputFile(fb);
00105   }
00106   
00107   template<typename T>
00108   inline
00109   void
00110   WorkerT<T>::implRespondToCloseInputFile(FileBlock const& fb) {
00111     module_->doRespondToCloseInputFile(fb);
00112   }
00113   
00114   template<typename T>
00115   inline
00116   void
00117   WorkerT<T>::implRespondToOpenOutputFiles(FileBlock const& fb) {
00118     module_->doRespondToOpenOutputFiles(fb);
00119   }
00120   
00121   template<typename T>
00122   inline
00123   void
00124   WorkerT<T>::implRespondToCloseOutputFiles(FileBlock const& fb) {
00125     module_->doRespondToCloseOutputFiles(fb);
00126   }
00127   
00128   template<typename T>
00129   inline
00130   void
00131   WorkerT<T>::implPreForkReleaseResources() {
00132     module_->doPreForkReleaseResources();
00133   }
00134   
00135   template<typename T>
00136   inline
00137   void
00138   WorkerT<T>::implPostForkReacquireResources(unsigned int iChildIndex,
00139                                              unsigned int iNumberOfChildren) {
00140     module_->doPostForkReacquireResources(iChildIndex, iNumberOfChildren);
00141   }
00142 
00143   template<typename T>
00144   void WorkerT<T>::updateLookup(BranchType iBranchType,
00145                                 ProductHolderIndexHelper const& iHelper) {
00146     module_->updateLookup(iBranchType,iHelper);
00147   }
00148 
00149   template<typename T>
00150   void WorkerT<T>::setEventSelectionInfo(std::map<std::string, std::vector<std::pair<std::string, int> > > const& outputModulePathPositions,
00151                              bool anyProductProduced) {
00152     //do nothing for the regular case
00153   }
00154 
00155 
00156   template<>
00157   void WorkerT<OutputModule>::setEventSelectionInfo(std::map<std::string, std::vector<std::pair<std::string, int> > > const& outputModulePathPositions,
00158                              bool anyProductProduced) {
00159     module_->setEventSelectionInfo(outputModulePathPositions, anyProductProduced);
00160   }
00161 
00162   template<>
00163   Worker::Types WorkerT<EDAnalyzer>::moduleType() const { return Worker::kAnalyzer;}
00164   template<>
00165   Worker::Types WorkerT<EDProducer>::moduleType() const { return Worker::kProducer;}
00166   template<>
00167   Worker::Types WorkerT<EDFilter>::moduleType() const { return Worker::kFilter;}
00168   template<>
00169   Worker::Types WorkerT<OutputModule>::moduleType() const { return Worker::kOutputModule;}
00170   template<>
00171   Worker::Types WorkerT<edm::one::EDProducerBase>::moduleType() const { return Worker::kProducer;}
00172   template<>
00173   Worker::Types WorkerT<edm::one::EDFilterBase>::moduleType() const { return Worker::kFilter;}
00174 
00175   
00176   //Explicitly instantiate our needed templates to avoid having the compiler
00177   // instantiate them in all of our libraries
00178   template class WorkerT<EDProducer>;
00179   template class WorkerT<EDFilter>;
00180   template class WorkerT<EDAnalyzer>;
00181   template class WorkerT<OutputModule>;
00182   template class WorkerT<one::EDProducerBase>;
00183   template class WorkerT<one::EDFilterBase>;
00184 }