LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
ELseverityLevel.cc
Go to the documentation of this file.
2 // vim: set sw=2 expandtab :
3 
4 #include <map>
5 #include <ostream>
6 #include <string>
7 
8 using namespace std;
9 
10 namespace {
11 
12  template <mf::ELseverityLevel(F)()>
13  void
14  setSeverity(map<string const, mf::ELseverityLevel::ELsev_>& m,
15  mf::ELslProxy<F> const proxy)
16  {
17  auto const severity =
18  static_cast<mf::ELseverityLevel::ELsev_>(proxy.getLevel());
19  m[proxy.getSymbol()] = severity;
20  m[proxy.getName()] = severity;
21  m[proxy.getInputStr()] = severity;
22  m[proxy.getVarName()] = severity;
23  }
24 
25 } // unnamed namespace
26 
27 namespace mf {
28 
29  namespace {
30 
31  map<string const, mf::ELseverityLevel::ELsev_> const&
32  loadMap()
33  {
34  static map<string const, mf::ELseverityLevel::ELsev_> m;
35  setSeverity(m, ELzeroSeverity);
36  setSeverity(m, ELsuccess);
37  setSeverity(m, ELdebug);
38  setSeverity(m, ELinfo);
39  setSeverity(m, ELwarning);
40  setSeverity(m, ELerror);
41  setSeverity(m, ELunspecified);
42  setSeverity(m, ELsevere);
43  setSeverity(m, ELhighestSeverity);
44  return m;
45  }
46 
47  } // unnamed namespace
48 
49  ELseverityLevel::ELseverityLevel(string const& s)
50  {
51  static map<string const, mf::ELseverityLevel::ELsev_> const& m = loadMap();
52  auto i = m.find(s);
53  myLevel = (i == m.end()) ? ELsev_unspecified : i->second;
54  }
55 
56  int
57  ELseverityLevel::cmp(ELseverityLevel const e) const
58  {
59  return myLevel - e.myLevel;
60  }
61 
62  int
63  ELseverityLevel::getLevel() const
64  {
65  return myLevel;
66  }
67 
68  string
69  ELseverityLevel::getSymbol() const
70  {
71  string result;
72  switch (myLevel) {
73  default:
74  result = "0";
75  break;
76  case ELsev_zeroSeverity:
77  result = "--";
78  break;
79  case ELsev_success:
80  result = "-d";
81  break;
82  case ELsev_info:
83  result = "-i";
84  break;
85  case ELsev_warning:
86  result = "-w";
87  break;
88  case ELsev_error:
89  result = "-e";
90  break;
91  case ELsev_unspecified:
92  result = "??";
93  break;
94  case ELsev_severe:
95  result = "-s";
96  break;
97  case ELsev_highestSeverity:
98  result = "!!";
99  break;
100  }
101  return result;
102  }
103 
104  string
105  ELseverityLevel::getName() const
106  {
107  string result;
108  switch (myLevel) {
109  default:
110  result = "?no value?";
111  break;
112  case ELsev_zeroSeverity:
113  result = "--";
114  break;
115  case ELsev_success:
116  result = "Debug";
117  break;
118  case ELsev_info:
119  result = "Info";
120  break;
121  case ELsev_warning:
122  result = "Warning";
123  break;
124  case ELsev_error:
125  result = "Error";
126  break;
127  case ELsev_unspecified:
128  result = "??";
129  break;
130  case ELsev_severe:
131  result = "System";
132  break;
133  case ELsev_highestSeverity:
134  result = "!!";
135  break;
136  }
137  return result;
138  }
139 
140  string
141  ELseverityLevel::getInputStr() const
142  {
143  string result;
144  switch (myLevel) {
145  default:
146  result = "?no value?";
147  break;
148  case ELsev_zeroSeverity:
149  result = "ZERO";
150  break;
151  case ELsev_success:
152  result = "DEBUG";
153  break;
154  case ELsev_info:
155  result = "INFO";
156  break;
157  case ELsev_warning:
158  result = "WARNING";
159  break;
160  case ELsev_error:
161  result = "ERROR";
162  break;
163  case ELsev_unspecified:
164  result = "UNSPECIFIED";
165  break;
166  case ELsev_severe:
167  result = "SYSTEM";
168  break;
169  case ELsev_highestSeverity:
170  result = "HIGHEST";
171  break;
172  }
173  return result;
174  }
175 
176  string
177  ELseverityLevel::getVarName() const
178  {
179  string result;
180  switch (myLevel) {
181  default:
182  result = "?no value? ";
183  break;
184  case ELsev_zeroSeverity:
185  result = "ELzeroSeverity ";
186  break;
187  case ELsev_success:
188  result = "ELdebug ";
189  break;
190  case ELsev_info:
191  result = "ELinfo ";
192  break;
193  case ELsev_warning:
194  result = "ELwarning ";
195  break;
196  case ELsev_error:
197  result = "ELerror ";
198  break;
199  case ELsev_unspecified:
200  result = "ELunspecified ";
201  break;
202  case ELsev_severe:
203  result = "ELsystem ";
204  break;
205  case ELsev_highestSeverity:
206  result = "ELhighestSeverity";
207  break;
208  }
209  return result;
210  }
211 
212  ostream&
213  operator<<(ostream& os, ELseverityLevel const sev)
214  {
215  return os << " -" << sev.getName() << "- ";
216  }
217 
218 } // namespace mf
Float_t s
Definition: plot.C:23
ELslProxy< ELinfoGen > constexpr ELinfo
std::string getSymbol() const
STL namespace.
ELslProxy< ELhighestSeverityGen > constexpr ELhighestSeverity
ELslProxy< ELerrorGen > constexpr ELerror
ELslProxy< ELzeroSeverityGen > constexpr ELzeroSeverity
ELslProxy< ELwarningGen > constexpr ELwarning
Encloses LArSoft data product proxy objects and utilities.See this doxygen module for an introduction...
std::string getVarName() const
ELslProxy< ELsuccessGen > constexpr ELsuccess
std::string getName() const
ELslProxy< ELdebugGen > constexpr ELdebug
ostream & operator<<(ostream &os, ELseverityLevel const sev)
std::string getName() const
int getLevel() const
std::string getInputStr() const
Float_t e
Definition: plot.C:34
ELslProxy< ELunspecifiedGen > constexpr ELunspecified
ELslProxy< ELsevereGen > constexpr ELsevere