CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/FWCore/Framework/src/DataProxyProvider.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Framework
00004 // Class  :     DataProxyProvider
00005 // 
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Author:      Chris Jones
00010 // Created:     Mon Mar 28 15:07:54 EST 2005
00011 //
00012 
00013 // system include files
00014 
00015 // user include files
00016 #include "FWCore/Framework/interface/DataProxyProvider.h"
00017 #include "FWCore/Framework/interface/DataProxy.h"
00018 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00019 
00020 namespace edm {
00021    namespace eventsetup {
00022 //
00023 // constants, enums and typedefs
00024 //
00025 
00026 //
00027 // static data member definitions
00028 //
00029 
00030 //
00031 // constructors and destructor
00032 //
00033 DataProxyProvider::DataProxyProvider() : recordProxies_(), description_()
00034 {
00035 }
00036 
00037 // DataProxyProvider::DataProxyProvider(const DataProxyProvider& rhs)
00038 // {
00039 //    // do actual copying here;
00040 // }
00041 
00042 DataProxyProvider::~DataProxyProvider()
00043 {
00044 }
00045 
00046 //
00047 // assignment operators
00048 //
00049 // const DataProxyProvider& DataProxyProvider::operator=(const DataProxyProvider& rhs)
00050 // {
00051 //   //An exception safe implementation is
00052 //   DataProxyProvider temp(rhs);
00053 //   swap(rhs);
00054 //
00055 //   return *this;
00056 // }
00057 
00058 //
00059 // member functions
00060 //
00061 void 
00062 DataProxyProvider::usingRecordWithKey(const EventSetupRecordKey& iKey)
00063 {
00064    recordProxies_[iKey];
00065    //keys_.push_back(iKey);
00066 }
00067 
00068 void 
00069 DataProxyProvider::invalidateProxies(const EventSetupRecordKey& iRecordKey) 
00070 {
00071    KeyedProxies& proxyList((*(recordProxies_.find(iRecordKey))).second) ;
00072    KeyedProxies::iterator finished(proxyList.end()) ;
00073    for (KeyedProxies::iterator keyedProxy(proxyList.begin()) ;
00074          keyedProxy != finished ;
00075          ++keyedProxy) {
00076       (*((*keyedProxy).second)).invalidate() ;
00077    }
00078    
00079 }
00080 
00081 void 
00082 DataProxyProvider::resetProxies(const EventSetupRecordKey& iRecordKey)
00083 {
00084   invalidateProxies(iRecordKey);
00085 }
00086       
00087 void 
00088 DataProxyProvider::resetProxiesIfTransient(const EventSetupRecordKey& iRecordKey) 
00089 {
00090    KeyedProxies& proxyList((*(recordProxies_.find(iRecordKey))).second) ;
00091    KeyedProxies::iterator finished(proxyList.end()) ;
00092    for (KeyedProxies::iterator keyedProxy(proxyList.begin()) ;
00093         keyedProxy != finished ;
00094         ++keyedProxy) {
00095       (*((*keyedProxy).second)).resetIfTransient() ;
00096    }
00097    
00098 }
00099       
00100 void
00101 DataProxyProvider::setAppendToDataLabel(const edm::ParameterSet& iToAppend)
00102 {
00103   std::string oldValue( appendToDataLabel_);
00104   //this can only be changed once and the default value is the empty string
00105   assert(0 == oldValue.size());
00106   
00107   const std::string kParamName("appendToDataLabel");
00108   if(iToAppend.exists(kParamName) ) {    
00109     appendToDataLabel_ = iToAppend.getParameter<std::string>(kParamName);
00110   }
00111 }
00112 //
00113 // const member functions
00114 //
00115 bool 
00116 DataProxyProvider::isUsingRecord(const EventSetupRecordKey& iKey) const
00117 {
00118    return recordProxies_.end() != recordProxies_.find(iKey);
00119 }
00120 
00121 std::set<EventSetupRecordKey> 
00122 DataProxyProvider::usingRecords() const
00123 {
00124    std::set<EventSetupRecordKey> returnValue;
00125    for(RecordProxies::const_iterator itRecProxies = recordProxies_.begin(),
00126         itRecProxiesEnd = recordProxies_.end();
00127         itRecProxies != itRecProxiesEnd;
00128         ++itRecProxies) {
00129       returnValue.insert(returnValue.end(), itRecProxies->first);
00130    }
00131    //copy_all(keys_, std::inserter(returnValue, returnValue.end()));
00132    return returnValue;
00133 }   
00134 
00135 const DataProxyProvider::KeyedProxies& 
00136 DataProxyProvider::keyedProxies(const EventSetupRecordKey& iRecordKey) const
00137 {
00138    RecordProxies::const_iterator itFind = recordProxies_.find(iRecordKey);
00139    assert(itFind != recordProxies_.end());
00140    
00141    if(itFind->second.empty()) {
00142       //delayed registration
00143       KeyedProxies& proxies = const_cast<KeyedProxies&>(itFind->second);
00144       const_cast<DataProxyProvider*>(this)->registerProxies(iRecordKey,
00145                                                             proxies);
00146 
00147       bool mustChangeLabels = (0 != appendToDataLabel_.size());
00148       for(KeyedProxies::iterator itProxy = proxies.begin(), itProxyEnd = proxies.end();
00149           itProxy != itProxyEnd;
00150           ++itProxy) {
00151         itProxy->second->setProviderDescription(&description());
00152         if( mustChangeLabels ) {
00153           //Using swap is fine since
00154           // 1) the data structure is not a map and so we have not sorted on the keys
00155           // 2) this is the first time filling this so no outside agency has yet seen
00156           //   the label and therefore can not be dependent upon its value
00157           std::string temp(std::string(itProxy->first.name().value())+appendToDataLabel_);
00158           DataKey newKey(itProxy->first.type(),temp.c_str());
00159           swap(itProxy->first,newKey);
00160         }
00161       }
00162    }
00163    
00164    return itFind->second;
00165 }
00166 
00167 //
00168 // static member functions
00169 //
00170    }
00171 }
00172