File indexing completed on 2024-09-12 04:16:30
0001
0002 #ifndef FWCore_Utilities_ESIndices_h
0003 #define FWCore_Utilities_ESIndices_h
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 #include <limits>
0025 #include <ostream>
0026
0027
0028
0029 namespace edm {
0030 class ESResolverIndex {
0031 public:
0032 using Value_t = int;
0033 constexpr ESResolverIndex() noexcept = default;
0034 constexpr explicit ESResolverIndex(Value_t iValue) noexcept : index_{iValue} {}
0035 constexpr ESResolverIndex(ESResolverIndex const&) noexcept = default;
0036 constexpr ESResolverIndex(ESResolverIndex&&) noexcept = default;
0037
0038 constexpr ESResolverIndex& operator=(ESResolverIndex const&) noexcept = default;
0039 constexpr ESResolverIndex& operator=(ESResolverIndex&&) noexcept = default;
0040
0041 constexpr bool operator==(ESResolverIndex iOther) const noexcept { return iOther.index_ == index_; }
0042 constexpr bool operator!=(ESResolverIndex iOther) const noexcept { return iOther.index_ != index_; }
0043
0044 constexpr Value_t value() const noexcept { return index_; }
0045
0046 static constexpr ESResolverIndex noResolverConfigured() noexcept {
0047 return ESResolverIndex{std::numeric_limits<int>::max()};
0048 }
0049
0050 static constexpr ESResolverIndex moduleLabelDoesNotMatch() noexcept {
0051 return ESResolverIndex{std::numeric_limits<int>::max() - 1};
0052 }
0053
0054 private:
0055 Value_t index_ = std::numeric_limits<int>::max();
0056 };
0057
0058 inline std::ostream& operator<<(std::ostream& iOS, ESResolverIndex const& iIndex) {
0059 iOS << iIndex.value();
0060 return iOS;
0061 }
0062
0063 class ESTokenIndex {
0064 public:
0065 using Value_t = int;
0066
0067 constexpr ESTokenIndex() noexcept = default;
0068 constexpr explicit ESTokenIndex(Value_t iValue) noexcept : index_{iValue} {}
0069 constexpr ESTokenIndex(ESTokenIndex const&) noexcept = default;
0070 constexpr ESTokenIndex(ESTokenIndex&&) noexcept = default;
0071
0072 constexpr ESTokenIndex& operator=(ESTokenIndex const&) noexcept = default;
0073 constexpr ESTokenIndex& operator=(ESTokenIndex&&) noexcept = default;
0074
0075 constexpr bool operator==(ESTokenIndex iOther) const noexcept { return iOther.index_ == index_; }
0076 constexpr bool operator!=(ESTokenIndex iOther) const noexcept { return iOther.index_ != index_; }
0077
0078 constexpr Value_t value() const noexcept { return index_; }
0079
0080 private:
0081 Value_t index_ = std::numeric_limits<Value_t>::max();
0082 };
0083 inline std::ostream& operator<<(std::ostream& iOS, ESTokenIndex const& iIndex) {
0084 iOS << iIndex.value();
0085 return iOS;
0086 }
0087
0088 class ESRecordIndex {
0089 public:
0090 using Value_t = unsigned int;
0091
0092 constexpr ESRecordIndex() noexcept = default;
0093 constexpr explicit ESRecordIndex(unsigned int iValue) noexcept : index_{iValue} {}
0094 constexpr ESRecordIndex(ESRecordIndex const&) noexcept = default;
0095 constexpr ESRecordIndex(ESRecordIndex&&) noexcept = default;
0096
0097 constexpr ESRecordIndex& operator=(ESRecordIndex const&) noexcept = default;
0098 constexpr ESRecordIndex& operator=(ESRecordIndex&&) noexcept = default;
0099
0100 constexpr bool operator==(ESRecordIndex iOther) const noexcept { return iOther.index_ == index_; }
0101 constexpr bool operator!=(ESRecordIndex iOther) const noexcept { return iOther.index_ != index_; }
0102
0103 constexpr Value_t value() const noexcept { return index_; }
0104
0105 static constexpr Value_t invalidValue() { return std::numeric_limits<Value_t>::max(); }
0106
0107 private:
0108 Value_t index_ = std::numeric_limits<Value_t>::max();
0109 };
0110 inline std::ostream& operator<<(std::ostream& iOS, ESRecordIndex const& iIndex) {
0111 iOS << iIndex.value();
0112 return iOS;
0113 }
0114
0115 }
0116 #endif