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
DataKey makeKey(const std::string &iName) const override
std::shared_ptr< std::pair< unsigned int, std::shared_ptr< CallbackType > > > callback_
const ProxyArgumentFactoryTemplate & operator=(const ProxyArgumentFactoryTemplate &)=delete
assert(be >=bs)
std::unique_ptr< DataProxy > makeProxy(unsigned int iovIndex) override
ProxyArgumentFactoryTemplate(std::shared_ptr< std::pair< unsigned int, std::shared_ptr< CallbackType >>> callback)
HLT enums.
def move(src, dest)
Definition: eostools.py:511