CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Actions.cc
Go to the documentation of this file.
1 
5 #include "boost/lambda/lambda.hpp"
6 
7 #include <vector>
8 #include <iostream>
9 
10 namespace edm {
11  namespace actions {
12  namespace {
13  struct ActionNames {
14  ActionNames():table_(LastCode + 1) {
15  table_[IgnoreCompletely] = "IgnoreCompletely";
16  table_[Rethrow] = "Rethrow";
17  table_[SkipEvent] = "SkipEvent";
18  table_[FailPath] = "FailPath";
19  }
20 
21  typedef std::vector<char const*> Table;
22  Table table_;
23  };
24  }
25 
26  char const* actionName(ActionCodes code) {
27  static ActionNames tab;
28  return static_cast<unsigned int>(code) < tab.table_.size() ? tab.table_[code] : "UnknownAction";
29  }
30  }
31 
33  addDefaults();
34  }
35 
36  namespace {
37  inline void install(actions::ActionCodes code,
39  ParameterSet const& pset) {
40  using boost::lambda::_1;
41  using boost::lambda::var;
42  typedef std::vector<std::string> vstring;
43 
44  // we cannot have parameters in the main process section so look
45  // for an untracked (optional) ParameterSet called "options" for
46  // now. Notice that all exceptions (most actally) throw
47  // edm::Exception with the configuration category. This
48  // category should probably be more specific or a derived
49  // exception type should be used so the catch can be more
50  // specific.
51 
52 // cerr << pset.toString() << std::endl;
53 
54  ParameterSet defopts;
55  ParameterSet const& opts = pset.getUntrackedParameterSet("options", defopts);
56  //cerr << "looking for " << actionName(code) << std::endl;
57  vstring v = opts.getUntrackedParameter(actionName(code),vstring());
58  for_all(v, var(out)[_1] = code);
59 
60  }
61  }
62 
63  ActionTable::ActionTable(ParameterSet const& pset) : map_() {
64  addDefaults();
65 
66  install(actions::SkipEvent, map_, pset);
67  install(actions::Rethrow, map_, pset);
68  install(actions::IgnoreCompletely, map_, pset);
69  install(actions::FailPath, map_, pset);
70  }
71 
73  using namespace boost::lambda;
74  // populate defaults that are not 'Rethrow'
75  // (There are none as of CMSSW_3_4_X.)
76  // 'Rethrow' is the default default.
77  if(2 <= debugit()) {
78  ActionMap::const_iterator ib(map_.begin()),ie(map_.end());
79  for(;ib != ie; ++ib) {
80  std::cerr << ib->first << ',' << ib->second << '\n';
81  }
82  std::cerr << std::endl;
83  }
84  }
85 
87  }
88 
90  map_[category] = code;
91  }
92 
94  ActionMap::const_iterator i(map_.find(category));
95  return i != map_.end() ? i->second : actions::Rethrow;
96  }
97 
98 }
void add(const std::string &category, actions::ActionCodes code)
Definition: Actions.cc:89
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
const char * actionName(ActionCodes code)
Definition: Actions.cc:26
ActionMap map_
Definition: Actions.h:35
roAction_t actions[nactions]
Definition: GenABIO.cc:200
int ib
Definition: cuy.py:660
debugvalue debugit
Definition: DebugMacros.cc:13
std::vector< std::string > vstring
Definition: Schedule.cc:277
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:16
std::map< std::string, actions::ActionCodes > ActionMap
Definition: Actions.h:24
ParameterSet const & getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
tuple tab
Definition: accesses.py:4
void addDefaults()
Definition: Actions.cc:72
tuple out
Definition: dbtoconf.py:99
actions::ActionCodes find(const std::string &category) const
Definition: Actions.cc:93
Table table_
Definition: Actions.cc:22