CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 23 of file WorkerMaker.h.

Constructor & Destructor Documentation

edm::Maker::~Maker ( )
virtual

Definition at line 14 of file WorkerMaker.cc.

14  {
15  }

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 dbtoconf::conf, edm::ParameterSet::getParameter(), edm::ModuleDescription::getUniqueID(), edm::ParameterSet::id(), popcon2dropbox_job_conf::md, 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...
tuple conf
Definition: dbtoconf.py:185
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 64 of file WorkerMaker.cc.

References baseType(), createModuleDescription(), fillDescriptions(), edm::ParameterSet::getParameter(), popcon2dropbox_job_conf::md, 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().

66  {
67  ConfigurationDescriptions descriptions(baseType());
68  fillDescriptions(descriptions);
69  try {
71  descriptions.validate(*p.pset_, p.pset_->getParameter<std::string>("@module_label"));
73  });
74  }
75  catch (cms::Exception & iException) {
76  throwValidationException(p, iException);
77  }
78  p.pset_->registerIt();
79 
80  ModuleDescription md = createModuleDescription(p);
81  std::shared_ptr<maker::ModuleHolder> module;
82  bool postCalled = false;
83  try {
85  pre(md);
86  module = makeModule(*(p.pset_));
87  module->setModuleDescription(md);
88  module->preallocate(*(p.preallocate_));
89  module->registerProductsAndCallbacks(p.reg_);
90  // if exception then post will be called in the catch block
91  postCalled = true;
92  post(md);
93  });
94  }
95  catch(cms::Exception & iException){
96  if(!postCalled) {
97  try {
98  post(md);
99  }
100  catch (...) {
101  // If post throws an exception ignore it because we are already handling another exception
102  }
103  }
104  throwConfigurationException(md, iException);
105  }
106  return module;
107  }
void throwConfigurationException(ModuleDescription const &md, cms::Exception &iException) const
Definition: WorkerMaker.cc:43
virtual const std::string & baseType() const =0
virtual void fillDescriptions(ConfigurationDescriptions &iDesc) const =0
void validateEDMType(std::string const &edmType, MakeModuleParams const &p) const
Definition: WorkerMaker.cc:52
std::shared_ptr< maker::ModuleHolder > makeModule(MakeModuleParams const &, signalslot::Signal< void(ModuleDescription const &)> &iPre, signalslot::Signal< void(ModuleDescription const &)> &iPost) const
Definition: WorkerMaker.cc:64
ModuleDescription createModuleDescription(MakeModuleParams const &p) const
Definition: WorkerMaker.cc:18
auto wrap(F iFunc) -> decltype(iFunc())
void throwValidationException(MakeModuleParams const &p, cms::Exception &iException) const
Definition: WorkerMaker.cc:29
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 makeModule().

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:64
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 
113  return makeWorker(actions,mod->moduleDescription(),mod);
114  }
actions
Definition: Schedule.cc:368
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 43 of file WorkerMaker.cc.

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

Referenced by makeModule().

44  {
45  std::ostringstream ost;
46  ost << "Constructing module: class=" << md.moduleName() << " label='" << md.moduleLabel() << "'";
47  iException.addContext(ost.str());
48  throw;
49  }
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 29 of file WorkerMaker.cc.

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

Referenced by makeModule().

30  {
31  ParameterSet const& conf = *p.pset_;
32  std::string moduleName = conf.getParameter<std::string>("@module_type");
33  std::string moduleLabel = conf.getParameter<std::string>("@module_label");
34 
35  std::ostringstream ost;
36  ost << "Validating configuration of module: class=" << moduleName
37  << " label='" << moduleLabel << "'";
38  iException.addContext(ost.str());
39  throw;
40  }
std::string moduleName(Provenance const &provenance)
Definition: Provenance.cc:27
tuple conf
Definition: dbtoconf.py:185
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 52 of file WorkerMaker.cc.

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

Referenced by makeModule().

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