test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ExceptionActions.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 exception_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(exception_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 
64  addDefaults();
65 
66  install(exception_actions::SkipEvent, map_, pset);
67  install(exception_actions::Rethrow, map_, pset);
69  install(exception_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 : exception_actions::Rethrow;
96  }
97 
98 }
Map map_
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
int ib
Definition: cuy.py:660
debugvalue debugit
Definition: DebugMacros.cc:13
exception_actions::ActionCodes find(const std::string &category) const
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:16
void add(const std::string &category, exception_actions::ActionCodes code)
const char * actionName(ActionCodes code)
Table table_
std::map< std::string, exception_actions::ActionCodes > ActionMap
std::vector< std::string > vstring
Definition: Schedule.cc:358