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 22 of file WorkerMaker.h.

Constructor & Destructor Documentation

edm::Maker::~Maker ( )
virtual

Definition at line 15 of file WorkerMaker.cc.

15 {}

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 17 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().

17  {
18  ParameterSet const& conf = *p.pset_;
19  ModuleDescription md(conf.id(),
20  conf.getParameter<std::string>("@module_type"),
21  conf.getParameter<std::string>("@module_label"),
22  p.processConfiguration_.get(),
24  return md;
25  }
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 56 of file WorkerMaker.cc.

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

59  {
60  ConfigurationDescriptions descriptions(baseType(), p.pset_->getParameter<std::string>("@module_type"));
61  fillDescriptions(descriptions);
62  try {
64  descriptions.validate(*p.pset_, p.pset_->getParameter<std::string>("@module_label"));
66  });
67  } catch (cms::Exception& iException) {
68  throwValidationException(p, iException);
69  }
70  p.pset_->registerIt();
71  //Need to be certain top level untracked parameters are stored in
72  // the registry even if another PSet already exists in the
73  // registry from a previous process
74  //NOTE: a better implementation would be to change ParameterSet::registerIt
75  // but that would require rebuilding much more code so will be done at
76  // a later date.
77  edm::pset::Registry::instance()->insertMapped(*(p.pset_), true);
78 
79  ModuleDescription md = createModuleDescription(p);
80  std::shared_ptr<maker::ModuleHolder> module;
81  bool postCalled = false;
82  try {
84  pre(md);
85  module = makeModule(*(p.pset_));
86  module->setModuleDescription(md);
87  module->preallocate(*(p.preallocate_));
88  module->registerProductsAndCallbacks(p.reg_);
89  // if exception then post will be called in the catch block
90  postCalled = true;
91  post(md);
92  });
93  } catch (cms::Exception& iException) {
94  if (!postCalled) {
95  try {
96  post(md);
97  } catch (...) {
98  // If post throws an exception ignore it because we are already handling another exception
99  }
100  }
101  throwConfigurationException(md, iException);
102  }
103  return module;
104  }
void throwConfigurationException(ModuleDescription const &md, cms::Exception &iException) const
Definition: WorkerMaker.cc:38
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:45
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:56
ModuleDescription createModuleDescription(MakeModuleParams const &p) const
Definition: WorkerMaker.cc:17
auto wrap(F iFunc) -> decltype(iFunc())
Definition: vlib.h:208
static Registry * instance()
Definition: Registry.cc:12
void throwValidationException(MakeModuleParams const &p, cms::Exception &iException) const
Definition: WorkerMaker.cc:27
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 30 of file WorkerMaker.h.

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

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

Definition at line 106 of file WorkerMaker.cc.

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

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

107  {
108  return makeWorker(actions, mod->moduleDescription(), mod);
109  }
roAction_t actions[nactions]
Definition: GenABIO.cc:181
std::unique_ptr< Worker > makeWorker(ExceptionToActionTable const *, maker::ModuleHolder const *) const
Definition: WorkerMaker.cc:106
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 38 of file WorkerMaker.cc.

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

Referenced by makeModule(), and makeReplacementModule().

38  {
39  std::ostringstream ost;
40  ost << "Constructing module: class=" << md.moduleName() << " label='" << md.moduleLabel() << "'";
41  iException.addContext(ost.str());
42  throw;
43  }
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 27 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().

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

Definition at line 45 of file WorkerMaker.cc.

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

Referenced by makeModule(), and makeReplacementModule().

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