CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 //
23 // constants, enums and typedefs
24 //
25 using namespace edm::eventsetup;
26 namespace edm {
27 
28  typedef std::multimap< EventSetupRecordKey, FactoryInfo > Record2Factories;
29 
30 //
31 // static data member definitions
32 //
33 
34 //
35 // constructors and destructor
36 //
38 {
39 }
40 
41 // ESProxyFactoryProducer::ESProxyFactoryProducer(const ESProxyFactoryProducer& rhs)
42 // {
43 // // do actual copying here;
44 // }
45 
47 {
48 }
49 
50 //
51 // assignment operators
52 //
53 // const ESProxyFactoryProducer& ESProxyFactoryProducer::operator=(const ESProxyFactoryProducer& rhs)
54 // {
55 // //An exception safe implementation is
56 // ESProxyFactoryProducer temp(rhs);
57 // swap(rhs);
58 //
59 // return *this;
60 // }
61 
62 //
63 // member functions
64 //
65 void
67  KeyedProxies& iProxies)
68 {
69  typedef Record2Factories::iterator Iterator;
70  std::pair< Iterator, Iterator > range = record2Factories_.equal_range(iRecord);
71  for(Iterator it = range.first; it != range.second; ++it) {
72 
73  boost::shared_ptr<DataProxy> proxy(it->second.factory_->makeProxy().release());
74  if(0 != proxy.get()) {
75  iProxies.push_back(KeyedProxies::value_type((*it).second.key_,
76  proxy));
77  }
78  }
79 }
80 
81 void
83  std::auto_ptr<ProxyFactoryBase>& iFactory,
84  const std::string& iLabel )
85 {
86  if(0 == iFactory.get()) {
87  assert(false && "Factor pointer was null");
88  ::exit(1);
89  }
90 
91  usingRecordWithKey(iRecord);
92 
93  boost::shared_ptr<ProxyFactoryBase> temp(iFactory.release());
94  FactoryInfo info(temp->makeKey(iLabel),
95  temp);
96 
97  //has this already been registered?
98  std::pair<Record2Factories::const_iterator,Record2Factories::const_iterator> range =
99  record2Factories_.equal_range(iRecord);
100  if(range.second != std::find_if(range.first,range.second,
101  boost::bind(std::equal_to<DataKey>(),
102  boost::bind(&FactoryInfo::key_,
104  _1)),
105  info.key_)
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  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 }
virtual void registerProxies(const eventsetup::EventSetupRecordKey &iRecord, KeyedProxies &aProxyList)
override DataProxyProvider method
void usingRecordWithKey(const EventSetupRecordKey &)
std::multimap< eventsetup::EventSetupRecordKey, eventsetup::FactoryInfo > record2Factories_
virtual void registerFactoryWithKey(const eventsetup::EventSetupRecordKey &iRecord, std::auto_ptr< eventsetup::ProxyFactoryBase > &iFactory, const std::string &iLabel=std::string())
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::vector< std::pair< DataKey, boost::shared_ptr< DataProxy > > > KeyedProxies
Container::value_type value_type
std::multimap< EventSetupRecordKey, FactoryInfo > Record2Factories