File indexing completed on 2024-04-06 12:12:03
0001 #ifndef FWCore_Framework_EventSetupRecordImplementation_h
0002 #define FWCore_Framework_EventSetupRecordImplementation_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 #include "FWCore/Framework/interface/EventSetupRecord.h"
0027 #include "FWCore/Framework/interface/EventSetupRecordKey.h"
0028 #include "FWCore/Framework/interface/ESTransientHandle.h"
0029 #include "FWCore/Framework/interface/data_default_record_trait.h"
0030 #include "FWCore/Utilities/interface/ESGetToken.h"
0031
0032
0033
0034
0035 namespace edm {
0036 namespace eventsetup {
0037 struct ComponentDescription;
0038
0039 template <typename T>
0040 class EventSetupRecordImplementation : public EventSetupRecord {
0041 public:
0042
0043
0044
0045 EventSetupRecordKey key() const override { return EventSetupRecordKey::makeKey<T>(); }
0046
0047 template <typename PRODUCT>
0048 ESHandle<PRODUCT> getHandle(ESGetToken<PRODUCT, T> const& iToken) const {
0049 return getHandleImpl<ESHandle>(iToken);
0050 }
0051
0052 template <typename PRODUCT>
0053 ESHandle<PRODUCT> getHandle(ESGetToken<PRODUCT, edm::DefaultRecord> const& iToken) const {
0054 static_assert(std::is_same_v<T, eventsetup::default_record_t<ESHandle<PRODUCT>>>,
0055 "The Record being used to retrieve the product is not the default record for the product type");
0056 return getHandleImpl<ESHandle>(iToken);
0057 }
0058
0059 template <typename PRODUCT>
0060 ESTransientHandle<PRODUCT> getTransientHandle(ESGetToken<PRODUCT, T> const& iToken) const {
0061 return getHandleImpl<ESTransientHandle>(iToken);
0062 }
0063
0064 template <typename PRODUCT>
0065 ESTransientHandle<PRODUCT> getTransientHandle(ESGetToken<PRODUCT, edm::DefaultRecord> const& iToken) const {
0066 static_assert(std::is_same_v<T, eventsetup::default_record_t<ESTransientHandle<PRODUCT>>>,
0067 "The Record being used to retrieve the product is not the default record for the product type");
0068 return getHandleImpl<ESTransientHandle>(iToken);
0069 }
0070
0071 template <typename PRODUCT>
0072 PRODUCT const& get(ESGetToken<PRODUCT, T> const& iToken) const {
0073 return *getHandleImpl<ESHandle>(iToken);
0074 }
0075 template <typename PRODUCT>
0076 PRODUCT const& get(ESGetToken<PRODUCT, T>& iToken) const {
0077 return *getHandleImpl<ESHandle>(const_cast<const ESGetToken<PRODUCT, T>&>(iToken));
0078 }
0079
0080 template <typename PRODUCT>
0081 PRODUCT const& get(ESGetToken<PRODUCT, edm::DefaultRecord> const& iToken) const {
0082 static_assert(std::is_same_v<T, eventsetup::default_record_t<ESHandle<PRODUCT>>>,
0083 "The Record being used to retrieve the product is not the default record for the product type");
0084 return *getHandleImpl<ESHandle>(iToken);
0085 }
0086 template <typename PRODUCT>
0087 PRODUCT const& get(ESGetToken<PRODUCT, edm::DefaultRecord>& iToken) const {
0088 return get(const_cast<const ESGetToken<PRODUCT, edm::DefaultRecord>&>(iToken));
0089 }
0090
0091
0092 static EventSetupRecordKey keyForClass() { return EventSetupRecordKey::makeKey<T>(); }
0093
0094
0095
0096 protected:
0097 EventSetupRecordImplementation() {}
0098
0099 private:
0100
0101 };
0102 }
0103 }
0104
0105 #endif