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 "boost/bind.hpp"
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  boost::bind(std::equal_to<DataKey>(),
104  boost::bind(&FactoryInfo::key_,
106  _1)),
107  info.key_)
108  ) ) {
109  throw cms::Exception("IdenticalProducts")<<"Producer has been asked to produce "<<info.key_.type().name()
110  <<" \""<<info.key_.name().value()<<"\" multiple times.\n Please modify the code.";
111  }
112 
114  std::move(info)));
115 }
116 
117 void
119  const ValidityInterval& /*iInterval*/)
120 {
121  invalidateProxies(iRecordType);
122 }
123 
124 //
125 // const member functions
126 //
127 
128 //
129 // static member functions
130 //
131 }
static const TGPicture * info(bool iBackgroundIsBlack)
virtual void registerProxies(const eventsetup::EventSetupRecordKey &iRecord, KeyedProxies &aProxyList)
override DataProxyProvider method
virtual ~ESProxyFactoryProducer() noexcept(false)
#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
U second(std::pair< T, U > const &p)
virtual void newInterval(const eventsetup::EventSetupRecordKey &iRecordType, const ValidityInterval &iInterval)
overrides DataProxyProvider method
void invalidateProxies(const EventSetupRecordKey &iRecordKey)
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.
def move(src, dest)
Definition: eostools.py:510