CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/FWCore/Framework/interface/EventSetupRecord.h

Go to the documentation of this file.
00001 #ifndef FWCore_Framework_EventSetupRecord_h
00002 #define FWCore_Framework_EventSetupRecord_h
00003 // -*- C++ -*-
00004 //
00005 // Package:     Framework
00006 // Class  :     EventSetupRecord
00007 //
00045 //
00046 // Author:      Chris Jones
00047 // Created:     Fri Mar 25 14:38:35 EST 2005
00048 //
00049 
00050 
00051 // user include files
00052 #include "FWCore/Framework/interface/DataKey.h"
00053 #include "FWCore/Framework/interface/NoProxyException.h"
00054 #include "FWCore/Framework/interface/ValidityInterval.h"
00055 #include "FWCore/Utilities/interface/ESInputTag.h"
00056 
00057 // system include files
00058 #include <map>
00059 #include <vector>
00060 
00061 // forward declarations
00062 namespace cms {
00063    class Exception;
00064 }
00065 
00066 namespace edm {
00067    class ESInputTag;
00068    class EventSetup;
00069 
00070    namespace eventsetup {
00071       struct ComponentDescription;
00072       class DataProxy;
00073       class EventSetupRecordKey;
00074 
00075       class EventSetupRecord {
00076 
00077       public:
00078          EventSetupRecord();
00079          virtual ~EventSetupRecord();
00080 
00081          // ---------- const member functions ---------------------
00082          ValidityInterval const& validityInterval() const {
00083             return validity_;
00084          }
00085 
00086          template<typename HolderT>
00087          void get(HolderT& iHolder) const {
00088             typename HolderT::value_type const* value = 0;
00089             ComponentDescription const* desc = 0;
00090             this->getImplementation(value, "", desc, iHolder.transientAccessOnly);
00091 
00092             iHolder = HolderT(value, desc);
00093          }
00094 
00095          template<typename HolderT>
00096          void get(char const* iName, HolderT& iHolder) const {
00097             typename HolderT::value_type const* value = 0;
00098             ComponentDescription const* desc = 0;
00099             this->getImplementation(value, iName, desc, iHolder.transientAccessOnly);
00100             iHolder = HolderT(value, desc);
00101          }
00102          template<typename HolderT>
00103          void get(std::string const& iName, HolderT& iHolder) const {
00104             typename HolderT::value_type const* value = 0;
00105             ComponentDescription const* desc = 0;
00106             this->getImplementation(value, iName.c_str(), desc, iHolder.transientAccessOnly);
00107             iHolder = HolderT(value, desc);
00108          }
00109 
00110          template<typename HolderT>
00111          void get(ESInputTag const& iTag, HolderT& iHolder) const {
00112             typename HolderT::value_type const* value = 0;
00113             ComponentDescription const* desc = 0;
00114             this->getImplementation(value, iTag.data().c_str(), desc, iHolder.transientAccessOnly);
00115             validate(desc, iTag);
00116             iHolder = HolderT(value, desc);
00117          }
00118 
00119 
00120 
00122          bool doGet(DataKey const& aKey, bool aGetTransiently = false) const;
00123 
00127          bool wasGotten(DataKey const& aKey) const;
00128 
00133          ComponentDescription const* providerDescription(DataKey const& aKey) const;
00134 
00135          virtual EventSetupRecordKey key() const = 0;
00136 
00147          unsigned long long cacheIdentifier() const {
00148             return cacheIdentifier_;
00149          }
00150 
00152          void fillRegisteredDataKeys(std::vector<DataKey>& oToFill) const;
00153          // ---------- static member functions --------------------
00154 
00155          // ---------- member functions ---------------------------
00156 
00157          // The following member functions should only be used by EventSetupRecordProvider
00158          bool add(DataKey const& iKey ,
00159                   DataProxy const* iProxy) ;
00160          void cacheReset() ;
00162          bool transientReset() ;
00163          void set(ValidityInterval const&);
00164          void setEventSetup(EventSetup const* iEventSetup) {eventSetup_ = iEventSetup; }
00165       protected:
00166 
00167          DataProxy const* find(DataKey const& aKey) const ;
00168 
00169          EventSetup const& eventSetup() const {
00170             return *eventSetup_;
00171          }
00172 
00173          void validate(ComponentDescription const*, ESInputTag const&) const;
00174 
00175          void addTraceInfoToCmsException(cms::Exception& iException, char const* iName, ComponentDescription const*, DataKey const&) const;
00176          void changeStdExceptionToCmsException(char const* iExceptionWhatMessage, char const* iName, ComponentDescription const*, DataKey const&) const;
00177 
00178          void transientAccessRequested() const { transientAccessRequested_ = true;}
00179       private:
00180          EventSetupRecord(EventSetupRecord const&); // stop default
00181 
00182          EventSetupRecord const& operator=(EventSetupRecord const&); // stop default
00183 
00184          void const* getFromProxy(DataKey const& iKey ,
00185                                   ComponentDescription const*& iDesc,
00186                                   bool iTransientAccessOnly) const;
00187 
00188          template <typename DataT>
00189          void getImplementation(DataT const*& iData ,
00190                                 char const* iName,
00191                                 ComponentDescription const*& iDesc,
00192                                 bool iTransientAccessOnly) const {
00193             DataKey dataKey(DataKey::makeTypeTag<DataT>(),
00194                             iName,
00195                             DataKey::kDoNotCopyMemory);
00196 
00197             void const* pValue = this->getFromProxy(dataKey, iDesc, iTransientAccessOnly);
00198             if(0 == pValue) {
00199                throw NoProxyException<DataT>(this->key(), dataKey);
00200             }
00201             iData = reinterpret_cast<DataT const*> (pValue);
00202          }
00203 
00204          // ---------- member data --------------------------------
00205          ValidityInterval validity_;
00206          std::map<DataKey, DataProxy const*> proxies_ ;
00207          EventSetup const* eventSetup_;
00208          unsigned long long cacheIdentifier_;
00209          mutable bool transientAccessRequested_;
00210       };
00211    }
00212 }
00213 #endif