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(), 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 edm::convertException::badAllocToEDM(), baseType(), trackerHits::c, edm::convertException::charPtrToEDM(), createModuleDescription(), alignCSCRings::e, cppFunctionSkipper::exception, fillDescriptions(), edm::ParameterSet::getParameter(), python.rootplot.argparse::module, edm::MakeModuleParams::preallocate_, edm::MakeModuleParams::pset_, edm::MakeModuleParams::reg_, edm::ParameterSet::registerIt(), alignCSCRings::s, edm::convertException::stdToEDM(), AlCaHLTBitMon_QueryRunRegistry::string, edm::convertException::stringToEDM(), throwConfigurationException(), throwValidationException(), edm::convertException::unknownToEDM(), edm::ConfigurationDescriptions::validate(), and validateEDMType().

Referenced by makeReplacementModule().

66  {
67  ConfigurationDescriptions descriptions(baseType());
68  fillDescriptions(descriptions);
69  try {
70  try {
71  descriptions.validate(*p.pset_, p.pset_->getParameter<std::string>("@module_label"));
73  }
74  catch (cms::Exception& e) { throw; }
75  catch(std::bad_alloc& bda) { convertException::badAllocToEDM(); }
78  catch(char const* c) { convertException::charPtrToEDM(c); }
79  catch (...) { convertException::unknownToEDM(); }
80  }
81  catch (cms::Exception & iException) {
82  throwValidationException(p, iException);
83  }
84  p.pset_->registerIt();
85 
86  ModuleDescription md = createModuleDescription(p);
87  std::shared_ptr<maker::ModuleHolder> module;
88  bool postCalled = false;
89  try {
90  try {
91  pre(md);
92  module = makeModule(*(p.pset_));
93  module->setModuleDescription(md);
94  module->preallocate(*(p.preallocate_));
95  module->registerProductsAndCallbacks(p.reg_);
96  // if exception then post will be called in the catch block
97  postCalled = true;
98  post(md);
99  }
100  catch (cms::Exception& e) { throw; }
101  catch(std::bad_alloc& bda) { convertException::badAllocToEDM(); }
102  catch (std::exception& e) { convertException::stdToEDM(e); }
104  catch(char const* c) { convertException::charPtrToEDM(c); }
105  catch (...) { convertException::unknownToEDM(); }
106  }
107  catch(cms::Exception & iException){
108  if(!postCalled) {
109  try {
110  post(md);
111  }
112  catch (...) {
113  // If post throws an exception ignore it because we are already handling another exception
114  }
115  }
116  throwConfigurationException(md, iException);
117  }
118  return module;
119  }
void throwConfigurationException(ModuleDescription const &md, cms::Exception &iException) const
Definition: WorkerMaker.cc:43
virtual const std::string & baseType() const =0
void stdToEDM(std::exception const &e)
virtual void fillDescriptions(ConfigurationDescriptions &iDesc) const =0
void validateEDMType(std::string const &edmType, MakeModuleParams const &p) const
Definition: WorkerMaker.cc:52
void charPtrToEDM(char const *c)
void stringToEDM(std::string &s)
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
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 122 of file WorkerMaker.cc.

References mod().

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

123  {
124 
125  return makeWorker(actions,mod->moduleDescription(),mod);
126  }
actions
Definition: Schedule.cc:362
std::unique_ptr< Worker > makeWorker(ExceptionToActionTable const *, maker::ModuleHolder const *) const
Definition: WorkerMaker.cc:122
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  }