test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
WorkerMaker.cc
Go to the documentation of this file.
1 
9 
10 #include <sstream>
11 #include <exception>
12 namespace edm {
13 
15  }
16 
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  }
27 
28  void
30  cms::Exception & iException) const {
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  }
41 
42  void
44  cms::Exception & iException) const {
45  std::ostringstream ost;
46  ost << "Constructing module: class=" << md.moduleName() << " label='" << md.moduleLabel() << "'";
47  iException.addContext(ost.str());
48  throw;
49  }
50 
51  void
52  Maker::validateEDMType(std::string const& edmType, MakeModuleParams const& p) const {
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  }
62 
63  std::shared_ptr<maker::ModuleHolder>
65  signalslot::Signal<void(ModuleDescription const&)>& pre,
66  signalslot::Signal<void(ModuleDescription const&)>& post) const {
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 
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  }
108 
109  std::unique_ptr<Worker>
111  maker::ModuleHolder const* mod) const {
112 
113  return makeWorker(actions,mod->moduleDescription(),mod);
114  }
115 
116 } // end of edm::
T getParameter(std::string const &) const
boost::shared_ptr< ProcessConfiguration const > processConfiguration_
ProductRegistry * reg_
void throwConfigurationException(ModuleDescription const &md, cms::Exception &iException) const
Definition: WorkerMaker.cc:43
ParameterSetID id() const
std::string const & moduleName() const
virtual const std::string & baseType() const =0
actions
Definition: Schedule.cc:369
std::string const & moduleLabel() const
static unsigned int getUniqueID()
Returns a unique id each time called. Intended to be passed to ModuleDescription&#39;s constructor&#39;s modI...
virtual ModuleDescription const & moduleDescription() const =0
std::unique_ptr< Worker > makeWorker(ExceptionToActionTable const *, maker::ModuleHolder const *) const
Definition: WorkerMaker.cc:110
std::string moduleName(Provenance const &provenance)
Definition: Provenance.cc:27
virtual void fillDescriptions(ConfigurationDescriptions &iDesc) const =0
void validateEDMType(std::string const &edmType, MakeModuleParams const &p) const
Definition: WorkerMaker.cc:52
tuple conf
Definition: dbtoconf.py:185
virtual ~Maker()
Definition: WorkerMaker.cc:14
void addContext(std::string const &context)
Definition: Exception.cc:227
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 validate(ParameterSet &pset, std::string const &moduleLabel) const
PreallocationConfiguration const * preallocate_
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
ParameterSet const & registerIt()
void throwValidationException(MakeModuleParams const &p, cms::Exception &iException) const
Definition: WorkerMaker.cc:29