File indexing completed on 2024-08-22 04:57:39
0001 #ifndef FWCore_Utilities_EDGetToken_h
0002 #define FWCore_Utilities_EDGetToken_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 namespace fwlite {
0031 class EventBase;
0032 }
0033
0034 namespace edm {
0035 class EDConsumerBase;
0036 template <typename T>
0037 class EDGetTokenT;
0038
0039 class EDGetToken {
0040 friend class EDConsumerBase;
0041
0042 public:
0043 constexpr EDGetToken() noexcept : m_value{s_uninitializedValue} {}
0044
0045 template <typename T>
0046 constexpr EDGetToken(EDGetTokenT<T> iOther) noexcept : m_value{iOther.m_value} {}
0047
0048 constexpr EDGetToken(const EDGetToken&) noexcept = default;
0049 constexpr EDGetToken(EDGetToken&&) noexcept = default;
0050 constexpr EDGetToken& operator=(const EDGetToken&) noexcept = default;
0051 constexpr EDGetToken& operator=(EDGetToken&&) noexcept = default;
0052
0053
0054 constexpr unsigned int index() const noexcept { return m_value; }
0055 constexpr bool isUninitialized() const noexcept { return m_value == s_uninitializedValue; }
0056
0057 private:
0058
0059 friend class TestEDGetToken;
0060
0061 static const unsigned int s_uninitializedValue = 0xFFFFFFFF;
0062
0063 constexpr explicit EDGetToken(unsigned int iValue) noexcept : m_value(iValue) {}
0064
0065
0066 unsigned int m_value;
0067 };
0068
0069 template <typename T>
0070 class EDGetTokenT {
0071 friend class EDConsumerBase;
0072 friend class EDGetToken;
0073 friend class ::fwlite::EventBase;
0074
0075 public:
0076 constexpr EDGetTokenT() : m_value{s_uninitializedValue} {}
0077
0078 constexpr EDGetTokenT(const EDGetTokenT<T>&) noexcept = default;
0079 constexpr EDGetTokenT(EDGetTokenT<T>&&) noexcept = default;
0080 constexpr EDGetTokenT& operator=(const EDGetTokenT<T>&) noexcept = default;
0081 constexpr EDGetTokenT& operator=(EDGetTokenT<T>&&) noexcept = default;
0082
0083 template <typename ADAPTER>
0084 requires requires(ADAPTER&& a) { a.template consumes<T>(); }
0085 constexpr explicit EDGetTokenT(ADAPTER&& iAdapter) : EDGetTokenT(iAdapter.template consumes<T>()) {}
0086
0087 template <typename ADAPTER>
0088 requires requires(ADAPTER&& a) { a.template consumes<T>(); }
0089 constexpr EDGetTokenT& operator=(ADAPTER&& iAdapter) {
0090 EDGetTokenT<T> temp(iAdapter.template consumes<T>());
0091 m_value = temp.m_value;
0092
0093 return *this;
0094 }
0095
0096
0097 constexpr unsigned int index() const noexcept { return m_value; }
0098 constexpr bool isUninitialized() const noexcept { return m_value == s_uninitializedValue; }
0099
0100 private:
0101
0102 friend class TestEDGetToken;
0103
0104 static const unsigned int s_uninitializedValue = 0xFFFFFFFF;
0105
0106 constexpr explicit EDGetTokenT(unsigned int iValue) noexcept : m_value(iValue) {}
0107
0108
0109 unsigned int m_value;
0110 };
0111 }
0112
0113 #endif