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 | Protected Member Functions | Private Member Functions
edm::Maker Class Referenceabstract

#include <WorkerMaker.h>

Inheritance diagram for edm::Maker:
edm::WorkerMaker< T >

Public Member Functions

std::shared_ptr
< maker::ModuleHolder
makeModule (MakeModuleParams const &, signalslot::Signal< void(ModuleDescription const &)> &iPre, signalslot::Signal< void(ModuleDescription const &)> &iPost) const
 
std::shared_ptr
< maker::ModuleHolder
makeReplacementModule (edm::ParameterSet const &p) const
 
std::unique_ptr< WorkermakeWorker (ExceptionToActionTable const *, maker::ModuleHolder const *) const
 
virtual ~Maker ()
 

Protected Member Functions

ModuleDescription createModuleDescription (MakeModuleParams const &p) const
 
void throwConfigurationException (ModuleDescription const &md, cms::Exception &iException) const
 
void throwValidationException (MakeModuleParams const &p, cms::Exception &iException) const
 
void validateEDMType (std::string const &edmType, MakeModuleParams const &p) const
 

Private Member Functions

virtual const std::string & baseType () const =0
 
virtual void fillDescriptions (ConfigurationDescriptions &iDesc) const =0
 
virtual std::shared_ptr
< maker::ModuleHolder
makeModule (edm::ParameterSet const &p) const =0
 
virtual std::unique_ptr< WorkermakeWorker (ExceptionToActionTable const *actions, ModuleDescription const &md, maker::ModuleHolder const *mod) const =0
 

Detailed Description

Definition at line 21 of file WorkerMaker.h.

Constructor & Destructor Documentation

edm::Maker::~Maker ( )
virtual

Definition at line 16 of file WorkerMaker.cc.

16 {}

Member Function Documentation

virtual const std::string& edm::Maker::baseType ( ) const
privatepure virtual

Implemented in edm::WorkerMaker< T >.

Referenced by makeModule().

ModuleDescription edm::Maker::createModuleDescription ( MakeModuleParams const &  p) const
protected

Definition at line 18 of file WorkerMaker.cc.

References edm::ParameterSet::getParameter(), edm::ModuleDescription::getUniqueID(), edm::ParameterSet::id(), edm::MakeModuleParams::processConfiguration_, edm::MakeModuleParams::pset_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by makeModule().

18  {
19  ParameterSet const& conf = *p.pset_;
20  ModuleDescription md(conf.id(),
21  conf.getParameter<std::string>("@module_type"),
22  conf.getParameter<std::string>("@module_label"),
23  p.processConfiguration_.get(),
25  return md;
26  }
static unsigned int getUniqueID()
Returns a unique id each time called. Intended to be passed to ModuleDescription&#39;s constructor&#39;s modI...
virtual void edm::Maker::fillDescriptions ( ConfigurationDescriptions iDesc) const
privatepure virtual

Implemented in edm::WorkerMaker< T >.

Referenced by makeModule().

std::shared_ptr< maker::ModuleHolder > edm::Maker::makeModule ( MakeModuleParams const &  p,
signalslot::Signal< void(ModuleDescription const &)> &  iPre,
signalslot::Signal< void(ModuleDescription const &)> &  iPost 
) const

Definition at line 57 of file WorkerMaker.cc.

References edm::ParameterSet::addUntrackedParameter(), baseType(), CMS_SA_ALLOW, createModuleDescription(), fillDescriptions(), edm::ParameterSet::getParameter(), edm::pset::Registry::insertMapped(), edm::pset::Registry::instance(), callgraph::module, edm::MakeModuleParams::preallocate_, edm::MakeModuleParams::processConfiguration_, edm::MakeModuleParams::pset_, edm::MakeModuleParams::reg_, edm::ParameterSet::registerIt(), AlCaHLTBitMon_QueryRunRegistry::string, throwConfigurationException(), throwValidationException(), edm::ConfigurationDescriptions::validate(), validateEDMType(), and edm::convertException::wrap().

Referenced by makeReplacementModule().

60  {
61  // Add process_name for SwitchProducer
62  if (p.pset_->getParameter<std::string>("@module_type") == "SwitchProducer") {
63  p.pset_->addUntrackedParameter("@process_name", p.processConfiguration_->processName());
64  }
65 
66  ConfigurationDescriptions descriptions(baseType(), p.pset_->getParameter<std::string>("@module_type"));
67  fillDescriptions(descriptions);
68  try {
70  descriptions.validate(*p.pset_, p.pset_->getParameter<std::string>("@module_label"));
72  });
73  } catch (cms::Exception& iException) {
74  throwValidationException(p, iException);
75  }
76  p.pset_->registerIt();
77  //Need to be certain top level untracked parameters are stored in
78  // the registry even if another PSet already exists in the
79  // registry from a previous process
80  //NOTE: a better implementation would be to change ParameterSet::registerIt
81  // but that would require rebuilding much more code so will be done at
82  // a later date.
83  edm::pset::Registry::instance()->insertMapped(*(p.pset_), true);
84 
85  ModuleDescription md = createModuleDescription(p);
86  std::shared_ptr<maker::ModuleHolder> module;
87  bool postCalled = false;
88  try {
90  pre(md);
91  module = makeModule(*(p.pset_));
92  module->setModuleDescription(md);
93  module->preallocate(*(p.preallocate_));
94  module->registerProductsAndCallbacks(p.reg_);
95  // if exception then post will be called in the catch block
96  postCalled = true;
97  post(md);
98  });
99  } catch (cms::Exception& iException) {
100  if (!postCalled) {
101  CMS_SA_ALLOW try { post(md); } catch (...) {
102  // If post throws an exception ignore it because we are already handling another exception
103  }
104  }
105  throwConfigurationException(md, iException);
106  }
107  return module;
108  }
#define CMS_SA_ALLOW
void throwConfigurationException(ModuleDescription const &md, cms::Exception &iException) const
Definition: WorkerMaker.cc:39
virtual const std::string & baseType() const =0
virtual void fillDescriptions(ConfigurationDescriptions &iDesc) const =0
bool insertMapped(value_type const &v, bool forceUpdate=false)
Definition: Registry.cc:32
void validateEDMType(std::string const &edmType, MakeModuleParams const &p) const
Definition: WorkerMaker.cc:46
std::shared_ptr< maker::ModuleHolder > makeModule(MakeModuleParams const &, signalslot::Signal< void(ModuleDescription const &)> &iPre, signalslot::Signal< void(ModuleDescription const &)> &iPost) const
Definition: WorkerMaker.cc:57
ModuleDescription createModuleDescription(MakeModuleParams const &p) const
Definition: WorkerMaker.cc:18
auto wrap(F iFunc) -> decltype(iFunc())
static Registry * instance()
Definition: Registry.cc:12
tuple module
Definition: callgraph.py:69
void throwValidationException(MakeModuleParams const &p, cms::Exception &iException) const
Definition: WorkerMaker.cc:28
virtual std::shared_ptr<maker::ModuleHolder> edm::Maker::makeModule ( edm::ParameterSet const &  p) const
privatepure virtual

