test
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 #include <cassert>
23 //
24 // constants, enums and typedefs
25 //
26 using namespace edm::eventsetup;
27 namespace edm {
28 
29  typedef std::multimap< EventSetupRecordKey, FactoryInfo > Record2Factories;
30 
31 //
32 // static data member definitions
33 //
34 
35 //
36 // constructors and destructor
37 //
39 {
40 }
41 
42 // ESProxyFactoryProducer::ESProxyFactoryProducer(const ESProxyFactoryProducer& rhs)
43 // {
44 // // do actual copying here;
45 // }
46 
48 {
49 }
50 
51 //
52 // assignment operators
53 //
54 // const ESProxyFactoryProducer& ESProxyFactoryProducer::operator=(const ESProxyFactoryProducer& rhs)
55 // {
56 // //An exception safe implementation is
57 // ESProxyFactoryProducer temp(rhs);
58 // swap(rhs);
59 //
60 // return *this;
61 // }
62 
63 //
64 // member functions
65 //
66 void
68  KeyedProxies& iProxies)
69 {
70  typedef Record2Factories::iterator Iterator;
71  std::pair< Iterator, Iterator > range = record2Factories_.equal_range(iRecord);
72  for(Iterator it = range.first; it != range.second; ++it) {
73 
74  boost::shared_ptr<DataProxy> proxy(it->second.factory_->makeProxy().release());
75  if(0 != proxy.get()) {
76  iProxies.push_back(KeyedProxies::value_type((*it).second.key_,
77  proxy));
78  }
79  }
80 }
81 
82 void
84  std::auto_ptr<ProxyFactoryBase>& iFactory,
85  const std::string& iLabel )
86 {
87  if(0 == iFactory.get()) {
88  assert(false && "Factor pointer was null");
89  ::exit(1);
90  }
91 
92  usingRecordWithKey(iRecord);
93 
94  boost::shared_ptr<ProxyFactoryBase> temp(iFactory.release());
95  FactoryInfo info(temp->makeKey(iLabel),
96  temp);
97 
98  //has this already been registered?
99  std::pair<Record2Factories::const_iterator,Record2Factories::const_iterator> range =
100  record2Factories_.equal_range(iRecord);
101  if(range.second != std::find_if(range.first,range.second,
102  boost::bind(std::equal_to<DataKey>(),
103  boost::bind(&FactoryInfo::key_,
105  _1)),
106  info.key_)
107  ) ) {
108  throw cms::Exception("IdenticalProducts")<<"Producer has been asked to produce "<<info.key_.type().name()
109  <<" \""<<info.key_.name().value()<<"\" multiple times.\n Please modify the code.";
110  }
111 
113  info));
114 }
115 
116 void
118  const ValidityInterval& /*iInterval*/)
119 {
120  invalidateProxies(iRecordType);
121 }
122 
123 //
124 // const member functions
125 //
126 
127 //
128 // static member functions
129 //
130 }
static const TGPicture * info(bool iBackgroundIsBlack)
virtual void registerProxies(const eventsetup::EventSetupRecordKey &iRecord, KeyedProxies &aProxyList)
override DataProxyProvider method
assert(m_qm.get())
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