CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Attributes
edm::ModuleRegistry Class Reference

#include "FWCore/Framework/interface/ModuleRegistry.h"

Public Member Functions

void deleteModule (std::string const &iModuleLabel, signalslot::Signal< void(ModuleDescription const &)> &iPre, signalslot::Signal< void(ModuleDescription const &)> &iPost)
 
template<typename F >
void forAllModuleHolders (F iFunc)
 
std::shared_ptr
< maker::ModuleHolder
getModule (MakeModuleParams const &p, std::string const &moduleLabel, signalslot::Signal< void(ModuleDescription const &)> &iPre, signalslot::Signal< void(ModuleDescription const &)> &iPost)
 
maker::ModuleHolderreplaceModule (std::string const &iModuleLabel, edm::ParameterSet const &iPSet, edm::PreallocationConfiguration const &)
 

Private Attributes

std::map< std::string,
edm::propagate_const
< std::shared_ptr
< maker::ModuleHolder > > > 
labelToModule_
 

Detailed Description

Description: Constructs and owns framework modules

Usage: <usage>

Definition at line 40 of file ModuleRegistry.h.

Member Function Documentation

void edm::ModuleRegistry::deleteModule ( std::string const &  iModuleLabel,
signalslot::Signal< void(ModuleDescription const &)> &  iPre,
signalslot::Signal< void(ModuleDescription const &)> &  iPost 
)

Definition at line 53 of file ModuleRegistry.cc.

References CMS_SA_ALLOW, Exception, and labelToModule_.

55  {
56  auto modItr = labelToModule_.find(iModuleLabel);
57  if (modItr == labelToModule_.end()) {
58  throw cms::Exception("LogicError")
59  << "Trying to delete module " << iModuleLabel
60  << " but it does not exist in the ModuleRegistry. Please contact framework developers.";
61  }
62  // If iPost throws and exception, let it propagate
63  // If deletion throws an exception, capture it and call iPost before throwing an exception
64  // If iPost throws an exception, let it propagate
65  auto md = modItr->second->moduleDescription();
66  iPre(modItr->second->moduleDescription());
67  bool postCalled = false;
68  // exception is rethrown
69  CMS_SA_ALLOW try {
70  labelToModule_.erase(modItr);
71  // if exception then post will be called in the catch block
72  postCalled = true;
73  iPost(md);
74  } catch (...) {
75  if (not postCalled) {
76  // we're already handling exception, nothing we can do if iPost throws
77  CMS_SA_ALLOW try { iPost(md); } catch (...) {
78  }
79  }
80  throw;
81  }
82  }
#define CMS_SA_ALLOW
std::map< std::string, edm::propagate_const< std::shared_ptr< maker::ModuleHolder > > > labelToModule_
template<typename F >
void edm::ModuleRegistry::forAllModuleHolders ( F  iFunc)
inline

Definition at line 56 of file ModuleRegistry.h.

References labelToModule_, and submitPVValidationJobs::t.

Referenced by edm::StreamSchedule::initializeEarlyDelete().

56  {
57  for (auto& labelMod : labelToModule_) {
58  maker::ModuleHolder* t = labelMod.second.get();
59  iFunc(t);
60  }
61  }
std::map< std::string, edm::propagate_const< std::shared_ptr< maker::ModuleHolder > > > labelToModule_
std::shared_ptr< maker::ModuleHolder > edm::ModuleRegistry::getModule ( MakeModuleParams const &  p,
std::string const &  moduleLabel,
signalslot::Signal< void(ModuleDescription const &)> &  iPre,
signalslot::Signal< void(ModuleDescription const &)> &  iPost 
)

Definition at line 20 of file ModuleRegistry.cc.

References edm::Factory::get(), edm::get_underlying_safe(), labelToModule_, and edm::Factory::makeModule().

24  {
25  auto modItr = labelToModule_.find(moduleLabel);
26  if (modItr == labelToModule_.end()) {
27  auto modPtr = Factory::get()->makeModule(p, iPre, iPost);
28 
29  // Transfer ownership of worker to the registry
30  labelToModule_[moduleLabel] = modPtr;
31  return modPtr;
32  }
33  return get_underlying_safe(modItr->second);
34  }
constexpr std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
std::shared_ptr< maker::ModuleHolder > makeModule(const MakeModuleParams &, signalslot::Signal< void(const ModuleDescription &)> &pre, signalslot::Signal< void(const ModuleDescription &)> &post) const
Definition: Factory.cc:56
std::map< std::string, edm::propagate_const< std::shared_ptr< maker::ModuleHolder > > > labelToModule_
static Factory const * get()
Definition: Factory.cc:24
maker::ModuleHolder * edm::ModuleRegistry::replaceModule ( std::string const &  iModuleLabel,
edm::ParameterSet const &  iPSet,
edm::PreallocationConfiguration const &  iPrealloc 
)

Definition at line 36 of file ModuleRegistry.cc.

References edm::Factory::get(), labelToModule_, and edm::Factory::makeReplacementModule().

38  {
39  auto modItr = labelToModule_.find(iModuleLabel);
40  if (modItr == labelToModule_.end()) {
41  return nullptr;
42  }
43 
44  auto modPtr = Factory::get()->makeReplacementModule(iPSet);
45  modPtr->setModuleDescription(modItr->second->moduleDescription());
46  modPtr->preallocate(iPrealloc);
47 
48  // Transfer ownership of worker to the registry
49  modItr->second = modPtr;
50  return modItr->second.get();
51  }
std::shared_ptr< maker::ModuleHolder > makeReplacementModule(const edm::ParameterSet &) const
Definition: Factory.cc:65
std::map< std::string, edm::propagate_const< std::shared_ptr< maker::ModuleHolder > > > labelToModule_
static Factory const * get()
Definition: Factory.cc:24

Member Data Documentation

std::map<std::string, edm::propagate_const<std::shared_ptr<maker::ModuleHolder> > > edm::ModuleRegistry::labelToModule_
private

Definition at line 64 of file ModuleRegistry.h.

Referenced by deleteModule(), forAllModuleHolders(), getModule(), and replaceModule().