CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Attributes
edm::WorkerRegistry Class Reference

The Registry of all workers that where requested Holds all instances of workers. In this implementation, Workers are owned. More...

#include "edm/WorkerRegistry.h"

Public Member Functions

void clear ()
 
void deleteModule (std::string const &moduleLabel)
 Deletes the module of the Worker, but the Worker continues to exist. More...
 
Worker const * get (std::string const &moduleLabel) const
 
WorkergetWorker (WorkerParams const &p, std::string const &moduleLabel)
 Retrieve the particular instance of the worker. More...
 
WorkerRegistryoperator= (WorkerRegistry const &)=delete
 
 WorkerRegistry (std::shared_ptr< ActivityRegistry > areg)
 
 WorkerRegistry (std::shared_ptr< ActivityRegistry > areg, std::shared_ptr< ModuleRegistry > iModReg)
 
 WorkerRegistry (WorkerRegistry &&)=default
 
 WorkerRegistry (WorkerRegistry const &)=delete
 
 ~WorkerRegistry ()
 

Private Types

typedef std::map< std::string, edm::propagate_const< std::shared_ptr< Worker > > > WorkerMap
 the container of workers More...
 

Private Attributes

std::shared_ptr< ActivityRegistryactReg_
 
WorkerMap m_workerMap
 internal map of registered workers (owned). More...
 
edm::propagate_const< std::shared_ptr< ModuleRegistry > > modRegistry_
 

Detailed Description

The Registry of all workers that where requested Holds all instances of workers. In this implementation, Workers are owned.

Definition at line 38 of file WorkerRegistry.h.

Member Typedef Documentation

◆ WorkerMap

typedef std::map<std::string, edm::propagate_const<std::shared_ptr<Worker> > > edm::WorkerRegistry::WorkerMap
private

the container of workers

Definition at line 65 of file WorkerRegistry.h.

Constructor & Destructor Documentation

◆ WorkerRegistry() [1/4]

edm::WorkerRegistry::WorkerRegistry ( std::shared_ptr< ActivityRegistry areg)
explicit

Definition at line 18 of file WorkerRegistry.cc.

19  : modRegistry_(new ModuleRegistry), m_workerMap(), actReg_(areg) {}

◆ WorkerRegistry() [2/4]

edm::WorkerRegistry::WorkerRegistry ( std::shared_ptr< ActivityRegistry areg,
std::shared_ptr< ModuleRegistry iModReg 
)

Definition at line 21 of file WorkerRegistry.cc.

22  : modRegistry_(modReg), m_workerMap(), actReg_(areg) {}

◆ ~WorkerRegistry()

edm::WorkerRegistry::~WorkerRegistry ( )

Definition at line 24 of file WorkerRegistry.cc.

24 {}

◆ WorkerRegistry() [3/4]

edm::WorkerRegistry::WorkerRegistry ( WorkerRegistry &&  )
default

◆ WorkerRegistry() [4/4]

edm::WorkerRegistry::WorkerRegistry ( WorkerRegistry const &  )
delete

Member Function Documentation

◆ clear()

void edm::WorkerRegistry::clear ( void  )

Definition at line 26 of file WorkerRegistry.cc.

26 { m_workerMap.clear(); }

References m_workerMap.

◆ deleteModule()

void edm::WorkerRegistry::deleteModule ( std::string const &  moduleLabel)

Deletes the module of the Worker, but the Worker continues to exist.

Definition at line 56 of file WorkerRegistry.cc.

56  {
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  }

References Exception, m_workerMap, and HerwigMaxPtPartonFilter_cfi::moduleLabel.

Referenced by edm::WorkerManager::deleteModuleIfExists().

◆ get()

Worker const * edm::WorkerRegistry::get ( std::string const &  moduleLabel) const

◆ getWorker()

Worker * edm::WorkerRegistry::getWorker ( WorkerParams const &  p,
std::string const &  moduleLabel 
)

Retrieve the particular instance of the worker.

If the worker with that set of parameters does not exist, create it

Note
Workers are owned by this class, do not delete them

Definition at line 28 of file WorkerRegistry.cc.

28  {
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  }

References actReg_, m_workerMap, modRegistry_, HerwigMaxPtPartonFilter_cfi::moduleLabel, and AlCaHLTBitMon_ParallelJobs::p.

Referenced by edm::WorkerManager::getWorker().

◆ operator=()

WorkerRegistry& edm::WorkerRegistry::operator= ( WorkerRegistry const &  )
delete

Member Data Documentation

◆ actReg_

std::shared_ptr<ActivityRegistry> edm::WorkerRegistry::actReg_
private

Definition at line 71 of file WorkerRegistry.h.

Referenced by getWorker().

◆ m_workerMap

WorkerMap edm::WorkerRegistry::m_workerMap
private

internal map of registered workers (owned).

Definition at line 70 of file WorkerRegistry.h.

Referenced by clear(), deleteModule(), get(), and getWorker().

◆ modRegistry_

edm::propagate_const<std::shared_ptr<ModuleRegistry> > edm::WorkerRegistry::modRegistry_
private

Definition at line 67 of file WorkerRegistry.h.

Referenced by getWorker().

edm::WorkerRegistry::m_workerMap
WorkerMap m_workerMap
internal map of registered workers (owned).
Definition: WorkerRegistry.h:70
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
edm::WorkerRegistry::actReg_
std::shared_ptr< ActivityRegistry > actReg_
Definition: WorkerRegistry.h:71
edm::WorkerRegistry::modRegistry_
edm::propagate_const< std::shared_ptr< ModuleRegistry > > modRegistry_
Definition: WorkerRegistry.h:67
Exception
Definition: hltDiff.cc:245
HerwigMaxPtPartonFilter_cfi.moduleLabel
moduleLabel
Definition: HerwigMaxPtPartonFilter_cfi.py:4