CMS 3D CMS Logo

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 // $Id: ESProxyFactoryProducer.cc,v 1.3 2006/09/01 18:16:42 wmtan Exp $
00012 //
00013 
00014 // system include files
00015 #include "boost/bind.hpp"
00016 // user include files
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 // constants, enums and typedefs
00025 //
00026 using namespace edm::eventsetup;
00027 namespace edm {
00028 
00029       typedef std::multimap< EventSetupRecordKey, FactoryInfo > Record2Factories;
00030 
00031 //
00032 // static data member definitions
00033 //
00034 
00035 //
00036 // constructors and destructor
00037 //
00038 ESProxyFactoryProducer::ESProxyFactoryProducer() : record2Factories_()
00039 {
00040 }
00041 
00042 // ESProxyFactoryProducer::ESProxyFactoryProducer(const ESProxyFactoryProducer& rhs)
00043 // {
00044 //    // do actual copying here;
00045 // }
00046 
00047 ESProxyFactoryProducer::~ESProxyFactoryProducer()
00048 {
00049 }
00050 
00051 //
00052 // assignment operators
00053 //
00054 // const ESProxyFactoryProducer& ESProxyFactoryProducer::operator=(const ESProxyFactoryProducer& rhs)
00055 // {
00056 //   //An exception safe implementation is
00057 //   ESProxyFactoryProducer temp(rhs);
00058 //   swap(rhs);
00059 //
00060 //   return *this;
00061 // }
00062 
00063 //
00064 // member functions
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    //has this already been registered?
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& /*iInterval*/)
00119 {
00120    invalidateProxies(iRecordType);
00121 }
00122 
00123 //
00124 // const member functions
00125 //
00126 
00127 //
00128 // static member functions
00129 //
00130 }

Generated on Tue Jun 9 17:35:58 2009 for CMSSW by  doxygen 1.5.4