Actions.cc
Go to the documentation of this file.
2 // vim: set sw=2 expandtab :
3 
7 
8 using namespace cet;
9 using namespace std;
10 
11 namespace art {
12 
13  namespace actions {
14 
15  char const*
17  {
18  vector<const char*> names{
19  "IgnoreCompletely", "Rethrow", "SkipEvent", "FailModule", "FailPath"};
20  return (static_cast<size_t>(code) < names.size()) ? names[code] :
21  "UnknownAction";
22  }
23 
24  } // namespace actions
25 
26  ActionTable::~ActionTable() = default;
27 
28  ActionTable::ActionTable() { addDefaults_(); }
29 
30  ActionTable::ActionTable(Config const& c)
31  {
32  if (c.defaultExceptions()) {
33  addDefaults_();
34  }
36  install_(actions::Rethrow, c.rethrow());
37  install_(actions::SkipEvent, c.skipEvent());
38  install_(actions::FailModule, c.failModule());
39  install_(actions::FailPath, c.failPath());
40  }
41 
42  void
43  ActionTable::addDefaults_()
44  {
45  // This is where defaults that are not 'Rethrow' would be populated.
46  if (2 > debugit())
47  return;
48 
49  for (auto const& pr : map_) {
50  cerr << pr.first << ',' << pr.second << '\n';
51  }
52  cerr << endl;
53  }
54 
55  void
56  ActionTable::install_(actions::ActionCodes code,
57  vector<string> const& action_names)
58  {
59  for_all(action_names, [this, code](auto const& action_name) {
60  this->add(action_name, code);
61  });
62  }
63 
64  void
66  {
67  map_[category] = code;
68  }
69 
71  ActionTable::find(string const& category) const
72  {
73  auto I = map_.find(category);
74  return (I != map_.end()) ? I->second : actions::Rethrow;
75  }
76 
77 } // namespace art
fhicl::Sequence< std::string > ignoreCompletely
Definition: Actions.h:26
DebugValue debugit
Definition: DebugMacros.cc:14
Coord add(Coord c1, Coord c2)
Definition: restypedef.cpp:23
STL namespace.
char const * actionName(ActionCodes code)
Definition: Actions.cc:16
fhicl::Sequence< std::string > skipEvent
Definition: Actions.h:29
fhicl::Atom< bool > defaultExceptions
Definition: Actions.h:25
CodeOutputInterface * code
auto for_all(FwdCont &, Func)
fhicl::Sequence< std::string > rethrow
Definition: Actions.h:28
fhicl::Sequence< std::string > failModule
Definition: Actions.h:30
fhicl::Sequence< std::string > failPath
Definition: Actions.h:31
Namespace containing all the test actions.
static std::vector< std::string > const names
Definition: FragmentType.hh:8
QTextStream & endl(QTextStream &s)