00001 00009 #include "FWCore/Framework/src/WorkerRegistry.h" 00010 #include "FWCore/Framework/src/Worker.h" 00011 #include "FWCore/Framework/src/Factory.h" 00012 #include "FWCore/ServiceRegistry/interface/ActivityRegistry.h" 00013 00014 namespace edm { 00015 00016 WorkerRegistry::WorkerRegistry(boost::shared_ptr<ActivityRegistry> areg) : 00017 m_workerMap(), 00018 actReg_(areg) 00019 { 00020 } 00021 00022 WorkerRegistry:: ~WorkerRegistry() { 00023 m_workerMap.clear(); 00024 } 00025 00026 void WorkerRegistry::clear() { 00027 m_workerMap.clear(); 00028 } 00029 00030 Worker* WorkerRegistry::getWorker(WorkerParams const& p, std::string const& moduleLabel) { 00031 00032 WorkerMap::iterator workerIt = m_workerMap.find(moduleLabel); 00033 00034 // if the worker is not there, make it 00035 if (workerIt == m_workerMap.end()){ 00036 00037 std::auto_ptr<Worker> workerPtr= 00038 Factory::get()->makeWorker(p,actReg_->preModuleConstructionSignal_, 00039 actReg_->postModuleConstructionSignal_); 00040 00041 workerPtr->setActivityRegistry(actReg_); 00042 00043 // Transfer ownership of worker to the registry 00044 m_workerMap[moduleLabel].reset(workerPtr.release()); 00045 return m_workerMap[moduleLabel].get(); 00046 } 00047 return (workerIt->second.get()); 00048 } 00049 }