CMS 3D CMS Logo

CallbackProxy.h
Go to the documentation of this file.
1 #ifndef Framework_CallbackProxy_h
2 #define Framework_CallbackProxy_h
3 // -*- C++ -*-
4 //
5 // Package: Framework
6 // Class : CallbackProxy
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>
39  class CallbackProxy final : public DataProxy {
40  public:
43  using RecordType = RecordT;
44 
45  CallbackProxy(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 Proxy
49  iCallback->holdOntoPointer(&data_);
50  }
51 
52  ~CallbackProxy() final {
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
75  CallbackProxy(const CallbackProxy&) = delete;
76  const CallbackProxy& operator=(const CallbackProxy&) = delete;
77 
78  private:
79  DataT data_{};
81  };
82 
83 } // namespace edm::eventsetup
84 
85 #endif
void const * getAfterPrefetchImpl() const final
Definition: CallbackProxy.h:67
void prefetchAsyncImpl(WaitingTaskHolder iWaitTask, const EventSetupRecordImpl &iRecord, const DataKey &, EventSetupImpl const *iEventSetupImpl, ServiceToken const &iToken, edm::ESParentContext const &iParent) final
Definition: CallbackProxy.h:57
static auto getPointer(T const &iPtr) -> decltype(&*iPtr)
assert(be >=bs)
edm::propagate_const< std::shared_ptr< CallbackT > > callback_
Definition: CallbackProxy.h:80
const CallbackProxy & operator=(const CallbackProxy &)=delete
CallbackProxy(std::shared_ptr< CallbackT > &iCallback)
Definition: CallbackProxy.h:45
typename smart_pointer_traits::type ValueType
Definition: CallbackProxy.h:42