File indexing completed on 2024-09-07 04:35:51
0001 #ifndef DataFormats_Common_ELseverityLevel_h
0002 #define DataFormats_Common_ELseverityLevel_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #include <string_view>
0018 #include <cassert>
0019
0020 namespace edm {
0021
0022
0023
0024
0025
0026 class ELseverityLevel {
0027 public:
0028
0029
0030
0031 enum ELsev_ {
0032 ELsev_noValueAssigned = 0,
0033 ELsev_zeroSeverity,
0034 ELsev_success,
0035 ELsev_info,
0036 ELsev_fwkInfo,
0037 ELsev_warning,
0038 ELsev_error,
0039 ELsev_unspecified,
0040 ELsev_severe,
0041 ELsev_highestSeverity,
0042
0043 nLevels
0044 };
0045
0046
0047
0048 constexpr ELseverityLevel(ELsev_ lev = ELsev_unspecified) noexcept : myLevel(lev) {}
0049 constexpr ELseverityLevel(int lev) noexcept : myLevel(lev) {
0050 assert(lev >= ELsev_noValueAssigned);
0051 assert(lev < nLevels);
0052 }
0053 ~ELseverityLevel() noexcept = default;
0054 constexpr ELseverityLevel(const ELseverityLevel&) noexcept = default;
0055 constexpr ELseverityLevel(ELseverityLevel&&) noexcept = default;
0056 constexpr ELseverityLevel& operator=(const ELseverityLevel&) noexcept = default;
0057 constexpr ELseverityLevel& operator=(ELseverityLevel&&) noexcept = default;
0058
0059
0060
0061 [[nodiscard]] constexpr int cmp(ELseverityLevel const& e) const noexcept { return myLevel - e.myLevel; }
0062
0063
0064
0065 constexpr int getLevel() const noexcept { return myLevel; }
0066 std::string_view getName() const noexcept;
0067
0068 private:
0069
0070
0071 int myLevel;
0072
0073 };
0074
0075
0076
0077
0078
0079
0080 constexpr const ELseverityLevel ELzeroSeverity{ELseverityLevel::ELsev_zeroSeverity};
0081
0082 constexpr const ELseverityLevel ELdebug{ELseverityLevel::ELsev_success};
0083
0084 constexpr const ELseverityLevel ELinfo{ELseverityLevel::ELsev_info};
0085
0086 constexpr const ELseverityLevel ELfwkInfo{ELseverityLevel::ELsev_fwkInfo};
0087
0088 constexpr const ELseverityLevel ELwarning{ELseverityLevel::ELsev_warning};
0089
0090 constexpr const ELseverityLevel ELerror{ELseverityLevel::ELsev_error};
0091
0092 constexpr const ELseverityLevel ELunspecified{ELseverityLevel::ELsev_unspecified};
0093
0094 constexpr const ELseverityLevel ELsevere{ELseverityLevel::ELsev_severe};
0095
0096 constexpr const ELseverityLevel ELhighestSeverity{ELseverityLevel::ELsev_highestSeverity};
0097
0098
0099
0100
0101
0102 constexpr inline bool operator==(ELseverityLevel const& e1, ELseverityLevel const& e2) noexcept {
0103 return e1.cmp(e2) == 0;
0104 }
0105 constexpr inline bool operator!=(ELseverityLevel const& e1, ELseverityLevel const& e2) noexcept {
0106 return e1.cmp(e2) != 0;
0107 }
0108 constexpr inline bool operator<(ELseverityLevel const& e1, ELseverityLevel const& e2) noexcept {
0109 return e1.cmp(e2) < 0;
0110 }
0111 constexpr inline bool operator<=(ELseverityLevel const& e1, ELseverityLevel const& e2) noexcept {
0112 return e1.cmp(e2) <= 0;
0113 }
0114 constexpr inline bool operator>(ELseverityLevel const& e1, ELseverityLevel const& e2) noexcept {
0115 return e1.cmp(e2) > 0;
0116 }
0117 constexpr inline bool operator>=(ELseverityLevel const& e1, ELseverityLevel const& e2) noexcept {
0118 return e1.cmp(e2) >= 0;
0119 }
0120
0121
0122
0123 }
0124
0125 #endif