CMS 3D CMS Logo

ProxyArgumentFactoryTemplate.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_ProxyArgumentFactoryTemplate_h
2 #define FWCore_Framework_ProxyArgumentFactoryTemplate_h
3 // -*- C++ -*-
4 //
5 // Package: Framework
6 // Class : ProxyArgumentFactoryTemplate
7 //
16 //
17 // Author: Chris Jones
18 // Created: Mon Apr 11 16:20:52 CDT 2005
19 //
20 
21 // system include files
22 #include <cassert>
23 #include <memory>
24 #include <string>
25 #include <vector>
26 
27 // user include files
30 
31 namespace edm {
32  namespace eventsetup {
33 
34  class DataProxy;
35 
36  template <class ProxyType, class CallbackType>
38  public:
39  using RecordType = typename ProxyType::RecordType;
40 
41  ProxyArgumentFactoryTemplate(std::shared_ptr<std::pair<unsigned int, std::shared_ptr<CallbackType>>> callback)
42  : callback_(std::move(callback)) {}
43 
46 
47  std::unique_ptr<DataProxy> makeProxy(unsigned int iovIndex) override {
48  if (iovIndex != callback_->first) {
49  // We are using the fact that we know all the factories related
50  // to one iovIndex are dealt with before makeProxy is called with
51  // a different iovIndex and that these calls are made in an
52  // order such that the iovIndex increments by 1 when it changes.
53  // We must clone, because we need a different callback object
54  // for each iovIndex.
55  assert(iovIndex == callback_->first + 1);
56  callback_->first = callback_->first + 1;
57  callback_->second = std::shared_ptr<CallbackType>(callback_->second->clone());
58  }
59  return std::make_unique<ProxyType>(callback_->second);
60  }
61 
62  DataKey makeKey(const std::string& iName) const override {
63  return DataKey(DataKey::makeTypeTag<typename ProxyType::ValueType>(), iName.c_str());
64  }
65 
66  private:
67  std::shared_ptr<std::pair<unsigned int, std::shared_ptr<CallbackType>>> callback_;
68  };
69  } // namespace eventsetup
70 } // namespace edm
71 #endif
edm::eventsetup::ProxyArgumentFactoryTemplate::callback_
std::shared_ptr< std::pair< unsigned int, std::shared_ptr< CallbackType > > > callback_
Definition: ProxyArgumentFactoryTemplate.h:67
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::eventsetup::ProxyArgumentFactoryTemplate::operator=
const ProxyArgumentFactoryTemplate & operator=(const ProxyArgumentFactoryTemplate &)=delete
cms::cuda::assert
assert(be >=bs)
edm::eventsetup::DataKey
Definition: DataKey.h:29
ProxyFactoryBase.h
edm::eventsetup::ProxyArgumentFactoryTemplate::ProxyArgumentFactoryTemplate
ProxyArgumentFactoryTemplate(std::shared_ptr< std::pair< unsigned int, std::shared_ptr< CallbackType >>> callback)
Definition: ProxyArgumentFactoryTemplate.h:41
edm::eventsetup::ProxyArgumentFactoryTemplate
Definition: ProxyArgumentFactoryTemplate.h:37
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DataProxy
Definition: DataProxy.h:26
DataKey.h
edm::eventsetup::ProxyFactoryBase
Definition: ProxyFactoryBase.h:33
edm::eventsetup::ProxyArgumentFactoryTemplate::makeProxy
std::unique_ptr< DataProxy > makeProxy(unsigned int iovIndex) override
Definition: ProxyArgumentFactoryTemplate.h:47
edm::eventsetup::ProxyArgumentFactoryTemplate::RecordType
typename ProxyType::RecordType RecordType
Definition: ProxyArgumentFactoryTemplate.h:39
edmIntegrityCheck.callback
callback
Definition: edmIntegrityCheck.py:75
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
edm::eventsetup::ProxyArgumentFactoryTemplate::makeKey
DataKey makeKey(const std::string &iName) const override
Definition: ProxyArgumentFactoryTemplate.h:62