CMS 3D CMS Logo

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::ModuleHoldermakeModule (MakeModuleParams const &, signalslot::Signal< void(ModuleDescription const &)> &iPre, signalslot::Signal< void(ModuleDescription const &)> &iPost) const
 
std::shared_ptr< maker::ModuleHoldermakeReplacementModule (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::ModuleHoldermakeModule (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 23 of file WorkerMaker.h.

Constructor & Destructor Documentation

edm::Maker::~Maker ( )
virtual

Definition at line 15 of file WorkerMaker.cc.

15  {
16  }

Member Function Documentation

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

Implemented in edm::WorkerMaker< T >.

Referenced by makeModule(), and makeReplacementModule().

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

Definition at line 19 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(), and makeReplacementModule().

19  {
20  ParameterSet const& conf = *p.pset_;
21  ModuleDescription md(conf.id(),
22  conf.getParameter<std::string>("@module_type"),
23  conf.getParameter<std::string>("@module_label"),
24  p.processConfiguration_.get(),
26  return md;
27  }
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(), and makeReplacementModule().

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 65 of file WorkerMaker.cc.

References baseType(), createModuleDescription(), fillDescriptions(), edm::ParameterSet::getParameter(), edm::pset::Registry::insertMapped(), edm::pset::Registry::instance(), python.rootplot.argparse::module, edm::MakeModuleParams::preallocate_, 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().

67  {
68  ConfigurationDescriptions descriptions(baseType());
69  fillDescriptions(descriptions);
70  try {
72  descriptions.validate(*p.pset_, p.pset_->getParameter<std::string>("@module_label"));
74  });
75  }
76  catch (cms::Exception & iException) {
77  throwValidationException(p, iException);
78  }
79  p.pset_->registerIt();
80  //Need to be certain top level untracked parameters are stored in
81  // the registry even if another PSet already exists in the
82  // registry from a previous process
83  //NOTE: a better implementation would be to change ParameterSet::registerIt
84  // but that would require rebuilding much more code so will be done at
85  // a later date.
87 
88  ModuleDescription md = createModuleDescription(p);
89  std::shared_ptr<maker::ModuleHolder> module;
90  bool postCalled = false;
91  try {
93  pre(md);
94  module = makeModule(*(p.pset_));
95  module->setModuleDescription(md);
96  module->preallocate(*(p.preallocate_));
97  module->registerProductsAndCallbacks(p.reg_);
98  // if exception then post will be called in the catch block
99  postCalled = true;
100  post(md);
101  });
102  }
103  catch(cms::Exception & iException){
104  if(!postCalled) {
105  try {
106  post(md);
107  }
108  catch (...) {
109  // If post throws an exception ignore it because we are already handling another exception
110  }
111  }
112  throwConfigurationException(md, iException);
113  }
114  return module;
115  }
void throwConfigurationException(ModuleDescription const &md, cms::Exception &iException) const
Definition: WorkerMaker.cc:44
bool insertMapped(value_type const &v, bool forceUpdate=false)
Definition: Registry.cc:35
void validateEDMType(std::string const &edmType, MakeModuleParams const &p) const
Definition: WorkerMaker.cc:53
virtual void fillDescriptions(ConfigurationDescriptions &iDesc) const =0
virtual const std::string & baseType() const =0
std::shared_ptr< maker::ModuleHolder > makeModule(MakeModuleParams const &, signalslot::Signal< void(ModuleDescription const &)> &iPre, signalslot::Signal< void(ModuleDescription const &)> &iPost) const
Definition: WorkerMaker.cc:65
ModuleDescription createModuleDescription(MakeModuleParams const &p) const
Definition: WorkerMaker.cc:19
auto wrap(F iFunc) -> decltype(iFunc())
static Registry * instance()
Definition: Registry.cc:12
void throwValidationException(MakeModuleParams const &p, cms::Exception &iException) const
Definition: WorkerMaker.cc:30
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 32 of file WorkerMaker.h.

References actions, baseType(), createModuleDescription(), fillDescriptions(), makeModule(), makeWorker(), mod(), AlCaHLTBitMon_ParallelJobs::p, AlCaHLTBitMon_QueryRunRegistry::string, throwConfigurationException(), throwValidationException(), and validateEDMType().

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

Definition at line 118 of file WorkerMaker.cc.

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

Referenced by makeReplacementModule(), and edm::maker::ModuleHolder::makeWorker().

119  {
120 
121  return makeWorker(actions,mod->moduleDescription(),mod);
122  }
roAction_t actions[nactions]
Definition: GenABIO.cc:187
std::unique_ptr< Worker > makeWorker(ExceptionToActionTable const *, maker::ModuleHolder const *) const
Definition: WorkerMaker.cc:118
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 44 of file WorkerMaker.cc.

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

Referenced by makeModule(), and makeReplacementModule().

45  {
46  std::ostringstream ost;
47  ost << "Constructing module: class=" << md.moduleName() << " label='" << md.moduleLabel() << "'";
48  iException.addContext(ost.str());
49  throw;
50  }
void addContext(std::string const &context)
Definition: Exception.cc:227
void edm::Maker::throwValidationException ( MakeModuleParams const &  p,
cms::Exception iException 
) const
protected

Definition at line 30 of file WorkerMaker.cc.

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

Referenced by makeModule(), and makeReplacementModule().

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

Definition at line 53 of file WorkerMaker.cc.

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

Referenced by makeModule(), and makeReplacementModule().

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