Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef FWCore_Framework_ModuleRegistry_h
0002 #define FWCore_Framework_ModuleRegistry_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     FWCore/Framework
0006 // Class  :     ModuleRegistry
0007 //
0008 /**\class edm::ModuleRegistry ModuleRegistry.h "FWCore/Framework/interface/ModuleRegistry.h"
0009 
0010  Description: Constructs and owns framework modules
0011 
0012  Usage:
0013     <usage>
0014 
0015 */
0016 //
0017 // Original Author:  Chris Jones
0018 //         Created:  Fri, 23 Aug 2013 16:21:10 GMT
0019 //
0020 
0021 // system include files
0022 #include <map>
0023 #include <memory>
0024 #include <string>
0025 
0026 // user include files
0027 #include "FWCore/ServiceRegistry/interface/ActivityRegistry.h"
0028 #include "FWCore/Utilities/interface/propagate_const.h"
0029 #include "FWCore/Framework/interface/ModuleTypeResolverMaker.h"
0030 
0031 // forward declarations
0032 namespace edm {
0033   class ParameterSet;
0034   struct MakeModuleParams;
0035   class ModuleDescription;
0036   class PreallocationConfiguration;
0037   namespace maker {
0038     class ModuleHolder;
0039   }
0040 
0041   class ModuleRegistry {
0042   public:
0043     ModuleRegistry() = default;
0044     explicit ModuleRegistry(ModuleTypeResolverMaker const* resolverMaker) : typeResolverMaker_(resolverMaker) {}
0045     std::shared_ptr<maker::ModuleHolder> getModule(MakeModuleParams const& p,
0046                                                    std::string const& moduleLabel,
0047                                                    signalslot::Signal<void(ModuleDescription const&)>& iPre,
0048                                                    signalslot::Signal<void(ModuleDescription const&)>& iPost);
0049 
0050     maker::ModuleHolder* replaceModule(std::string const& iModuleLabel,
0051                                        edm::ParameterSet const& iPSet,
0052                                        edm::PreallocationConfiguration const&);
0053 
0054     void deleteModule(std::string const& iModuleLabel,
0055                       signalslot::Signal<void(ModuleDescription const&)>& iPre,
0056                       signalslot::Signal<void(ModuleDescription const&)>& iPost);
0057 
0058     template <typename F>
0059     void forAllModuleHolders(F iFunc) {
0060       for (auto& labelMod : labelToModule_) {
0061         maker::ModuleHolder* t = labelMod.second.get();
0062         iFunc(t);
0063       }
0064     }
0065 
0066   private:
0067     std::map<std::string, edm::propagate_const<std::shared_ptr<maker::ModuleHolder>>> labelToModule_;
0068     ModuleTypeResolverMaker const* typeResolverMaker_;
0069   };
0070 }  // namespace edm
0071 
0072 #endif