00001 00002 #include "FWCore/Framework/src/InputSourceFactory.h" 00003 #include "FWCore/ParameterSet/interface/ParameterSet.h" 00004 #include "FWCore/Utilities/interface/DebugMacros.h" 00005 #include "FWCore/Utilities/interface/EDMException.h" 00006 00007 #include <iostream> 00008 00009 EDM_REGISTER_PLUGINFACTORY(edm::InputSourcePluginFactory,"CMS EDM Framework InputSource"); 00010 namespace edm { 00011 00012 00013 InputSourceFactory::~InputSourceFactory() 00014 { 00015 } 00016 00017 InputSourceFactory::InputSourceFactory() 00018 { 00019 } 00020 00021 InputSourceFactory InputSourceFactory::singleInstance_; 00022 00023 InputSourceFactory* InputSourceFactory::get() 00024 { 00025 // will not work with plugin factories 00026 //static InputSourceFactory f; 00027 //return &f; 00028 00029 return &singleInstance_; 00030 } 00031 00032 std::auto_ptr<InputSource> 00033 InputSourceFactory::makeInputSource(ParameterSet const& conf, 00034 InputSourceDescription const& desc) const 00035 00036 { 00037 std::string modtype = conf.getParameter<std::string>("@module_type"); 00038 FDEBUG(1) << "InputSourceFactory: module_type = " << modtype << std::endl; 00039 std::auto_ptr<InputSource> wm; 00040 try { 00041 wm = std::auto_ptr<InputSource>(InputSourcePluginFactory::get()->create(modtype,conf,desc)); 00042 } 00043 catch(edm::Exception& ex) { 00044 ex << "\nError occurred while creating source " << modtype << "\n"; 00045 throw; 00046 } 00047 catch(cms::Exception& e) { 00048 e << "\nError occurred while creating source " << modtype << "\n"; 00049 throw; 00050 } 00051 00052 if(wm.get()==0) { 00053 throw edm::Exception(errors::Configuration,"NoSourceModule") 00054 << "InputSource Factory:\n" 00055 << "Cannot find source type from ParameterSet: " 00056 << modtype << "\n" 00057 << "Perhaps your source type is misspelled or is not an EDM Plugin?\n" 00058 << "Try running EdmPluginDump to obtain a list of available Plugins."; 00059 } 00060 00061 wm->registerProducts(); 00062 00063 FDEBUG(1) << "InputSourceFactory: created input source " 00064 << modtype 00065 << std::endl; 00066 00067 return wm; 00068 } 00069 00070 }