CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/FWCore/Framework/src/WorkerMaker.cc

Go to the documentation of this file.
00001 
00002 #include "FWCore/Framework/src/WorkerMaker.h"
00003 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
00004 #include "FWCore/Utilities/interface/EDMException.h"
00005 #include "DataFormats/Provenance/interface/ModuleDescription.h"
00006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00007 
00008 namespace edm {
00009 
00010 Maker::~Maker() {
00011 }
00012 
00013 ModuleDescription 
00014 Maker::createModuleDescription(WorkerParams const &p) const {
00015   ParameterSet const& conf = *p.pset_;
00016   ModuleDescription md(conf.id(),
00017                        conf.getParameter<std::string>("@module_type"),
00018                        conf.getParameter<std::string>("@module_label"),
00019                        p.processConfiguration_);
00020   return md;
00021 }
00022 
00023 void 
00024 Maker::throwValidationException(WorkerParams const& p,
00025                                 cms::Exception const& iException) const {
00026   ParameterSet const& conf = *p.pset_;
00027   std::string moduleName = conf.getParameter<std::string>("@module_type");
00028   std::string moduleLabel = conf.getParameter<std::string>("@module_label");
00029 
00030   Exception toThrow(errors::Configuration,
00031                          "Error occurred while validating and registering configuration\n");
00032   toThrow << "for module of type \'" << moduleName << "\' with label \'" << moduleLabel << "\'\n";
00033   toThrow.append(iException);
00034   throw toThrow;
00035 }
00036 
00037 void 
00038 Maker::throwConfigurationException(ModuleDescription const& md, 
00039                                    sigc::signal<void, ModuleDescription const&>& post, 
00040                                    cms::Exception const& iException) const {
00041   Exception toThrow(errors::Configuration,"Error occurred while creating ");
00042   toThrow << "for module of type \'"<<md.moduleName() << "\' with label \'" << md.moduleLabel() << "'\n";
00043   toThrow.append(iException);
00044   post(md);
00045   throw toThrow;
00046 }
00047 
00048 void 
00049 Maker::validateEDMType(std::string const& edmType, WorkerParams const& p) const {
00050   std::string expected = p.pset_->getParameter<std::string>("@module_edm_type");
00051   if(edmType != expected) {
00052     Exception toThrow(errors::Configuration,"Error occurred while creating module.\n");
00053     toThrow <<"Module of type \'"<<  p.pset_->getParameter<std::string>("@module_type") <<  "' with label '" << p.pset_->getParameter<std::string>("@module_label")
00054       << "' is of type " << edmType << ", but declared in the configuration as " << expected << ".\n"
00055       << "Please replace " << expected << " with " << edmType << " in the appropriate configuration file(s).\n";
00056     throw toThrow;
00057   }
00058 }
00059   
00060 std::auto_ptr<Worker> 
00061 Maker::makeWorker(WorkerParams const& p,
00062                   sigc::signal<void, ModuleDescription const&>& pre,
00063                   sigc::signal<void, ModuleDescription const&>& post) const {
00064   try {
00065     ConfigurationDescriptions descriptions(baseType());
00066     fillDescriptions(descriptions);
00067     descriptions.validate(*p.pset_, p.pset_->getParameter<std::string>("@module_label"));    
00068     p.pset_->registerIt();
00069   }
00070   catch (cms::Exception& iException) {
00071     throwValidationException(p, iException);
00072   }
00073   
00074   ModuleDescription md = createModuleDescription(p);
00075   
00076   std::auto_ptr<Worker> worker;
00077   validateEDMType(baseType(), p);
00078   try {
00079     pre(md);    
00080     worker = makeWorker(p,md);
00081 
00082     post(md);
00083   } catch( cms::Exception& iException){
00084     throwConfigurationException(md, post, iException);
00085   }
00086   return worker;
00087 }
00088   
00089 void 
00090 Maker::swapModule(Worker* w, ParameterSet const& p) {
00091    implSwapModule(w,p);
00092 }
00093 
00094 } // end of edm::