Public Types | Public Member Functions | Private Attributes | List of all members
art::RPManager Class Reference

#include <RPManager.h>

Public Types

template<typename RET , typename... ARGS>
using invoke_function_t = RET(ResultsProducer::*)(ARGS...)
 
using on_rpworker_t = std::function< void(RPWorker &)>
 

Public Member Functions

 RPManager (fhicl::ParameterSet const &ps)
 
template<typename... ARGS>
void invoke (invoke_function_t< void, ARGS... > mfunc, ARGS &&...args)
 
void for_each_RPWorker (on_rpworker_t wfunc)
 

Private Attributes

std::map< std::string, std::vector< std::unique_ptr< RPWorker > > > rpmap_
 

Detailed Description

Definition at line 19 of file RPManager.h.

Member Typedef Documentation

template<typename RET , typename... ARGS>
using art::RPManager::invoke_function_t = RET (ResultsProducer::*)(ARGS...)

Definition at line 23 of file RPManager.h.

Definition at line 25 of file RPManager.h.

Constructor & Destructor Documentation

art::RPManager::RPManager ( fhicl::ParameterSet const &  ps)

Definition at line 21 of file RPManager.cc.

21  : rpmap_{}
22  {
23  string const omLabel(ps.get<string>("module_label"));
24  auto results = ps.get<ParameterSet>("results", {});
25  auto producers = results.get<ParameterSet>("producers", {});
26  auto results_keys = results.get_names();
27  auto producer_keys = producers.get_names();
28  map<string, vector<string>> paths;
29  string errMsg;
30  if (producer_keys.empty() && !results.is_empty()) {
32  << "Parameter set " << omLabel
33  << ".results is non-empty, but does not contain\n"
34  << "a non-empty producers parameter set.\n";
35  }
36  auto const path_keys_end =
37  remove(results_keys.begin(), results_keys.end(), "producers");
38  auto const& all_labels = producers.get_names();
39  set<string> all_labels_set(all_labels.cbegin(), all_labels.cend());
40  map<string, string> used_labels;
41  for (auto path_key = results_keys.begin(); path_key != path_keys_end;
42  ++path_key) {
43  if (!results.is_key_to_sequence(*path_key)) {
44  errMsg += "Parameter " + omLabel + ".results." + *path_key +
45  " does not describe a sequence (i.e. a path).\n";
46  continue;
47  }
48  auto path = results.get<vector<string>>(*path_key);
49  int idx = 0;
50  for (auto const& l : path) {
51  if (all_labels_set.find(l) == all_labels_set.end()) {
52  // Bad label
53  errMsg += omLabel + ".results."s + *path_key + '[' +
54  std::to_string(idx) + "] ("s + l + ')' +
55  " is not defined in "s + omLabel + ".results.producers.\n"s;
56  ++idx;
57  continue;
58  }
59  auto const ans = used_labels.emplace(l, *path_key);
60  if (!ans.second) {
61  // Duplicate
62  errMsg += omLabel + ".results." + *path_key + '[' +
63  std::to_string(idx) + "] (" + l + ')' +
64  " is a duplicate: previously used in path " +
65  ans.first->second + ".\n";
66  }
67  ++idx;
68  }
69  if (errMsg.empty()) {
70  paths.emplace(*path_key, move(path));
71  }
72  }
73  if (paths.empty() && (errMsg.empty())) {
74  paths.emplace("default_path", all_labels);
75  }
76  if (!errMsg.empty()) {
78  << "Errors encountered while configuring ResultsProducers:\n"
79  << errMsg;
80  }
82  for (auto const& path : paths) {
83  auto ins_res = rpmap_.emplace(path.first, vector<unique_ptr<RPWorker>>{});
84  transform(path.second.cbegin(),
85  path.second.cend(),
86  back_inserter(ins_res.first->second),
87  [&pf, &producers, &omLabel, &errMsg](string const& pkey) {
88  unique_ptr<RPWorker> result;
89  auto const& pconfig = producers.get<ParameterSet>(pkey);
90  auto libspec = pconfig.get<string>("plugin_type");
91  auto const& ptype = pf.pluginType(libspec);
93  result = pf.makePlugin<unique_ptr<RPWorker>,
94  RPParams const&,
95  ParameterSet const&>(
96  libspec, {pconfig.id(), libspec, pkey}, pconfig);
97  } else {
98  errMsg +=
99  "Parameter set " + omLabel + ".results." + pkey +
100  " specifies a plugin " + libspec +
101  "\n which is not of required type ResultsProducer.\n";
102  }
103  return result;
104  });
105  }
106  if (!errMsg.empty()) {
108  << "Errors encountered while instantiating ResultsProducers:\n"
109  << errMsg;
110  }
111  }
std::map< std::string, std::vector< std::unique_ptr< RPWorker > > > rpmap_
Definition: RPManager.h:38
static QCString result
type * first()
Definition: qinternallist.h:87
struct vector vector
static QStrList * l
Definition: config.cpp:1044
def move(depos, offset)
Definition: depos.py:107
T get(std::string const &key) const
Definition: ParameterSet.h:271
static constexpr double ps
Definition: Units.h:99
static std::string const & plugin()
ParameterSetID id() const
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::vector< std::string > get_names() const
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
static QCString * s
Definition: config.cpp:1042

Member Function Documentation

void art::RPManager::for_each_RPWorker ( on_rpworker_t  wfunc)

Definition at line 114 of file RPManager.cc.

115  {
116  for (auto& path : rpmap_) {
117  for (auto& w : path.second) {
118  wfunc(*w);
119  }
120  }
121  }
std::map< std::string, std::vector< std::unique_ptr< RPWorker > > > rpmap_
Definition: RPManager.h:38
template<typename... ARGS>
void art::RPManager::invoke ( invoke_function_t< void, ARGS... >  mfunc,
ARGS &&...  args 
)

Definition at line 43 of file RPManager.h.

44  {
45  for (auto& path : rpmap_) {
46  for (auto& w : path.second) {
47  (w->rp().*mfunc)(std::forward<ARGS>(args)...);
48  }
49  }
50  }
std::map< std::string, std::vector< std::unique_ptr< RPWorker > > > rpmap_
Definition: RPManager.h:38
static QCString args
Definition: declinfo.cpp:674

Member Data Documentation

std::map<std::string, std::vector<std::unique_ptr<RPWorker> > > art::RPManager::rpmap_
private

Definition at line 38 of file RPManager.h.


The documentation for this class was generated from the following files: