CMS 3D CMS Logo

ESProxyFactoryProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Framework
4 // Class : ESProxyFactoryProducer
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Author: Chris Jones
10 // Created: Thu Apr 7 21:36:15 CDT 2005
11 //
12 
13 // system include files
14 
15 // user include files
18 
20 
22 #include <algorithm>
23 #include <cassert>
24 //
25 // constants, enums and typedefs
26 //
27 using namespace edm::eventsetup;
28 namespace edm {
29 
30  typedef std::multimap< EventSetupRecordKey, FactoryInfo > Record2Factories;
31 
32 //
33 // static data member definitions
34 //
35 
36 //
37 // constructors and destructor
38 //
40 {
41 }
42 
43 // ESProxyFactoryProducer::ESProxyFactoryProducer(const ESProxyFactoryProducer& rhs)
44 // {
45 // // do actual copying here;
46 // }
47 
49 {
50 }
51 
52 //
53 // assignment operators
54 //
55 // const ESProxyFactoryProducer& ESProxyFactoryProducer::operator=(const ESProxyFactoryProducer& rhs)
56 // {
57 // //An exception safe implementation is
58 // ESProxyFactoryProducer temp(rhs);
59 // swap(rhs);
60 //
61 // return *this;
62 // }
63 
64 //
65 // member functions
66 //
67 void
69  KeyedProxies& iProxies)
70 {
71  typedef Record2Factories::iterator Iterator;
72  std::pair< Iterator, Iterator > range = record2Factories_.equal_range(iRecord);
73  for(Iterator it = range.first; it != range.second; ++it) {
74 
75  std::shared_ptr<DataProxy> proxy(it->second.factory_->makeProxy().release());
76  if(nullptr != proxy.get()) {
77  iProxies.push_back(KeyedProxies::value_type((*it).second.key_,
78  proxy));
79  }
80  }
81 }
82 
83 void
85  std::unique_ptr<ProxyFactoryBase> iFactory,
86  const std::string& iLabel )
87 {
88  if(nullptr == iFactory.get()) {
89  assert(false && "Factor pointer was null");
90  ::exit(1);
91  }
92 
93  usingRecordWithKey(iRecord);
94 
95  std::shared_ptr<ProxyFactoryBase> temp(iFactory.release());
96  FactoryInfo info(temp->makeKey(iLabel),
97  temp);
98 
99  //has this already been registered?
100  std::pair<Record2Factories::const_iterator,Record2Factories::const_iterator> range =
101  record2Factories_.equal_range(iRecord);
102  if(range.second != std::find_if(range.first,range.second,
103  [&info](const auto& r2f) {
104  return r2f.second.key_ == info.key_;
105  }
106  ) ) {
107  throw cms::Exception("IdenticalProducts")<<"Producer has been asked to produce "<<info.key_.type().name()
108  <<" \""<<info.key_.name().value()<<"\" multiple times.\n Please modify the code.";
109  }
110 
112  std::move(info)));
113 }
114 
115 void
117  const ValidityInterval& /*iInterval*/)
118 {
119  invalidateProxies(iRecordType);
120 }
121 
122 //
123 // const member functions
124 //
125 
126 //
127 // static member functions
128 //
129 }
static const TGPicture * info(bool iBackgroundIsBlack)
#define noexcept
void usingRecordWithKey(const EventSetupRecordKey &)
std::multimap< eventsetup::EventSetupRecordKey, eventsetup::FactoryInfo > record2Factories_
std::vector< std::pair< DataKey, edm::propagate_const< std::shared_ptr< DataProxy > > > > KeyedProxies
void invalidateProxies(const EventSetupRecordKey &iRecordKey)
~ESProxyFactoryProducer() noexcept(false) override
std::multimap< EventSetupRecordKey, FactoryInfo > Record2Factories
virtual void registerFactoryWithKey(const eventsetup::EventSetupRecordKey &iRecord, std::unique_ptr< eventsetup::ProxyFactoryBase > iFactory, const std::string &iLabel=std::string())
HLT enums.
void registerProxies(const eventsetup::EventSetupRecordKey &iRecord, KeyedProxies &aProxyList) override
override DataProxyProvider method
void newInterval(const eventsetup::EventSetupRecordKey &iRecordType, const ValidityInterval &iInterval) override
overrides DataProxyProvider method
def move(src, dest)
Definition: eostools.py:510