File indexing completed on 2024-08-22 04:57:39
0001 #ifndef FWCore_Utilities_EDPutToken_h
0002 #define FWCore_Utilities_EDPutToken_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 edm {
0031 class ProductRegistryHelper;
0032 template <typename T>
0033 class EDPutTokenT;
0034 namespace test {
0035 class TestProcessorConfig;
0036 }
0037
0038 class EDPutToken {
0039 friend class ProductRegistryHelper;
0040
0041 public:
0042 using value_type = unsigned int;
0043
0044 constexpr EDPutToken() noexcept : m_value{s_uninitializedValue} {}
0045
0046 template <typename T>
0047 constexpr EDPutToken(EDPutTokenT<T> iOther) noexcept : m_value{iOther.m_value} {}
0048
0049
0050 constexpr value_type index() const noexcept { return m_value; }
0051 constexpr bool isUninitialized() const noexcept { return m_value == s_uninitializedValue; }
0052
0053 private:
0054
0055 friend class TestEDPutToken;
0056
0057 static constexpr unsigned int s_uninitializedValue = 0xFFFFFFFF;
0058
0059 explicit constexpr EDPutToken(unsigned int iValue) noexcept : m_value(iValue) {}
0060
0061
0062 value_type m_value;
0063 };
0064
0065 template <typename T>
0066 class EDPutTokenT {
0067 friend class ProductRegistryHelper;
0068 friend class EDPutToken;
0069 friend class edm::test::TestProcessorConfig;
0070
0071 public:
0072 using value_type = EDPutToken::value_type;
0073
0074 constexpr EDPutTokenT() noexcept : m_value{s_uninitializedValue} {}
0075
0076 constexpr EDPutTokenT(const EDPutTokenT<T>&) noexcept = default;
0077 constexpr EDPutTokenT(EDPutTokenT<T>&&) noexcept = default;
0078
0079 template <typename ADAPTER>
0080 requires requires(ADAPTER&& a) { a.template produces<T>(); }
0081 constexpr explicit EDPutTokenT(ADAPTER&& iAdapter) noexcept : EDPutTokenT(iAdapter.template produces<T>()) {}
0082
0083 constexpr EDPutTokenT& operator=(const EDPutTokenT<T>&) noexcept = default;
0084 constexpr EDPutTokenT& operator=(EDPutTokenT<T>&&) noexcept = default;
0085
0086 template <typename ADAPTER>
0087 requires requires(ADAPTER&& a) { a.template produces<T>(); }
0088 constexpr EDPutTokenT& operator=(ADAPTER&& iAdapter) noexcept {
0089 EDPutTokenT<T> temp(iAdapter.template produces<T>());
0090 m_value = temp.m_value;
0091
0092 return *this;
0093 }
0094
0095
0096 constexpr value_type index() const noexcept { return m_value; }
0097 constexpr bool isUninitialized() const noexcept { return m_value == s_uninitializedValue; }
0098
0099 private:
0100
0101 friend class TestEDPutToken;
0102
0103 static constexpr unsigned int s_uninitializedValue = 0xFFFFFFFF;
0104
0105 constexpr explicit EDPutTokenT(unsigned int iValue) noexcept : m_value(iValue) {}
0106 constexpr explicit EDPutTokenT(unsigned long int iValue) noexcept : m_value(iValue) {}
0107
0108
0109 value_type m_value;
0110 };
0111 }
0112
0113 #endif