CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/FWCore/Framework/src/ESProxyFactoryProducer.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Framework
00004 // Class  :     ESProxyFactoryProducer
00005 // 
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Author:      Chris Jones
00010 // Created:     Thu Apr  7 21:36:15 CDT 2005
00011 //
00012 
00013 // system include files
00014 #include "boost/bind.hpp"
00015 // user include files
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 // constants, enums and typedefs
00024 //
00025 using namespace edm::eventsetup;
00026 namespace edm {
00027 
00028       typedef std::multimap< EventSetupRecordKey, FactoryInfo > Record2Factories;
00029 
00030 //
00031 // static data member definitions
00032 //
00033 
00034 //
00035 // constructors and destructor
00036 //
00037 ESProxyFactoryProducer::ESProxyFactoryProducer() : record2Factories_()
00038 {
00039 }
00040 
00041 // ESProxyFactoryProducer::ESProxyFactoryProducer(const ESProxyFactoryProducer& rhs)
00042 // {
00043 //    // do actual copying here;
00044 // }
00045 
00046 ESProxyFactoryProducer::~ESProxyFactoryProducer()
00047 {
00048 }
00049 
00050 //
00051 // assignment operators
00052 //
00053 // const ESProxyFactoryProducer& ESProxyFactoryProducer::operator=(const ESProxyFactoryProducer& rhs)
00054 // {
00055 //   //An exception safe implementation is
00056 //   ESProxyFactoryProducer temp(rhs);
00057 //   swap(rhs);
00058 //
00059 //   return *this;
00060 // }
00061 
00062 //
00063 // member functions
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    //has this already been registered?
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& /*iInterval*/)
00118 {
00119    invalidateProxies(iRecordType);
00120 }
00121 
00122 //
00123 // const member functions
00124 //
00125 
00126 //
00127 // static member functions
00128 //
00129 }