CMS 3D CMS Logo

CallbackProductResolver.h
Go to the documentation of this file.
1 #ifndef Framework_CallbackProductResolver_h
2 #define Framework_CallbackProductResolver_h
3 // -*- C++ -*-
4 //
5 // Package: Framework
6 // Class : CallbackProductResolver
7 //
17 //
18 // Author: Chris Jones
19 // Created: Fri Apr 8 11:50:21 CDT 2005
20 //
21 
22 // system include files
23 #include <cassert>
24 #include <memory>
25 
26 // user include files
31 
34 
35 // forward declarations
36 namespace edm::eventsetup {
37 
38  template <class CallbackT, class RecordT, class DataT>
40  public:
43  using RecordType = RecordT;
44 
45  CallbackProductResolver(std::shared_ptr<CallbackT>& iCallback) : callback_{iCallback} {
46  //The callback fills the data directly. This is done so that the callback does not have to
47  // hold onto a temporary copy of the result of the callback since the callback is allowed
48  // to return multiple items where only one item is needed by this ProductResolver
49  iCallback->holdOntoPointer(&data_);
50  }
51 
53  DataT* dummy(nullptr);
54  callback_->holdOntoPointer(dummy);
55  }
56 
58  const EventSetupRecordImpl& iRecord,
59  const DataKey&,
60  EventSetupImpl const* iEventSetupImpl,
61  ServiceToken const& iToken,
62  edm::ESParentContext const& iParent) final {
63  assert(iRecord.key() == RecordT::keyForClass());
64  callback_->prefetchAsync(iWaitTask, &iRecord, iEventSetupImpl, iToken, iParent);
65  }
66 
68 
69  void invalidateCache() override {
70  data_ = DataT{};
71  callback_->newRecordComing();
72  }
73 
74  // Delete copy operations
77 
78  private:
79  DataT data_{};
81  };
82 
83 } // namespace edm::eventsetup
84 
85 #endif
edm::propagate_const< std::shared_ptr< CallbackT > > callback_
const CallbackProductResolver & operator=(const CallbackProductResolver &)=delete
static auto getPointer(T const &iPtr) -> decltype(&*iPtr)
assert(be >=bs)
CallbackProductResolver(std::shared_ptr< CallbackT > &iCallback)
void prefetchAsyncImpl(WaitingTaskHolder iWaitTask, const EventSetupRecordImpl &iRecord, const DataKey &, EventSetupImpl const *iEventSetupImpl, ServiceToken const &iToken, edm::ESParentContext const &iParent) final
typename smart_pointer_traits::type ValueType