CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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) {
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
constexpr ESTokenIndex index() const noexcept
Definition: ESGetToken.h:73
constexpr unsigned int transitionID() const noexcept
Definition: ESGetToken.h:71
ESTokenIndex m_index
Definition: ESGetToken.h:84
constexpr ESGetToken(unsigned int transitionID, ESTokenIndex index, char const *label) noexcept
Definition: ESGetToken.h:78
constexpr char const * name() const noexcept
Definition: ESGetToken.h:81
constexpr ESGetToken< ESProduct, ESRecord > & operator=(ADAPTER &&iAdapter)
Definition: ESGetToken.h:55
char const * label
static constexpr ESTokenIndex invalidIndex() noexcept
Definition: ESGetToken.h:75
def move
Definition: eostools.py:511
constexpr ESGetToken() noexcept=default
constexpr ESGetToken(ESGetToken< ESProduct, ESRecord > &iOther)
Definition: ESGetToken.h:61
constexpr ESGetToken< ESProduct, ESRecord > & operator=(ESGetToken< ESProduct, ESRecord > &iOther) noexcept
Definition: ESGetToken.h:63
constexpr bool isInitialized() const noexcept
Definition: ESGetToken.h:72
unsigned int m_transitionID
Definition: ESGetToken.h:83
char const * m_label
Definition: ESGetToken.h:82
constexpr ESGetToken< ESProduct, ESRecord > & operator=(ESGetToken< ESProduct, ESRecord > const &&iOther) noexcept
Definition: ESGetToken.h:67
constexpr ESGetToken(ESGetToken< ESProduct, ESRecord > const &&iOther)
Definition: ESGetToken.h:66
constexpr bool hasValidIndex() const noexcept
Definition: ESGetToken.h:74
def template
Definition: svgfig.py:521