CMS 3D CMS Logo

ELseverityLevel.h
Go to the documentation of this file.
1 #ifndef MessageLogger_ELseverityLevel_h
2 #define MessageLogger_ELseverityLevel_h
3 
4 // ----------------------------------------------------------------------
5 //
6 // ELseverityLevel.h - declare objects that encode a message's urgency
7 //
8 // Both frameworker and user will often pass one of the
9 // instantiated severity levels to logger methods.
10 //
11 // The only other methods of ELseverityLevel a frameworker
12 // might use is to check the relative level of two severities
13 // using operator< or the like.
14 //
15 // ----------------------------------------------------------------------
16 
17 #include <string>
18 #include <string_view>
19 
20 namespace edm {
21 
22  // ----------------------------------------------------------------------
23  // ELseverityLevel:
24  // ----------------------------------------------------------------------
25 
27  public:
28  // --- One ELseverityLevel is globally instantiated (see below)
29  // --- for each of the following levels:
30  //
31  enum ELsev_ {
32  ELsev_noValueAssigned = 0 // default returned by map when not found
33  ,
34  ELsev_zeroSeverity // threshold use only
35  ,
36  ELsev_success // report reaching a milestone
37  ,
38  ELsev_info // information
39  ,
40  ELsev_fwkInfo // framework
41  ,
42  ELsev_warning // warning
43  ,
44  ELsev_error // error detected
45  ,
46  ELsev_unspecified // severity was not specified
47  ,
48  ELsev_severe // future results are suspect
49  ,
50  ELsev_highestSeverity // threshold use only
51  // -----
52  ,
53  nLevels // how many levels?
54  }; // ELsev_
55 
56  // ----- Birth/death:
57  //
58  constexpr ELseverityLevel(ELsev_ lev = ELsev_unspecified) noexcept : myLevel(lev) {}
59  ELseverityLevel(std::string_view str);
60  // str may match getSymbol, getName, getInputStr,
61  // or getVarName -- see accessors
62  ~ELseverityLevel() noexcept = default;
63 
64  // ----- Comparator:
65  //
66  [[nodiscard]] constexpr int cmp(ELseverityLevel const& e) const noexcept { return myLevel - e.myLevel; }
67 
68  // ----- Accessors:
69  //
70  constexpr int getLevel() const noexcept { return myLevel; }
71  const std::string& getSymbol() const; // example: "-e"
72  const std::string& getName() const; // example: "Error"
73  const std::string& getInputStr() const; // example: "ERROR"
74  const std::string& getVarName() const; // example: "ELerror"
75 
76  // ----- Emitter:
77  //
78  friend std::ostream& operator<<(std::ostream& os, const ELseverityLevel& sev);
79 
80  private:
81  // Data per ELseverityLevel object:
82  //
83  int myLevel;
84 
85  }; // ELseverityLevel
86 
87  // ----------------------------------------------------------------------
88  // Declare the globally available severity objects,
89  // one generator function and one proxy per non-default ELsev_:
90  // ----------------------------------------------------------------------
91 
93 
95 
97 
99 
101 
103 
105 
107 
109 
110  // ----------------------------------------------------------------------
111  // Comparators:
112  // ----------------------------------------------------------------------
113 
114  constexpr inline bool operator==(ELseverityLevel const& e1, ELseverityLevel const& e2) noexcept {
115  return e1.cmp(e2) == 0;
116  }
117  constexpr inline bool operator!=(ELseverityLevel const& e1, ELseverityLevel const& e2) noexcept {
118  return e1.cmp(e2) != 0;
119  }
120  constexpr inline bool operator<(ELseverityLevel const& e1, ELseverityLevel const& e2) noexcept {
121  return e1.cmp(e2) < 0;
122  }
123  constexpr inline bool operator<=(ELseverityLevel const& e1, ELseverityLevel const& e2) noexcept {
124  return e1.cmp(e2) <= 0;
125  }
126  constexpr inline bool operator>(ELseverityLevel const& e1, ELseverityLevel const& e2) noexcept {
127  return e1.cmp(e2) > 0;
128  }
129  constexpr inline bool operator>=(ELseverityLevel const& e1, ELseverityLevel const& e2) noexcept {
130  return e1.cmp(e2) >= 0;
131  }
132 
133  // ----------------------------------------------------------------------
134 
135 } // end of namespace edm
136 
137 #endif // MessageLogger_ELseverityLevel_h
edm::ELseverityLevel::ELsev_highestSeverity
Definition: ELseverityLevel.h:50
edm::ELseverityLevel::ELsev_zeroSeverity
Definition: ELseverityLevel.h:34
edm::ELseverityLevel::operator<<
friend std::ostream & operator<<(std::ostream &os, const ELseverityLevel &sev)
Definition: ELseverityLevel.cc:170
edm::ELhighestSeverity
constexpr const ELseverityLevel ELhighestSeverity
Definition: ELseverityLevel.h:108
edm::ELinfo
constexpr const ELseverityLevel ELinfo
Definition: ELseverityLevel.h:96
edm::ELseverityLevel::ELsev_
ELsev_
Definition: ELseverityLevel.h:31
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ELwarning
constexpr const ELseverityLevel ELwarning
Definition: ELseverityLevel.h:100
edm::ELunspecified
constexpr const ELseverityLevel ELunspecified
Definition: ELseverityLevel.h:104
edm::ELseverityLevel::getSymbol
const std::string & getSymbol() const
Definition: ELseverityLevel.cc:86
edm::ELseverityLevel::ELsev_fwkInfo
Definition: ELseverityLevel.h:40
edm::ELseverityLevel::ELsev_severe
Definition: ELseverityLevel.h:48
watchdog.const
const
Definition: watchdog.py:83
edm::operator!=
bool operator!=(debugging_allocator< X > const &, debugging_allocator< Y > const &) noexcept
Definition: debugging_allocator.h:75
edm::operator==
bool operator==(debugging_allocator< X > const &, debugging_allocator< Y > const &) noexcept
Definition: debugging_allocator.h:72
edm::ELseverityLevel::getInputStr
const std::string & getInputStr() const
Definition: ELseverityLevel.cc:126
edm::operator<
bool operator<(DetSet< T > const &x, DetSet< T > const &y)
Definition: DetSet.h:89
str
#define str(s)
Definition: TestProcessor.cc:51
edm::ELerror
constexpr const ELseverityLevel ELerror
Definition: ELseverityLevel.h:102
edm::ELseverityLevel::ELsev_error
Definition: ELseverityLevel.h:44
edm::operator<=
bool operator<=(View< T > const &, View< T > const &)
Definition: View.h:320
edm::operator>
bool operator>(View< T > const &, View< T > const &)
Definition: View.h:325
edm::ELseverityLevel::ELsev_unspecified
Definition: ELseverityLevel.h:46
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
writedatasetfile.default
default
Definition: writedatasetfile.py:11
edm::ELseverityLevel::ELsev_warning
Definition: ELseverityLevel.h:42
edm::ELsevere
constexpr const ELseverityLevel ELsevere
Definition: ELseverityLevel.h:106
StorageManager_cfg.e1
e1
Definition: StorageManager_cfg.py:16
edm::ELseverityLevel::nLevels
Definition: ELseverityLevel.h:53
edm::ELseverityLevel::ELsev_success
Definition: ELseverityLevel.h:36
edm::ELdebug
constexpr const ELseverityLevel ELdebug
Definition: ELseverityLevel.h:94
edm::ELseverityLevel
Definition: ELseverityLevel.h:26
edm::ELseverityLevel::getLevel
constexpr int getLevel() const noexcept
Definition: ELseverityLevel.h:70
edm::ELseverityLevel::ELsev_noValueAssigned
Definition: ELseverityLevel.h:32
edm::operator>=
bool operator>=(View< T > const &, View< T > const &)
Definition: View.h:330
edm::ELseverityLevel::getName
const std::string & getName() const
Definition: ELseverityLevel.cc:106
edm::ELseverityLevel::myLevel
int myLevel
Definition: ELseverityLevel.h:83
edm::ELseverityLevel::~ELseverityLevel
~ELseverityLevel() noexcept=default
edm::ELseverityLevel::cmp
constexpr int cmp(ELseverityLevel const &e) const noexcept
Definition: ELseverityLevel.h:66
edm::ELfwkInfo
constexpr const ELseverityLevel ELfwkInfo
Definition: ELseverityLevel.h:98
edm::ELzeroSeverity
constexpr const ELseverityLevel ELzeroSeverity
Definition: ELseverityLevel.h:92
edm::ELseverityLevel::ELsev_info
Definition: ELseverityLevel.h:38
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
edm::ELseverityLevel::getVarName
const std::string & getVarName() const
Definition: ELseverityLevel.cc:146
edm::ELseverityLevel::ELseverityLevel
constexpr ELseverityLevel(ELsev_ lev=ELsev_unspecified) noexcept
Definition: ELseverityLevel.h:58