LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
Actions.cc
Go to the documentation of this file.
2 
5 #include "cetlib/container_algorithms.h"
7 #include <iostream>
8 #include <vector>
9 
10 using namespace cet;
11 using namespace std;
13 
14 namespace art {
15  namespace actions {
16  namespace {
17  struct ActionNames {
18  ActionNames() : table_(LastCode + 1)
19  {
20  table_[IgnoreCompletely] = "IgnoreCompletely";
21  table_[Rethrow] = "Rethrow";
22  table_[SkipEvent] = "SkipEvent";
23  table_[FailModule] = "FailModule";
24  table_[FailPath] = "FailPath";
25  }
26 
27  using Table = vector<char const*>;
28  Table table_;
29  };
30  }
31 
32  char const*
33  actionName(ActionCodes const code)
34  {
35  static ActionNames tab;
36  return static_cast<unsigned int>(code) < tab.table_.size() ?
37  tab.table_[code] :
38  "UnknownAction";
39  }
40  }
41 
42  ActionTable::ActionTable() : map_() { addDefaults_(); }
43 
44  ActionTable::ActionTable(ParameterSet const& scheduleOpts) : map_()
45  {
46  if (scheduleOpts.get<bool>("defaultExceptions", true)) {
47  addDefaults_();
48  }
49  install_(actions::SkipEvent, scheduleOpts);
50  install_(actions::Rethrow, scheduleOpts);
51  install_(actions::IgnoreCompletely, scheduleOpts);
52  install_(actions::FailModule, scheduleOpts);
53  install_(actions::FailPath, scheduleOpts);
54  }
55 
56  void
58  {
59  // This is where defaults that are not 'Rethrow' would be populated.
60  if (2 > debugit())
61  return;
62 
63  for (auto const& pr : map_) {
64  cerr << pr.first << ',' << pr.second << '\n';
65  }
66  cerr << endl;
67  }
68 
69  void
71  ParameterSet const& scheduler)
72  {
73  auto const& action_names =
74  scheduler.get<vector<string>>(actionName(code), {});
75  for_all(action_names, [this, code](auto const& action_name) {
76  this->add(action_name, code);
77  });
78  }
79 
80  void
81  ActionTable::add(string const& category, actions::ActionCodes const code)
82  {
83  map_[category] = code;
84  }
85 
87  ActionTable::find(string const& category) const
88  {
89  auto it = map_.find(category);
90  return it != end(map_) ? it->second : actions::Rethrow;
91  }
92 
93 } // art
actions::ActionCodes find(std::string const &category) const
Definition: Actions.cc:87
STL namespace.
void add(std::string const &category, actions::ActionCodes code)
Definition: Actions.cc:81
void addDefaults_()
Definition: Actions.cc:57
debugvalue debugit
Definition: DebugMacros.cc:12
T get(std::string const &key) const
Definition: ParameterSet.h:231
void install_(actions::ActionCodes code, fhicl::ParameterSet const &scheduler)
Definition: Actions.cc:70
char const * actionName(ActionCodes const code)
Definition: Actions.cc:33
ActionMap map_
Definition: Actions.h:34
HLT enums.
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
Table table_
Definition: Actions.cc:28