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 
28 #include "cetlib/LibraryManager.h"
29 #include "fhiclcpp/ParameterSet.h"
30 
31 #include <map>
32 #include <memory>
33 #include <set>
34 #include <string>
35 #include <variant>
36 #include <vector>
37 
38 namespace art {
39 
40  class ActionTable;
41  class ActivityRegistry;
42  class GlobalTaskGroup;
43  class ModuleBase;
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 const& 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  PathsInfo& triggerPathsInfo(ScheduleID);
71  PerScheduleContainer<PathsInfo>& triggerPathsInfo();
72  PathsInfo& endPathInfo(ScheduleID);
73  PerScheduleContainer<PathsInfo>& endPathInfo();
74 
75  private:
77  std::map<module_label_t, std::shared_ptr<ModuleBase>> shared{};
78  std::map<module_label_t,
81  };
82 
83  std::map<std::string, detail::ModuleConfigInfo> moduleInformation_(
84  detail::EnabledModules const& enabled_modules) const;
85 
87  using maybe_module_t = std::variant<ModuleBase*, std::string>;
88  maybe_module_t makeModule_(fhicl::ParameterSet const& module_pset,
89  ModuleDescription const& md,
90  ScheduleID) const;
91  std::vector<WorkerInPath> fillWorkers_(
92  PathContext const& pc,
93  std::vector<WorkerInPath::ConfigInfo> const& wci_list,
94  ModulesByThreadingType const& modules,
95  std::map<std::string, std::shared_ptr<Worker>>& workers,
96  GlobalTaskGroup& task_group,
97  detail::SharedResources& resources);
98  std::shared_ptr<Worker> makeWorker_(ModulesByThreadingType const& modules,
99  ModuleDescription const& md,
100  WorkerParams const& wp);
101  ModuleType loadModuleType_(std::string const& lib_spec) const;
102  ModuleThreadingType loadModuleThreadingType_(
103  std::string const& lib_spec) const;
104 
105  // Module-graph implementation
106  detail::collection_map_t getModuleGraphInfoCollection_(
107  std::vector<std::string> const& producing_services);
108  void fillModuleOnlyDeps_(
109  std::string const& path_name,
110  detail::configs_t const& worker_configs,
111  std::map<std::string, std::set<ProductInfo>> const& produced_products,
112  std::map<std::string, std::set<std::string>> const& viewable_products,
113  detail::collection_map_t& info_collection) const;
114  void fillSelectEventsDeps_(detail::configs_t const& worker_configs,
115  detail::collection_map_t& info_collection) const;
116 
117  std::vector<std::string> triggerPathNames_() const;
118  std::vector<std::string> prependedTriggerPathNames_() const;
119 
120  // Member Data
129 
131  // The following data members are only needed to delay the
132  // creation of modules until after the service system has
133  // started. We can move them back to the ctor once that is
134  // fixed.
135  std::string processName_{};
136  std::map<std::string, detail::ModuleConfigInfo> allModules_{};
137  art::detail::paths_to_modules_t protoTrigPathLabels_{};
138  art::detail::configs_t protoEndPathLabels_{};
139  };
140 } // namespace art
141 
142 #endif /* art_Framework_Core_PathManager_h */
143 
144 // Local Variables:
145 // mode: c++
146 // End:
ProductDescriptions & productsToProduce_
Definition: PathManager.h:128
std::string string
Definition: nybbler.cc:12
std::map< module_name_t, ModuleGraphInfo > collection_map_t
std::vector< BranchDescription > ProductDescriptions
std::string module_label_t
Definition: WorkerInPath.h:26
PerScheduleContainer< PathsInfo > triggerPathsInfo_
Definition: PathManager.h:126
std::vector< WorkerInPath::ConfigInfo > configs_t
std::variant< ModuleBase *, std::string > maybe_module_t
Definition: PathManager.h:87
std::void_t< T > n
PerScheduleContainer< PathsInfo > endPathInfo_
Definition: PathManager.h:127
std::vector< std::pair< PathSpec, configs_t >> paths_to_modules_t
UpdateOutputCallbacks & outputCallbacks_
Definition: PathManager.h:121
ActionTable const & exceptActions_
Definition: PathManager.h:122
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:125
static std::string const & module()
ActivityRegistry const & actReg_
Definition: PathManager.h:123
workers
Definition: train.py:479
fhicl::ParameterSet procPS_
Definition: PathManager.h:124
std::vector< std::pair< PathSpec, std::vector< ModuleSpec >>> module_entries_for_ordered_path_t
ModuleType
Definition: ModuleType.h:11