CMS 3D CMS Logo

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

Go to the documentation of this file.
00001 #ifndef FWCore_Framework_EventSetup_h
00002 #define FWCore_Framework_EventSetup_h
00003 // -*- C++ -*-
00004 //
00005 // Package:     Framework
00006 // Class:      EventSetup
00007 // 
00016 //
00017 // Author:      Chris Jones
00018 // Created:     Thu Mar 24 13:50:04 EST 2005
00019 //
00020 
00021 // system include files
00022 #include <map>
00023 #include <string>
00024 #include <vector>
00025 #include <cassert>
00026 #include "boost/type_traits/is_base_and_derived.hpp"
00027 #include "boost/static_assert.hpp"
00028 // user include files
00029 #include "FWCore/Framework/interface/IOVSyncValue.h"
00030 #include "FWCore/Framework/interface/EventSetupRecordKey.h"
00031 #include "FWCore/Framework/interface/HCMethods.h"
00032 #include "FWCore/Framework/interface/eventSetupGetImplementation.h"
00033 
00034 // forward declarations
00035 
00036 namespace edm {
00037    class ESInputTag;
00038    
00039    namespace eventsetup {
00040       class EventSetupProvider;
00041       class EventSetupRecord;
00042       template<class T> struct data_default_record_trait;
00043    }
00044 class EventSetup
00045 {
00047    friend class eventsetup::EventSetupProvider;
00048    public:
00049       virtual ~EventSetup();
00050 
00051       // ---------- const member functions ---------------------
00054       template< typename T>
00055          const T& get() const {
00056             //NOTE: this will catch the case where T does not inherit from EventSetupRecord
00057             //  HOWEVER the error message under gcc 3.x is awful
00058             BOOST_STATIC_ASSERT((boost::is_base_and_derived<edm::eventsetup::EventSetupRecord, T>::value));
00059             const T* value = 0;
00060             eventSetupGetImplementation(*this, value);
00061             //NOTE: by construction, eventSetupGetImplementation should thrown an exception rather than return a null value
00062             assert(0 != value);
00063             return *value;
00064          }
00066       template< typename T>
00067          void getData(T& iHolder) const {
00068             typedef typename T::value_type data_type;
00069             typedef typename eventsetup::data_default_record_trait<data_type>::type RecordT;
00070             const RecordT& rec = this->get<RecordT>();
00071             rec.get(iHolder);
00072          }
00073       template< typename T>
00074          void getData(const std::string& iLabel, T& iHolder) const {
00075             typedef typename T::value_type data_type;
00076             typedef typename eventsetup::data_default_record_trait<data_type>::type RecordT;
00077             const RecordT& rec = this->get<RecordT>();
00078             rec.get(iLabel,iHolder);
00079          }
00080 
00081       template< typename T>
00082         void getData(const edm::ESInputTag& iTag, T& iHolder) const {
00083            typedef typename T::value_type data_type;
00084            typedef typename eventsetup::data_default_record_trait<data_type>::type RecordT;
00085            const RecordT& rec = this->get<RecordT>();
00086            rec.get(iTag,iHolder);
00087         }
00088    
00089       const IOVSyncValue& iovSyncValue() const { return syncValue_;}
00090 
00091       const eventsetup::EventSetupRecord* find(const eventsetup::EventSetupRecordKey&) const;
00092       
00094       void fillAvailableRecordKeys(std::vector<eventsetup::EventSetupRecordKey>& oToFill) const;
00095       
00096       // ---------- static member functions --------------------
00097 
00098       // ---------- member functions ---------------------------
00099       template< typename T>
00100          void
00101          getAvoidCompilerBug(const T*& iValue) const {
00102             iValue = &(get<T>());
00103          }
00104    protected:
00105       //Only called by EventSetupProvider
00106       void setIOVSyncValue(const IOVSyncValue&);
00107 
00108       void add(const eventsetup::EventSetupRecord& iRecord);
00109       
00110       void clear();
00111       
00112    private:
00113       EventSetup();
00114       
00115       EventSetup(EventSetup const&); // stop default
00116 
00117       EventSetup const& operator=(EventSetup const&); // stop default
00118 
00119       void insert(const eventsetup::EventSetupRecordKey&,
00120                   const eventsetup::EventSetupRecord*);
00121 
00122       // ---------- member data --------------------------------
00123       IOVSyncValue syncValue_;
00124       
00125       //NOTE: the records are not owned
00126       std::map<eventsetup::EventSetupRecordKey, eventsetup::EventSetupRecord const *> recordMap_;
00127 };
00128 
00129 }
00130 #endif