CMS 3D CMS Logo

WorkerRegistry.cc
Go to the documentation of this file.
1 
8 #include <memory>
15 
16 namespace edm {
17 
18  WorkerRegistry::WorkerRegistry(std::shared_ptr<ActivityRegistry> areg)
19  : modRegistry_(new ModuleRegistry), m_workerMap(), actReg_(areg) {}
20 
21  WorkerRegistry::WorkerRegistry(std::shared_ptr<ActivityRegistry> areg, std::shared_ptr<ModuleRegistry> modReg)
22  : modRegistry_(modReg), m_workerMap(), actReg_(areg) {}
23 
25 
26  void WorkerRegistry::clear() { m_workerMap.clear(); }
27 
29  WorkerMap::iterator workerIt = m_workerMap.find(moduleLabel);
30 
31  // if the worker is not there, make it
32  if (workerIt == m_workerMap.end()) {
33  MakeModuleParams mmp(p.pset_, *p.reg_, p.preallocate_, p.processConfiguration_);
34  auto modulePtr = modRegistry_->getModule(
35  mmp, moduleLabel, actReg_->preModuleConstructionSignal_, actReg_->postModuleConstructionSignal_);
36  auto workerPtr = modulePtr->makeWorker(p.actions_);
37 
38  workerPtr->setActivityRegistry(actReg_);
39 
40  // Transfer ownership of worker to the registry
42  std::shared_ptr<Worker>(workerPtr.release()); // propagate_const<T> has no reset() function
43  return m_workerMap[moduleLabel].get();
44  }
45  return (workerIt->second.get());
46  }
47 
49  WorkerMap::const_iterator workerIt = m_workerMap.find(moduleLabel);
50  if (workerIt != m_workerMap.end()) {
51  return workerIt->second;
52  }
53  return nullptr;
54  }
55 
57  WorkerMap::iterator workerIt = m_workerMap.find(moduleLabel);
58  if (workerIt == m_workerMap.end()) {
59  throw cms::Exception("LogicError")
60  << "WorkerRegistry::deleteModule() Trying to delete the module of a Worker with label " << moduleLabel
61  << " but no such Worker exists in the WorkerRegistry. Please contact framework developers.";
62  }
63  workerIt->second->clearModule();
64  }
65 
66 } // namespace edm
std::shared_ptr< ActivityRegistry > actReg_
WorkerRegistry(std::shared_ptr< ActivityRegistry > areg)
Worker const * get(std::string const &moduleLabel) const
void deleteModule(std::string const &moduleLabel)
Deletes the module of the Worker, but the Worker continues to exist.
WorkerMap m_workerMap
internal map of registered workers (owned).
edm::propagate_const< std::shared_ptr< ModuleRegistry > > modRegistry_
HLT enums.
Worker * getWorker(WorkerParams const &p, std::string const &moduleLabel)
Retrieve the particular instance of the worker.