LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
PathManager.h
Go to the documentation of this file.
1 #ifndef art_Framework_Core_PathManager_h
2 #define art_Framework_Core_PathManager_h
3 // vim: set sw=2 expandtab :
4 
5 // ======================================================================
6 // PathManager.
7 //
8 // Class to handle the processing of the configuration of modules in
9 // art, including the creation of paths and construction of modules as
10 // appropriate.
11 //
12 // Intended to be constructed early, prior to services, since
13 // TriggerNamesService will need some of the information herein at
14 // construction time.
15 // ======================================================================
16 
29 #include "cetlib/LibraryManager.h"
30 #include "fhiclcpp/ParameterSet.h"
31 
32 #include <map>
33 #include <memory>
34 #include <set>
35 #include <string>
36 #include <variant>
37 #include <vector>
38 
39 namespace art {
40 
41  class ActionTable;
42  class ActivityRegistry;
43  class GlobalTaskGroup;
44  class UpdateOutputCallbacks;
45 
46  namespace detail {
47  class SharedResources;
48  }
49 
50  class PathManager {
51  public:
52  PathManager(fhicl::ParameterSet const& procPS,
54  ProductDescriptions& productsToProduce,
55  ActionTable const& exceptActions,
56  ActivityRegistry const& areg,
57  detail::EnabledModules enabled_modules);
58 
59  PathManager(PathManager const&) = delete;
60  PathManager(PathManager&&) = delete;
61  PathManager& operator=(PathManager const&) = delete;
62  PathManager& operator=(PathManager&&) = delete;
63 
64  std::vector<PathSpec> triggerPathSpecs() const;
65 
66  void createModulesAndWorkers(
67  GlobalTaskGroup& task_group,
68  detail::SharedResources& resources,
69  std::vector<std::string> const& producing_services);
70  std::unique_ptr<Worker> releaseTriggerResultsInserter(ScheduleID);
71  PathsInfo& triggerPathsInfo(ScheduleID);
72  PerScheduleContainer<PathsInfo> const& triggerPathsInfo();
73  PathsInfo& endPathInfo(ScheduleID);
74  PerScheduleContainer<PathsInfo> const& endPathInfo();
75 
76  private:
78  std::map<module_label_t, std::unique_ptr<ModuleBase>> shared{};
79  std::map<module_label_t,
82  };
83 
84  std::map<std::string, detail::ModuleConfigInfo> moduleInformation_(
85  detail::EnabledModules const& enabled_modules) const;
86 
88  std::unique_ptr<ReplicatedProducer> makeTriggerResultsInserter_(
89  ScheduleID scheduleID);
90 
91  using maybe_module_t = std::variant<ModuleBase*, std::string>;
92  maybe_module_t makeModule_(fhicl::ParameterSet const& module_pset,
93  ModuleDescription const& md,
94  ScheduleID) const;
95  std::vector<WorkerInPath> fillWorkers_(
96  PathContext const& pc,
97  std::vector<WorkerInPath::ConfigInfo> const& wci_list,
98  std::map<std::string, std::shared_ptr<Worker>>& workers,
99  GlobalTaskGroup& task_group,
100  detail::SharedResources& resources);
101  std::shared_ptr<Worker> makeWorker_(ModuleDescription const& md,
102  WorkerParams const& wp);
103  ModuleType loadModuleType_(std::string const& lib_spec) const;
104  ModuleThreadingType loadModuleThreadingType_(
105  std::string const& lib_spec) const;
106 
107  // Module-graph implementation
108  detail::collection_map_t getModuleGraphInfoCollection_(
109  std::vector<std::string> const& producing_services);
110  void fillModuleOnlyDeps_(
111  std::string const& path_name,
112  detail::configs_t const& worker_configs,
113  std::map<std::string, std::set<ProductInfo>> const& produced_products,
114  std::map<std::string, std::set<std::string>> const& viewable_products,
115  detail::collection_map_t& info_collection) const;
116  void fillSelectEventsDeps_(detail::configs_t const& worker_configs,
117  detail::collection_map_t& info_collection) const;
118 
119  std::vector<std::string> triggerPathNames_() const;
120  std::vector<std::string> prependedTriggerPathNames_() const;
121 
122  // Member Data
131 
132  cet::LibraryManager lm_{Suffixes::module()};
133  // The following data members are only needed to delay the
134  // creation of modules until after the service system has
135  // started. We can move them back to the ctor once that is
136  // fixed.
137  std::string processName_{};
138  std::map<std::string, detail::ModuleConfigInfo> allModules_{};
139  art::detail::paths_to_modules_t protoTrigPathLabels_{};
140  art::detail::configs_t protoEndPathLabels_{};
143  };
144 } // namespace art
145 
146 #endif /* art_Framework_Core_PathManager_h */
147 
148 // Local Variables:
149 // mode: c++
150 // End:
ProductDescriptions & productsToProduce_
Definition: PathManager.h:130
std::map< module_name_t, ModuleGraphInfo > collection_map_t
PerScheduleContainer< std::unique_ptr< Worker > > triggerResultsWorkers_
Definition: PathManager.h:142
std::vector< BranchDescription > ProductDescriptions
std::string module_label_t
Definition: WorkerInPath.h:26
PerScheduleContainer< PathsInfo > triggerPathsInfo_
Definition: PathManager.h:128
std::vector< WorkerInPath::ConfigInfo > configs_t
std::variant< ModuleBase *, std::string > maybe_module_t
Definition: PathManager.h:91
PerScheduleContainer< PathsInfo > endPathInfo_
Definition: PathManager.h:129
std::vector< std::pair< PathSpec, configs_t >> paths_to_modules_t
UpdateOutputCallbacks & outputCallbacks_
Definition: PathManager.h:123
ActionTable const & exceptActions_
Definition: PathManager.h:124
id_type size_type
Definition: ScheduleID.h:25
ModuleThreadingType
Definition: ModuleType.h:19
art::detail::module_entries_for_ordered_path_t triggerPathSpecs_
Definition: PathManager.h:127
Definition: MVAAlg.h:12
Char_t n[5]
static std::string const & module()
ActivityRegistry const & actReg_
Definition: PathManager.h:125
fhicl::ParameterSet procPS_
Definition: PathManager.h:126
std::vector< std::pair< PathSpec, std::vector< ModuleSpec >>> module_entries_for_ordered_path_t
ModuleType
Definition: ModuleType.h:11