Implemented in edm::WorkerMaker< T >.

std::shared_ptr<maker::ModuleHolder> edm::Maker::makeReplacementModule ( edm::ParameterSet const &  p) const
inline

Definition at line 29 of file WorkerMaker.h.

References makeModule().

29  {
30  return makeModule(p);
31  }
std::shared_ptr< maker::ModuleHolder > makeModule(MakeModuleParams const &, signalslot::Signal< void(ModuleDescription const &)> &iPre, signalslot::Signal< void(ModuleDescription const &)> &iPost) const
Definition: WorkerMaker.cc:57
std::unique_ptr< Worker > edm::Maker::makeWorker ( ExceptionToActionTable const *  actions,
maker::ModuleHolder const *  mod 
) const

Definition at line 110 of file WorkerMaker.cc.

References mod(), and edm::maker::ModuleHolder::moduleDescription().

Referenced by edm::maker::ModuleHolder::makeWorker().

111  {
112  return makeWorker(actions, mod->moduleDescription(), mod);
113  }
actions
Definition: Schedule.cc:687
std::unique_ptr< Worker > makeWorker(ExceptionToActionTable const *, maker::ModuleHolder const *) const
Definition: WorkerMaker.cc:110
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
virtual std::unique_ptr<Worker> edm::Maker::makeWorker ( ExceptionToActionTable const *  actions,
ModuleDescription const &  md,
maker::ModuleHolder const *  mod 
) const
privatepure virtual

Implemented in edm::WorkerMaker< T >.

void edm::Maker::throwConfigurationException ( ModuleDescription const &  md,
cms::Exception iException 
) const
protected

Definition at line 39 of file WorkerMaker.cc.

References cms::Exception::addContext(), edm::ModuleDescription::moduleLabel(), and edm::ModuleDescription::moduleName().

Referenced by makeModule().

39  {
40  std::ostringstream ost;
41  ost << "Constructing module: class=" << md.moduleName() << " label='" << md.moduleLabel() << "'";
42  iException.addContext(ost.str());
43  throw;
44  }
void addContext(std::string const &context)
Definition: Exception.cc:165
void edm::Maker::throwValidationException ( MakeModuleParams const &  p,
cms::Exception iException 
) const
protected

Definition at line 28 of file WorkerMaker.cc.

References cms::Exception::addContext(), edm::ParameterSet::getParameter(), edm::moduleName(), edm::MakeModuleParams::pset_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by makeModule().

28  {
29  ParameterSet const& conf = *p.pset_;
30  std::string moduleName = conf.getParameter<std::string>("@module_type");
31  std::string moduleLabel = conf.getParameter<std::string>("@module_label");
32 
33  std::ostringstream ost;
34  ost << "Validating configuration of module: class=" << moduleName << " label='" << moduleLabel << "'";
35  iException.addContext(ost.str());
36  throw;
37  }
void addContext(std::string const &context)
Definition: Exception.cc:165
std::string moduleName(StableProvenance const &provenance, ProcessHistory const &history)
Definition: Provenance.cc:27
void edm::Maker::validateEDMType ( std::string const &  edmType,
MakeModuleParams const &  p 
) const
protected

Definition at line 46 of file WorkerMaker.cc.

References edm::errors::Configuration, Exception, edm::ParameterSet::getParameter(), edm::MakeModuleParams::pset_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by makeModule().

46  {
47  std::string expected = p.pset_->getParameter<std::string>("@module_edm_type");
48  if (edmType != expected) {
50  << "The base type in the python configuration is " << expected << ", but the base type\n"
51  << "for the module's C++ class is " << edmType << ". "
52  << "Please fix the configuration.\n"
53  << "It must use the same base type as the C++ class.\n";
54  }
55  }