00001 #ifndef Framework_DataProxyProvider_h 00002 #define Framework_DataProxyProvider_h 00003 // -*- C++ -*- 00004 // 00005 // Package: Framework 00006 // Class : DataProxyProvider 00007 // 00016 // 00017 // Author: Chris Jones 00018 // Created: Mon Mar 28 14:21:58 EST 2005 00019 // 00020 00021 // system include files 00022 #include <map> 00023 #include <set> 00024 #include <string> 00025 #include <vector> 00026 #include "boost/shared_ptr.hpp" 00027 00028 // user include files 00029 #include "FWCore/Framework/interface/EventSetupRecordKey.h" 00030 #include "FWCore/Framework/interface/DataKey.h" 00031 #include "FWCore/Framework/interface/ComponentDescription.h" 00032 00033 // forward declarations 00034 namespace edm { 00035 class ValidityInterval; 00036 class ParameterSet; 00037 namespace eventsetup { 00038 class DataProxy; 00039 00040 00041 class DataProxyProvider 00042 { 00043 00044 public: 00045 typedef std::vector< EventSetupRecordKey> Keys; 00046 typedef std::vector<std::pair<DataKey, 00047 boost::shared_ptr<DataProxy> > > KeyedProxies ; 00048 typedef std::map<EventSetupRecordKey, KeyedProxies> RecordProxies; 00049 00050 DataProxyProvider(); 00051 virtual ~DataProxyProvider(); 00052 00053 // ---------- const member functions --------------------- 00054 bool isUsingRecord(const EventSetupRecordKey&) const; 00055 00056 std::set<EventSetupRecordKey> usingRecords() const; 00057 00058 const KeyedProxies& keyedProxies(const EventSetupRecordKey& iRecordKey) const ; 00059 00060 const ComponentDescription& description() const { return description_;} 00061 // ---------- static member functions -------------------- 00062 00063 // ---------- member functions --------------------------- 00064 00066 virtual void newInterval(const EventSetupRecordKey& iRecordType, 00067 const ValidityInterval& iInterval) = 0; 00068 00069 void setDescription(const ComponentDescription& iDescription) { 00070 description_ = iDescription; 00071 } 00072 00076 void setAppendToDataLabel(const edm::ParameterSet&); 00077 00078 void resetProxies(const EventSetupRecordKey& iRecordType); 00079 void resetProxiesIfTransient(const EventSetupRecordKey& iRecordType); 00080 00081 protected: 00082 template< class T> 00083 void usingRecord() { 00084 usingRecordWithKey(EventSetupRecordKey::makeKey<T>()); 00085 } 00086 00087 void usingRecordWithKey(const EventSetupRecordKey&); 00088 00089 void invalidateProxies(const EventSetupRecordKey& iRecordKey) ; 00090 00091 virtual void registerProxies(const EventSetupRecordKey& iRecordKey , 00092 KeyedProxies& aProxyList) = 0 ; 00093 00095 void eraseAll(const EventSetupRecordKey& iRecordKey) ; 00096 00097 private: 00098 DataProxyProvider(const DataProxyProvider&); // stop default 00099 00100 const DataProxyProvider& operator=(const DataProxyProvider&); // stop default 00101 00102 // ---------- member data -------------------------------- 00103 RecordProxies recordProxies_; 00104 ComponentDescription description_; 00105 std::string appendToDataLabel_; 00106 }; 00107 00108 template<class ProxyT> 00109 inline void insertProxy(DataProxyProvider::KeyedProxies& iList, 00110 boost::shared_ptr<ProxyT> iProxy, 00111 const char* iName="") { 00112 iList.push_back(DataProxyProvider::KeyedProxies::value_type( 00113 DataKey(DataKey::makeTypeTag<typename ProxyT::value_type>(), 00114 iName), 00115 iProxy)); 00116 00117 } 00118 00119 } 00120 } 00121 #endif