CMS 3D CMS Logo

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::setAppendToDataLabel(const edm::ParameterSet& iToAppend)
00089 {
00090   std::string oldValue( appendToDataLabel_);
00091   //this can only be changed once and the default value is the empty string
00092   assert(0 == oldValue.size());
00093   
00094   const std::string kParamName("appendToDataLabel");
00095   if(iToAppend.exists(kParamName) ) {    
00096     appendToDataLabel_ = iToAppend.getParameter<std::string>(kParamName);
00097   }
00098 }
00099 //
00100 // const member functions
00101 //
00102 bool 
00103 DataProxyProvider::isUsingRecord(const EventSetupRecordKey& iKey) const
00104 {
00105    return recordProxies_.end() != recordProxies_.find(iKey);
00106 }
00107 
00108 std::set<EventSetupRecordKey> 
00109 DataProxyProvider::usingRecords() const
00110 {
00111    std::set<EventSetupRecordKey> returnValue;
00112    for(RecordProxies::const_iterator itRecProxies = recordProxies_.begin(),
00113         itRecProxiesEnd = recordProxies_.end();
00114         itRecProxies != itRecProxiesEnd;
00115         ++itRecProxies) {
00116       returnValue.insert(returnValue.end(), itRecProxies->first);
00117    }
00118    //copy_all(keys_, std::inserter(returnValue, returnValue.end()));
00119    return returnValue;
00120 }   
00121 
00122 const DataProxyProvider::KeyedProxies& 
00123 DataProxyProvider::keyedProxies(const EventSetupRecordKey& iRecordKey) const
00124 {
00125    RecordProxies::const_iterator itFind = recordProxies_.find(iRecordKey);
00126    assert(itFind != recordProxies_.end());
00127    
00128    if(itFind->second.empty()) {
00129       //delayed registration
00130       KeyedProxies& proxies = const_cast<KeyedProxies&>(itFind->second);
00131       const_cast<DataProxyProvider*>(this)->registerProxies(iRecordKey,
00132                                                             proxies);
00133 
00134       bool mustChangeLabels = (0 != appendToDataLabel_.size());
00135       for(KeyedProxies::iterator itProxy = proxies.begin(), itProxyEnd = proxies.end();
00136           itProxy != itProxyEnd;
00137           ++itProxy) {
00138         itProxy->second->setProviderDescription(&description());
00139         if( mustChangeLabels ) {
00140           //Using swap is fine since
00141           // 1) the data structure is not a map and so we have not sorted on the keys
00142           // 2) this is the first time filling this so no outside agency has yet seen
00143           //   the label and therefore can not be dependent upon its value
00144           std::string temp(std::string(itProxy->first.name().value())+appendToDataLabel_);
00145           DataKey newKey(itProxy->first.type(),temp.c_str());
00146           swap(itProxy->first,newKey);
00147         }
00148       }
00149    }
00150    
00151    return itFind->second;
00152 }
00153 
00154 //
00155 // static member functions
00156 //
00157    }
00158 }
00159 

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