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