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