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 #include <algorithm>
15 #include <cassert>
16 
17 // user include files
20 
22 
24 
25 using namespace edm::eventsetup;
26 namespace edm {
27 
28  using Record2Factories = std::multimap<EventSetupRecordKey, FactoryInfo>;
29 
31 
33 
35  unsigned int iovIndex) {
36  KeyedProxiesVector keyedProxiesVector;
37  using Iterator = Record2Factories::iterator;
38  std::pair<Iterator, Iterator> range = record2Factories_.equal_range(iRecord);
39  for (Iterator it = range.first; it != range.second; ++it) {
40  std::shared_ptr<DataProxy> proxy(it->second.factory_->makeProxy(iovIndex).release());
41  if (nullptr != proxy.get()) {
42  keyedProxiesVector.emplace_back((*it).second.key_, proxy);
43  }
44  }
45  return keyedProxiesVector;
46  }
47 
49  std::unique_ptr<ProxyFactoryBase> iFactory,
50  const std::string& iLabel) {
51  if (nullptr == iFactory.get()) {
52  assert(false && "Factor pointer was null");
53  ::exit(1);
54  }
55 
56  usingRecordWithKey(iRecord);
57 
58  std::shared_ptr<ProxyFactoryBase> temp(iFactory.release());
59  FactoryInfo info(temp->makeKey(iLabel), temp);
60 
61  //has this already been registered?
62  std::pair<Record2Factories::const_iterator, Record2Factories::const_iterator> range =
63  record2Factories_.equal_range(iRecord);
64  if (range.second !=
65  std::find_if(range.first, range.second, [&info](const auto& r2f) { return r2f.second.key_ == info.key_; })) {
66  throw cms::Exception("IdenticalProducts")
67  << "Producer has been asked to produce " << info.key_.type().name() << " \"" << info.key_.name().value()
68  << "\" multiple times.\n Please modify the code.";
69  }
70 
72  }
73 
74 } // namespace edm
static const TGPicture * info(bool iBackgroundIsBlack)
void usingRecordWithKey(const EventSetupRecordKey &key)
virtual void registerFactoryWithKey(const EventSetupRecordKey &iRecord, std::unique_ptr< eventsetup::ProxyFactoryBase > iFactory, const std::string &iLabel=std::string())
KeyedProxiesVector registerProxies(const EventSetupRecordKey &, unsigned int iovIndex) override
assert(be >=bs)
~ESProxyFactoryProducer() noexcept(false) override
std::multimap< EventSetupRecordKey, eventsetup::FactoryInfo > record2Factories_
std::vector< std::pair< DataKey, std::shared_ptr< DataProxy > >> KeyedProxiesVector
std::multimap< EventSetupRecordKey, FactoryInfo > Record2Factories
HLT enums.
def move(src, dest)
Definition: eostools.py:511
def exit(msg="")