CMS 3D CMS Logo

ESGetToken.h
Go to the documentation of this file.
1 #ifndef FWCore_Utilities_ESGetToken_h
2 #define FWCore_Utilities_ESGetToken_h
3 // -*- C++ -*-
4 //
5 // Package: FWCore/Utilities
6 // Class : ESGetToken
7 //
19 #include <limits>
20 
21 namespace edm {
22  class EDConsumerBase;
23  class ESProducer;
24  class ESConsumesCollector;
25  class EventSetup;
26  class EventSetupImpl;
27  namespace eventsetup {
28  class EventSetupRecord;
29  }
30 
31  // A ESGetToken is created by calls to 'esConsumes' from an EDM
32  // module.
33  template <typename ESProduct, typename ESRecord>
34  class ESGetToken {
35  friend class EDConsumerBase;
36  friend class ESProducer;
37  friend class ESConsumesCollector;
38  friend class EventSetup;
39  friend class EventSetupImpl;
41 
42  public:
43  constexpr ESGetToken() noexcept = default;
44 
45  constexpr ESGetToken(ESGetToken<ESProduct, ESRecord> const&) noexcept = default;
46  constexpr ESGetToken(ESGetToken<ESProduct, ESRecord>&&) noexcept = default;
47 
48  constexpr ESGetToken<ESProduct, ESRecord>& operator=(ESGetToken<ESProduct, ESRecord>&&) noexcept = default;
49  constexpr ESGetToken<ESProduct, ESRecord>& operator=(ESGetToken<ESProduct, ESRecord> const&) noexcept = default;
50 
51  template <typename ADAPTER>
52  constexpr explicit ESGetToken(ADAPTER&& iAdapter) : ESGetToken(iAdapter.template consumes<ESProduct, ESRecord>()) {}
53 
54  template <typename ADAPTER>
55  constexpr ESGetToken<ESProduct, ESRecord>& operator=(ADAPTER&& iAdapter) noexcept {
56  ESGetToken<ESProduct, ESRecord> temp(std::forward<ADAPTER>(iAdapter));
57  return (*this = std::move(temp));
58  }
59 
60  //protect against templated version being a better match
62  : ESGetToken(const_cast<const ESGetToken<ESProduct, ESRecord>&>(iOther)) {}
64  return (*this = const_cast<ESGetToken<ESProduct, ESRecord> const&>(iOther));
65  }
66  constexpr ESGetToken(ESGetToken<ESProduct, ESRecord> const&& iOther) : ESGetToken(iOther) {}
68  return (*this = iOther);
69  }
70 
71  constexpr unsigned int transitionID() const noexcept { return m_transitionID; }
72  constexpr bool isInitialized() const noexcept { return transitionID() != std::numeric_limits<unsigned int>::max(); }
73  constexpr ESTokenIndex index() const noexcept { return m_index; }
74  constexpr bool hasValidIndex() const noexcept { return index() != invalidIndex(); }
75  static constexpr ESTokenIndex invalidIndex() noexcept { return ESTokenIndex{std::numeric_limits<int>::max()}; }
76 
77  private:
78  explicit constexpr ESGetToken(unsigned int transitionID, ESTokenIndex index, char const* label) noexcept
80 
81  constexpr char const* name() const noexcept { return m_label; }
82  char const* m_label{nullptr};
85  };
86 
87 } // namespace edm
88 
89 #endif
edm::ESGetToken::name
constexpr char const * name() const noexcept
Definition: ESGetToken.h:81
edm::ESTokenIndex
Definition: ESIndices.h:55
mixOne_cfi.ESProducer
ESProducer
Definition: mixOne_cfi.py:33
edm::ESGetToken::index
constexpr ESTokenIndex index() const noexcept
Definition: ESGetToken.h:73
edm::eventsetup::EventSetupRecord
Definition: EventSetupRecord.h:83
edm::ESGetToken::m_index
ESTokenIndex m_index
Definition: ESGetToken.h:84
edm::ESConsumesCollector
Definition: ESConsumesCollector.h:61
edm::EventSetupImpl
Definition: EventSetupImpl.h:49
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ESGetToken::ESGetToken
constexpr ESGetToken() noexcept=default
watchdog.const
const
Definition: watchdog.py:83
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
ESIndices.h
Utilities.operator
operator
Definition: Utilities.py:24
edm::ESGetToken::ESGetToken
constexpr ESGetToken(ESGetToken< ESProduct, ESRecord > &iOther)
Definition: ESGetToken.h:61
edm::ESGetToken::isInitialized
constexpr bool isInitialized() const noexcept
Definition: ESGetToken.h:72
edm::ESGetToken::hasValidIndex
constexpr bool hasValidIndex() const noexcept
Definition: ESGetToken.h:74
edm::ESGetToken::invalidIndex
static constexpr ESTokenIndex invalidIndex() noexcept
Definition: ESGetToken.h:75
edm::EDConsumerBase
Definition: EDConsumerBase.h:71
edm::ESGetToken::m_transitionID
unsigned int m_transitionID
Definition: ESGetToken.h:83
edm::ESGetToken::operator=
constexpr ESGetToken< ESProduct, ESRecord > & operator=(ADAPTER &&iAdapter) noexcept
Definition: ESGetToken.h:55
edm::ESGetToken::ESGetToken
constexpr ESGetToken(unsigned int transitionID, ESTokenIndex index, char const *label) noexcept
Definition: ESGetToken.h:78
edm::ESGetToken::operator=
constexpr ESGetToken< ESProduct, ESRecord > & operator=(ESGetToken< ESProduct, ESRecord > const &&iOther) noexcept
Definition: ESGetToken.h:67
edm::ESGetToken::transitionID
constexpr unsigned int transitionID() const noexcept
Definition: ESGetToken.h:71
writedatasetfile.default
default
Definition: writedatasetfile.py:11
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
edm::ESGetToken::operator=
constexpr ESGetToken< ESProduct, ESRecord > & operator=(ESGetToken< ESProduct, ESRecord > &iOther) noexcept
Definition: ESGetToken.h:63
edm::EventSetup
Definition: EventSetup.h:58
svgfig.template
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
ESGetToken
edm::ESGetToken
Definition: EventSetup.h:48
ESInputTag.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::ESGetToken::m_label
char const * m_label
Definition: ESGetToken.h:82
edm::ESProducer
Definition: ESProducer.h:104
edm::ESGetToken::ESGetToken
constexpr ESGetToken(ESGetToken< ESProduct, ESRecord > const &&iOther)
Definition: ESGetToken.h:66
EventSetup
label
const char * label
Definition: PFTauDecayModeTools.cc:11