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 
7 
8 namespace edm {
9 
11 }
12 
15  ParameterSet const& conf = *p.pset_;
16  ModuleDescription md(conf.id(),
17  conf.getParameter<std::string>("@module_type"),
18  conf.getParameter<std::string>("@module_label"),
20  return md;
21 }
22 
23 void
25  cms::Exception const& iException) const {
26  ParameterSet const& conf = *p.pset_;
27  std::string moduleName = conf.getParameter<std::string>("@module_type");
28  std::string moduleLabel = conf.getParameter<std::string>("@module_label");
29 
31  "Error occurred while validating and registering configuration\n");
32  toThrow << "for module of type \'" << moduleName << "\' with label \'" << moduleLabel << "\'\n";
33  toThrow.append(iException);
34  throw toThrow;
35 }
36 
37 void
39  sigc::signal<void, ModuleDescription const&>& post,
40  cms::Exception const& iException) const {
41  Exception toThrow(errors::Configuration,"Error occurred while creating ");
42  toThrow << "for module of type \'"<<md.moduleName() << "\' with label \'" << md.moduleLabel() << "'\n";
43  toThrow.append(iException);
44  post(md);
45  throw toThrow;
46 }
47 
48 void
49 Maker::validateEDMType(std::string const& edmType, WorkerParams const& p) const {
50  std::string expected = p.pset_->getParameter<std::string>("@module_edm_type");
51  if(edmType != expected) {
52  Exception toThrow(errors::Configuration,"Error occurred while creating module.\n");
53  toThrow <<"Module of type \'"<< p.pset_->getParameter<std::string>("@module_type") << "' with label '" << p.pset_->getParameter<std::string>("@module_label")
54  << "' is of type " << edmType << ", but declared in the configuration as " << expected << ".\n"
55  << "Please replace " << expected << " with " << edmType << " in the appropriate configuration file(s).\n";
56  throw toThrow;
57  }
58 }
59 
60 std::auto_ptr<Worker>
62  sigc::signal<void, ModuleDescription const&>& pre,
63  sigc::signal<void, ModuleDescription const&>& post) const {
64  try {
65  ConfigurationDescriptions descriptions(baseType());
66  fillDescriptions(descriptions);
67  descriptions.validate(*p.pset_, p.pset_->getParameter<std::string>("@module_label"));
68  p.pset_->registerIt();
69  }
70  catch (cms::Exception& iException) {
71  throwValidationException(p, iException);
72  }
73 
75 
76  std::auto_ptr<Worker> worker;
78  try {
79  pre(md);
80  worker = makeWorker(p,md);
81 
82  post(md);
83  } catch( cms::Exception& iException){
84  throwConfigurationException(md, post, iException);
85  }
86  return worker;
87 }
88 
89 void
91  implSwapModule(w,p);
92 }
93 
94 } // end of edm::
T getParameter(std::string const &) const
void append(Exception const &another)
Definition: Exception.cc:82
void throwValidationException(WorkerParams const &p, cms::Exception const &iException) const
Definition: WorkerMaker.cc:24
ParameterSetID id() const
ParameterSet * pset_
Definition: WorkerParams.h:38
std::string const & moduleName() const
std::auto_ptr< Worker > makeWorker(WorkerParams const &, sigc::signal< void, ModuleDescription const & > &iPre, sigc::signal< void, ModuleDescription const & > &iPost) const
Definition: WorkerMaker.cc:61
virtual const std::string & baseType() const =0
void swapModule(Worker *, ParameterSet const &)
Definition: WorkerMaker.cc:90
std::string const & moduleLabel() const
void validateEDMType(std::string const &edmType, WorkerParams const &p) const
Definition: WorkerMaker.cc:49
virtual void implSwapModule(Worker *, ParameterSet const &)=0
ModuleDescription createModuleDescription(WorkerParams const &p) const
Definition: WorkerMaker.cc:14
virtual void fillDescriptions(ConfigurationDescriptions &iDesc) const =0
void throwConfigurationException(ModuleDescription const &md, sigc::signal< void, ModuleDescription const & > &post, cms::Exception const &iException) const
Definition: WorkerMaker.cc:38
tuple conf
Definition: dbtoconf.py:185
virtual ~Maker()
Definition: WorkerMaker.cc:10
boost::shared_ptr< ProcessConfiguration const > processConfiguration_
Definition: WorkerParams.h:40
void validate(ParameterSet &pset, std::string const &moduleLabel) const
ParameterSet const & registerIt()
const std::string * moduleLabel() const
Definition: HLTadd.h:40