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
edm::EDGetToken::index
constexpr unsigned int index() const noexcept
Definition: EDGetToken.h:50
edm::EDGetToken::s_uninitializedValue
static const unsigned int s_uninitializedValue
Definition: EDGetToken.h:57
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::EDGetTokenT::operator=
constexpr EDGetTokenT & operator=(ADAPTER &&iAdapter)
Definition: EDGetToken.h:82
edm::EDGetTokenT::isUninitialized
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:99
edm::EDGetToken::EDGetToken
constexpr EDGetToken(unsigned int iValue) noexcept
Definition: EDGetToken.h:59
edm::EDGetToken::TestEDGetToken
friend class TestEDGetToken
Definition: EDGetToken.h:55
watchdog.const
const
Definition: watchdog.py:83
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
Utilities.operator
operator
Definition: Utilities.py:24
edm::EDGetTokenT::EDGetTokenT
constexpr EDGetTokenT(const EDGetTokenT< T > &&iOther) noexcept
Definition: EDGetToken.h:92
edm::EDConsumerBase
Definition: EDConsumerBase.h:71
edm::EDGetToken::EDGetToken
constexpr EDGetToken(EDGetTokenT< T > iOther) noexcept
Definition: EDGetToken.h:42
edm::EDGetTokenT::s_uninitializedValue
static const unsigned int s_uninitializedValue
Definition: EDGetToken.h:105
edm::EDGetTokenT::operator=
constexpr EDGetTokenT & operator=(EDGetTokenT< T > &iOther)
Definition: EDGetToken.h:94
edm::EDGetToken::m_value
unsigned int m_value
Definition: EDGetToken.h:62
writedatasetfile.default
default
Definition: writedatasetfile.py:11
edm::EDGetToken::EDGetToken
constexpr EDGetToken() noexcept
Definition: EDGetToken.h:39
svgfig.template
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
edm::EDGetTokenT::index
constexpr unsigned int index() const noexcept
Definition: EDGetToken.h:98
edm::EDGetToken
Definition: EDGetToken.h:35
edm::EDGetTokenT::EDGetTokenT
constexpr EDGetTokenT(unsigned int iValue) noexcept
Definition: EDGetToken.h:107
EDGetToken
edm::EDGetToken::isUninitialized
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:51
T
long double T
Definition: Basic3DVectorLD.h:48
edm::EDGetTokenT::EDGetTokenT
constexpr EDGetTokenT()
Definition: EDGetToken.h:71
edm::EDGetTokenT::EDGetTokenT
constexpr EDGetTokenT(EDGetTokenT< T > &iOther) noexcept
Definition: EDGetToken.h:91
edm::EDGetTokenT::m_value
unsigned int m_value
Definition: EDGetToken.h:110
edm::EDGetTokenT::TestEDGetToken
friend class TestEDGetToken
Definition: EDGetToken.h:103