CMS 3D CMS Logo

EDGetToken.h
Go to the documentation of this file.
1 #ifndef FWCore_Utilities_EDGetToken_h
2 #define FWCore_Utilities_EDGetToken_h
3 // -*- C++ -*-
4 //
5 // Package: FWCore/Utilities
6 // Class : EDGetToken
7 //
20 //
21 // Original Author: Chris Jones
22 // Created: Wed, 03 Apr 2013 17:54:11 GMT
23 //
24 
25 // system include files
26 
27 // user include files
28 
29 // forward declarations
30 namespace edm {
31  class EDConsumerBase;
32  template <typename T>
33  class EDGetTokenT;
34 
35  class EDGetToken {
36  friend class EDConsumerBase;
37 
38  public:
39  constexpr EDGetToken() noexcept : m_value{s_uninitializedValue} {}
40 
41  template <typename T>
42  constexpr EDGetToken(EDGetTokenT<T> iOther) noexcept : m_value{iOther.m_value} {}
43 
44  constexpr EDGetToken(const EDGetToken&) noexcept = default;
45  constexpr EDGetToken(EDGetToken&&) noexcept = default;
46  constexpr EDGetToken& operator=(const EDGetToken&) noexcept = default;
47  constexpr EDGetToken& operator=(EDGetToken&&) noexcept = default;
48 
49  // ---------- const member functions ---------------------
50  constexpr unsigned int index() const noexcept { return m_value; }
51  constexpr bool isUninitialized() const noexcept { return m_value == s_uninitializedValue; }
52 
53  private:
54  //for testing
55  friend class TestEDGetToken;
56 
57  static const unsigned int s_uninitializedValue = 0xFFFFFFFF;
58 
59  constexpr explicit EDGetToken(unsigned int iValue) noexcept : m_value(iValue) {}
60 
61  // ---------- member data --------------------------------
62  unsigned int m_value;
63  };
64 
65  template <typename T>
66  class EDGetTokenT {
67  friend class EDConsumerBase;
68  friend class EDGetToken;
69 
70  public:
72 
73  constexpr EDGetTokenT(const EDGetTokenT<T>&) noexcept = default;
74  constexpr EDGetTokenT(EDGetTokenT<T>&&) noexcept = default;
75  constexpr EDGetTokenT& operator=(const EDGetTokenT<T>&) noexcept = default;
76  constexpr EDGetTokenT& operator=(EDGetTokenT<T>&&) noexcept = default;
77 
78  template <typename ADAPTER>
79  constexpr explicit EDGetTokenT(ADAPTER&& iAdapter) : EDGetTokenT(iAdapter.template consumes<T>()) {}
80 
81  template <typename ADAPTER>
82  constexpr EDGetTokenT& operator=(ADAPTER&& iAdapter) {
83  EDGetTokenT<T> temp(iAdapter.template consumes<T>());
84  m_value = temp.m_value;
85 
86  return *this;
87  }
88 
89  //Needed to avoid EDGetTokenT(ADAPTER&&) from being called instead
90  // when we can use C++20 concepts we can avoid the problem using a constraint
91  constexpr EDGetTokenT(EDGetTokenT<T>& iOther) noexcept : m_value{iOther.m_value} {}
92  constexpr EDGetTokenT(const EDGetTokenT<T>&& iOther) noexcept : m_value{iOther.m_value} {}
93 
94  constexpr EDGetTokenT& operator=(EDGetTokenT<T>& iOther) {
95  return (*this = const_cast<const EDGetTokenT<T>&>(iOther));
96  }
97  // ---------- const member functions ---------------------
98  constexpr unsigned int index() const noexcept { return m_value; }
99  constexpr bool isUninitialized() const noexcept { return m_value == s_uninitializedValue; }
100 
101  private:
102  //for testing
103  friend class TestEDGetToken;
104 
105  static const unsigned int s_uninitializedValue = 0xFFFFFFFF;
106 
107  constexpr explicit EDGetTokenT(unsigned int iValue) noexcept : m_value(iValue) {}
108 
109  // ---------- member data --------------------------------
110  unsigned int m_value;
111  };
112 } // namespace edm
113 
114 #endif
constexpr EDGetTokenT(unsigned int iValue) noexcept
Definition: EDGetToken.h:107
constexpr unsigned int index() const noexcept
Definition: EDGetToken.h:50
static const unsigned int s_uninitializedValue
Definition: EDGetToken.h:57
constexpr EDGetTokenT(EDGetTokenT< T > &iOther) noexcept
Definition: EDGetToken.h:91
constexpr EDGetTokenT()
Definition: EDGetToken.h:71
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:99
friend class TestEDGetToken
Definition: EDGetToken.h:55
constexpr EDGetTokenT & operator=(EDGetTokenT< T > &iOther)
Definition: EDGetToken.h:94
constexpr EDGetToken(unsigned int iValue) noexcept
Definition: EDGetToken.h:59
static const unsigned int s_uninitializedValue
Definition: EDGetToken.h:105
constexpr EDGetToken(EDGetTokenT< T > iOther) noexcept
Definition: EDGetToken.h:42
constexpr EDGetTokenT(const EDGetTokenT< T > &&iOther) noexcept
Definition: EDGetToken.h:92
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
constexpr EDGetToken() noexcept
Definition: EDGetToken.h:39
unsigned int m_value
Definition: EDGetToken.h:62
unsigned int m_value
Definition: EDGetToken.h:110
friend class TestEDGetToken
Definition: EDGetToken.h:103
constexpr unsigned int index() const noexcept
Definition: EDGetToken.h:98
HLT enums.
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:51
long double T
constexpr EDGetTokenT & operator=(ADAPTER &&iAdapter)
Definition: EDGetToken.h:82