Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "boost/bind.hpp"
00015
00016 #include "FWCore/Framework/interface/ESProxyFactoryProducer.h"
00017 #include "FWCore/Framework/interface/ProxyFactoryBase.h"
00018
00019 #include "FWCore/Framework/interface/DataProxy.h"
00020
00021 #include "FWCore/Utilities/interface/Exception.h"
00022
00023
00024
00025 using namespace edm::eventsetup;
00026 namespace edm {
00027
00028 typedef std::multimap< EventSetupRecordKey, FactoryInfo > Record2Factories;
00029
00030
00031
00032
00033
00034
00035
00036
00037 ESProxyFactoryProducer::ESProxyFactoryProducer() : record2Factories_()
00038 {
00039 }
00040
00041
00042
00043
00044
00045
00046 ESProxyFactoryProducer::~ESProxyFactoryProducer()
00047 {
00048 }
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 void
00066 ESProxyFactoryProducer::registerProxies(const EventSetupRecordKey& iRecord,
00067 KeyedProxies& iProxies)
00068 {
00069 typedef Record2Factories::iterator Iterator;
00070 std::pair< Iterator, Iterator > range = record2Factories_.equal_range(iRecord);
00071 for(Iterator it = range.first; it != range.second; ++it) {
00072
00073 boost::shared_ptr<DataProxy> proxy(it->second.factory_->makeProxy().release());
00074 if(0 != proxy.get()) {
00075 iProxies.push_back(KeyedProxies::value_type((*it).second.key_,
00076 proxy));
00077 }
00078 }
00079 }
00080
00081 void
00082 ESProxyFactoryProducer::registerFactoryWithKey(const EventSetupRecordKey& iRecord ,
00083 std::auto_ptr<ProxyFactoryBase>& iFactory,
00084 const std::string& iLabel )
00085 {
00086 if(0 == iFactory.get()) {
00087 assert(false && "Factor pointer was null");
00088 ::exit(1);
00089 }
00090
00091 usingRecordWithKey(iRecord);
00092
00093 boost::shared_ptr<ProxyFactoryBase> temp(iFactory.release());
00094 FactoryInfo info(temp->makeKey(iLabel),
00095 temp);
00096
00097
00098 std::pair<Record2Factories::const_iterator,Record2Factories::const_iterator> range =
00099 record2Factories_.equal_range(iRecord);
00100 if(range.second != std::find_if(range.first,range.second,
00101 boost::bind(std::equal_to<DataKey>(),
00102 boost::bind(&FactoryInfo::key_,
00103 boost::bind(&Record2Factories::value_type::second,
00104 _1)),
00105 info.key_)
00106 ) ) {
00107 throw cms::Exception("IdenticalProducts")<<"Producer has been asked to produce "<<info.key_.type().name()
00108 <<" \""<<info.key_.name().value()<<"\" multiple times.\n Please modify the code.";
00109 }
00110
00111 record2Factories_.insert(Record2Factories::value_type(iRecord,
00112 info));
00113 }
00114
00115 void
00116 ESProxyFactoryProducer::newInterval(const EventSetupRecordKey& iRecordType,
00117 const ValidityInterval& )
00118 {
00119 invalidateProxies(iRecordType);
00120 }
00121
00122
00123
00124
00125
00126
00127
00128
00129 }