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  // ESProxyFactoryProducer::ESProxyFactoryProducer(const ESProxyFactoryProducer& rhs)
42  // {
43  // // do actual copying here;
44  // }
45 
47 
48  //
49  // assignment operators
50  //
51  // const ESProxyFactoryProducer& ESProxyFactoryProducer::operator=(const ESProxyFactoryProducer& rhs)
52  // {
53  // //An exception safe implementation is
54  // ESProxyFactoryProducer temp(rhs);
55  // swap(rhs);
56  //
57  // return *this;
58  // }
59 
60  //
61  // member functions
62  //
64  typedef Record2Factories::iterator Iterator;
65  std::pair<Iterator, Iterator> range = record2Factories_.equal_range(iRecord);
66  for (Iterator it = range.first; it != range.second; ++it) {
67  std::shared_ptr<DataProxy> proxy(it->second.factory_->makeProxy().release());
68  if (nullptr != proxy.get()) {
69  iProxies.push_back(KeyedProxies::value_type((*it).second.key_, proxy));
70  }
71  }
72  }
73 
75  std::unique_ptr<ProxyFactoryBase> iFactory,
76  const std::string& iLabel) {
77  if (nullptr == iFactory.get()) {
78  assert(false && "Factor pointer was null");
79  ::exit(1);
80  }
81 
82  usingRecordWithKey(iRecord);
83 
84  std::shared_ptr<ProxyFactoryBase> temp(iFactory.release());
85  FactoryInfo info(temp->makeKey(iLabel), temp);
86 
87  //has this already been registered?
88  std::pair<Record2Factories::const_iterator, Record2Factories::const_iterator> range =
89  record2Factories_.equal_range(iRecord);
90  if (range.second !=
91  std::find_if(range.first, range.second, [&info](const auto& r2f) { return r2f.second.key_ == info.key_; })) {
92  throw cms::Exception("IdenticalProducts")
93  << "Producer has been asked to produce " << info.key_.type().name() << " \"" << info.key_.name().value()
94  << "\" multiple times.\n Please modify the code.";
95  }
96 
98  }
99 
101  const ValidityInterval& /*iInterval*/) {
102  invalidateProxies(iRecordType);
103  }
104 
105  //
106  // const member functions
107  //
108 
109  //
110  // static member functions
111  //
112 } // namespace edm
static const TGPicture * info(bool iBackgroundIsBlack)
void usingRecordWithKey(const EventSetupRecordKey &)
std::vector< std::pair< DataKey, edm::propagate_const< std::shared_ptr< DataProxy > > > > KeyedProxies
TGeoIterator Iterator
void invalidateProxies(const EventSetupRecordKey &iRecordKey)
~ESProxyFactoryProducer() noexcept(false) override
#define noexcept
virtual void registerFactoryWithKey(const eventsetup::EventSetupRecordKey &iRecord, std::unique_ptr< eventsetup::ProxyFactoryBase > iFactory, const std::string &iLabel=std::string())
std::multimap< EventSetupRecordKey, FactoryInfo > Record2Factories
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
std::multimap< eventsetup::EventSetupRecordKey, eventsetup::FactoryInfo > record2Factories_
def move(src, dest)
Definition: eostools.py:511