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
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::WorkerRegistry::m_workerMap
WorkerMap m_workerMap
internal map of registered workers (owned).
Definition: WorkerRegistry.h:70
edm::MakeModuleParams
Definition: MakeModuleParams.h:21
edm::WorkerRegistry::clear
void clear()
Definition: WorkerRegistry.cc:26
edm::WorkerRegistry::WorkerRegistry
WorkerRegistry(std::shared_ptr< ActivityRegistry > areg)
Definition: WorkerRegistry.cc:18
ActivityRegistry.h
edm::WorkerRegistry::getWorker
Worker * getWorker(WorkerParams const &p, std::string const &moduleLabel)
Retrieve the particular instance of the worker.
Definition: WorkerRegistry.cc:28
edm::WorkerRegistry::get
Worker const * get(std::string const &moduleLabel) const
Definition: WorkerRegistry.cc:48
edm::Worker
Definition: Worker.h:91
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
MakeModuleParams.h
edm::WorkerParams
Definition: WorkerParams.h:22
edm::WorkerRegistry::actReg_
std::shared_ptr< ActivityRegistry > actReg_
Definition: WorkerRegistry.h:71
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
ModuleRegistry.h
edm::ModuleRegistry
Definition: ModuleRegistry.h:40
ModuleHolder.h
edm::WorkerRegistry::modRegistry_
edm::propagate_const< std::shared_ptr< ModuleRegistry > > modRegistry_
Definition: WorkerRegistry.h:67
edm::WorkerRegistry::deleteModule
void deleteModule(std::string const &moduleLabel)
Deletes the module of the Worker, but the Worker continues to exist.
Definition: WorkerRegistry.cc:56
Exception
Definition: hltDiff.cc:245
Worker.h
WorkerRegistry.h
HerwigMaxPtPartonFilter_cfi.moduleLabel
moduleLabel
Definition: HerwigMaxPtPartonFilter_cfi.py:4
edm::WorkerRegistry::~WorkerRegistry
~WorkerRegistry()
Definition: WorkerRegistry.cc:24