LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
RPManager.h
Go to the documentation of this file.
1 #ifndef art_Framework_Core_RPManager_h
2 #define art_Framework_Core_RPManager_h
3 // vim: set sw=2 expandtab :
4 
7 #include "cetlib/BasicPluginFactory.h"
9 
10 #include <functional>
11 #include <map>
12 #include <memory>
13 #include <string>
14 #include <utility>
15 #include <vector>
16 
17 namespace art {
18 
19  class RPManager {
20  public:
21  template <typename RET, typename... ARGS>
22  using invoke_function_t = RET (ResultsProducer::*)(ARGS...);
23 
24  using on_rpworker_t = std::function<void(RPWorker&)>;
25 
26  RPManager(fhicl::ParameterSet const& ps);
27 
28  template <typename... ARGS>
29  void invoke(invoke_function_t<void, ARGS...> mfunc, ARGS&&... args);
30 
31  void for_each_RPWorker(on_rpworker_t wfunc);
32 
33  private:
34  // Maps path name to RPWorkers on that path.
35  std::map<std::string, std::vector<std::unique_ptr<RPWorker>>> rpmap_;
36  };
37 
38  template <typename... ARGS>
39  void
41  {
42  for (auto& path : rpmap_) {
43  for (auto& w : path.second) {
44  (w->rp().*mfunc)(std::forward<ARGS>(args)...);
45  }
46  }
47  }
48 
49 } // namespace art
50 
51 #endif /* art_Framework_Core_RPManager_h */
52 
53 // Local Variables:
54 // mode: c++
55 // End:
std::map< std::string, std::vector< std::unique_ptr< RPWorker > > > rpmap_
Definition: RPManager.h:35
std::function< void(RPWorker &)> on_rpworker_t
Definition: RPManager.h:24
void for_each_RPWorker(on_rpworker_t wfunc)
Definition: RPManager.cc:114
RPManager(fhicl::ParameterSet const &ps)
Definition: RPManager.cc:21
void invoke(invoke_function_t< void, ARGS... > mfunc, ARGS &&...args)
Definition: RPManager.h:40
Definition: MVAAlg.h:12
Float_t w
Definition: plot.C:20
RET(ResultsProducer::*)(ARGS...) invoke_function_t
Definition: RPManager.h:22