Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-04-30 22:24:06

0001 #ifndef FWCore_Framework_PathsAndConsumesOfModules_h
0002 #define FWCore_Framework_PathsAndConsumesOfModules_h
0003 
0004 /**\class edm::PathsAndConsumesOfModules
0005 
0006  Description: See comments in the base class
0007 
0008  Usage:
0009 
0010 */
0011 //
0012 // Original Author: W. David Dagenhart
0013 //         Created: 11/5/2014
0014 
0015 #include "FWCore/ServiceRegistry/interface/PathsAndConsumesOfModulesBase.h"
0016 
0017 #include "FWCore/Framework/interface/ESRecordsToProductResolverIndices.h"
0018 #include "FWCore/ServiceRegistry/interface/ServiceRegistryfwd.h"
0019 #include "FWCore/Utilities/interface/BranchType.h"
0020 #include "FWCore/Utilities/interface/Transition.h"
0021 
0022 #include <array>
0023 #include <memory>
0024 #include <string>
0025 #include <utility>
0026 #include <vector>
0027 #include <map>
0028 
0029 namespace edm {
0030 
0031   class ModuleDescription;
0032   class ProductRegistry;
0033   class Schedule;
0034 
0035   namespace eventsetup {
0036     struct ComponentDescription;
0037     class ESProductResolverProvider;
0038     class EventSetupProvider;
0039   }  // namespace eventsetup
0040 
0041   class PathsAndConsumesOfModules : public PathsAndConsumesOfModulesBase {
0042   public:
0043     PathsAndConsumesOfModules() = default;
0044     ~PathsAndConsumesOfModules() override = default;
0045 
0046     void initialize(Schedule const*, std::shared_ptr<ProductRegistry const>);
0047     void initializeForEventSetup(eventsetup::EventSetupProvider const&);
0048     void checkEventSetupInitialization() const;
0049 
0050     void removeModules(std::vector<ModuleDescription const*> const& modules);
0051 
0052     struct ESProductInfo {
0053       eventsetup::ComponentDescription const* componentDescription_ = nullptr;
0054       unsigned int produceMethodID_ = std::numeric_limits<unsigned int>::max();
0055     };
0056     using ProducedByESModule =
0057         std::map<edm::eventsetup::EventSetupRecordKey, std::map<edm::eventsetup::DataKey, ESProductInfo>>;
0058 
0059   private:
0060     std::vector<std::string> const& doPaths() const override;
0061     std::vector<std::string> const& doEndPaths() const override;
0062 
0063     std::vector<ModuleDescription const*> const& doAllModules() const override;
0064     ModuleDescription const* doModuleDescription(unsigned int moduleID) const override;
0065 
0066     std::vector<ModuleDescription const*> const& doModulesOnPath(unsigned int pathIndex) const override;
0067     std::vector<ModuleDescription const*> const& doModulesOnEndPath(unsigned int endPathIndex) const override;
0068     std::vector<ModuleDescription const*> const& doModulesWhoseProductsAreConsumedBy(
0069         unsigned int moduleID, BranchType branchType) const override;
0070 
0071     std::vector<eventsetup::ComponentDescription const*> const& doESModulesWhoseProductsAreConsumedBy(
0072         unsigned int moduleID, Transition) const override;
0073 
0074     std::vector<ModuleConsumesInfo> doModuleConsumesInfos(unsigned int moduleID) const override;
0075     std::vector<ModuleConsumesESInfo> doModuleConsumesESInfos(unsigned int moduleID) const override;
0076 
0077     unsigned int doLargestModuleID() const override;
0078 
0079     std::vector<eventsetup::ComponentDescription const*> const& doAllESModules() const override;
0080     eventsetup::ComponentDescription const* doComponentDescription(unsigned int esModuleID) const override;
0081 
0082     std::vector<std::vector<eventsetup::ComponentDescription const*>> const&
0083     doESModulesWhoseProductsAreConsumedByESModule() const override;
0084     std::vector<std::vector<ESModuleConsumesInfo>> doESModuleConsumesInfos(unsigned int esModuleID) const override;
0085 
0086     unsigned int moduleIndex(unsigned int moduleID) const;
0087     unsigned int esModuleIndex(unsigned int esModuleID) const;
0088 
0089     // data members
0090 
0091     std::vector<std::string> paths_;
0092     std::vector<std::string> endPaths_;
0093 
0094     std::vector<ModuleDescription const*> allModuleDescriptions_;
0095 
0096     std::vector<std::vector<ModuleDescription const*>> modulesOnPaths_;
0097     std::vector<std::vector<ModuleDescription const*>> modulesOnEndPaths_;
0098 
0099     // Gives a translation from the module ID to the index into the
0100     // following data member
0101     std::vector<std::pair<unsigned int, unsigned int>> moduleIDToIndex_;
0102 
0103     std::array<std::vector<std::vector<ModuleDescription const*>>, NumBranchTypes> modulesWhoseProductsAreConsumedBy_;
0104 
0105     std::array<std::vector<std::vector<eventsetup::ComponentDescription const*>>, kNumberOfEventSetupTransitions>
0106         esModulesWhoseProductsAreConsumedBy_;
0107 
0108     // Gives a translation from the componentID to the index into allComponentDescriptions_,
0109     // allESProductResolverProviders_, and the outer vector of esModulesWhoseProductsAreConsumedByESModule_
0110     std::vector<std::pair<unsigned int, unsigned int>> esModuleIDToIndex_;
0111 
0112     std::vector<eventsetup::ComponentDescription const*> allComponentDescriptions_;
0113     std::vector<eventsetup::ESProductResolverProvider const*> allESProductResolverProviders_;
0114     std::vector<std::vector<eventsetup::ComponentDescription const*>> esModulesWhoseProductsAreConsumedByESModule_;
0115 
0116     Schedule const* schedule_ = nullptr;
0117     ProducedByESModule producedByESModule_;
0118     std::shared_ptr<ProductRegistry const> preg_;
0119     bool eventSetupInfoInitialized_ = false;
0120   };
0121 
0122   std::vector<ModuleDescription const*> nonConsumedUnscheduledModules(edm::PathsAndConsumesOfModulesBase const& iPnC);
0123 
0124   void checkForModuleDependencyCorrectness(edm::PathsAndConsumesOfModulesBase const& iPnC, bool iPrintDependencies);
0125 }  // namespace edm
0126 #endif