Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-01-11 16:27:15

0001 
0002 #include "FWCore/Framework/src/Factory.h"
0003 #include "FWCore/Framework/interface/maker/MakerPluginFactory.h"
0004 #include "FWCore/Framework/interface/ModuleTypeResolverMaker.h"
0005 #include "FWCore/Framework/interface/resolveMaker.h"
0006 #include "FWCore/Utilities/interface/DebugMacros.h"
0007 #include "FWCore/Utilities/interface/EDMException.h"
0008 #include "FWCore/Utilities/interface/Algorithms.h"
0009 
0010 #include <iostream>
0011 
0012 EDM_REGISTER_PLUGINFACTORY(edm::MakerPluginFactory, "CMS EDM Framework Module");
0013 namespace edm {
0014 
0015   Factory const Factory::singleInstance_;
0016 
0017   Factory::~Factory() = default;
0018 
0019   Factory::Factory() = default;
0020 
0021   Factory const* Factory::get() { return &singleInstance_; }
0022 
0023   Maker const* Factory::findMaker(const MakeModuleParams& p, ModuleTypeResolverMaker const* resolverMaker) const {
0024     std::string modtype = p.pset_->getParameter<std::string>("@module_type");
0025     FDEBUG(1) << "Factory: module_type = " << modtype << std::endl;
0026     MakerMap::iterator it = makers_.find(modtype);
0027     if (it != makers_.end()) {
0028       return it->second.get();
0029     }
0030     return detail::resolveMaker<MakerPluginFactory>(modtype, resolverMaker, *p.pset_, makers_);
0031   }
0032 
0033   std::shared_ptr<maker::ModuleHolder> Factory::makeModule(
0034       const MakeModuleParams& p,
0035       const ModuleTypeResolverMaker* resolverMaker,
0036       signalslot::Signal<void(const ModuleDescription&)>& pre,
0037       signalslot::Signal<void(const ModuleDescription&)>& post) const {
0038     auto maker = findMaker(p, resolverMaker);
0039     auto mod(maker->makeModule(p, pre, post));
0040     return mod;
0041   }
0042 
0043   std::shared_ptr<maker::ModuleHolder> Factory::makeReplacementModule(const edm::ParameterSet& p) const {
0044     std::string modtype = p.getParameter<std::string>("@module_type");
0045     MakerMap::iterator it = makers_.find(modtype);
0046     if (it != makers_.end()) {
0047       return it->second->makeReplacementModule(p);
0048     }
0049     return std::shared_ptr<maker::ModuleHolder>{};
0050   }
0051 }  // namespace edm