CMS 3D CMS Logo

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 <vector>
00024 #include <cassert>
00025 #include "boost/type_traits/is_base_and_derived.hpp"
00026 // user include files
00027 #include "FWCore/Framework/interface/IOVSyncValue.h"
00028 #include "FWCore/Framework/interface/EventSetupRecordKey.h"
00029 #include "FWCore/Framework/interface/HCMethods.h"
00030 #include "FWCore/Framework/interface/eventSetupGetImplementation.h"
00031 
00032 // forward declarations
00033 
00034 namespace edm {
00035    namespace eventsetup {
00036       class EventSetupProvider;
00037       class EventSetupRecord;
00038       template<class T> struct data_default_record_trait;
00039    }
00040 class EventSetup
00041 {
00043    friend class eventsetup::EventSetupProvider;
00044    public:
00045       virtual ~EventSetup();
00046 
00047       // ---------- const member functions ---------------------
00050       template< typename T>
00051          const T& get() const {
00052             //NOTE: this will catch the case where T does not inherit from EventSetupRecord
00053             //  HOWEVER the error message under gcc 3.x is awful
00054             BOOST_STATIC_ASSERT((boost::is_base_and_derived<edm::eventsetup::EventSetupRecord, T>::value));
00055             const T* value = 0;
00056             eventSetupGetImplementation(*this, value);
00057             //NOTE: by construction, eventSetupGetImplementation should thrown an exception rather than return a null value
00058             assert(0 != value);
00059             return *value;
00060          }
00062       template< typename T>
00063          void getData(T& iHolder) const {
00064             typedef typename T::value_type data_type;
00065             typedef typename eventsetup::data_default_record_trait<data_type>::type RecordT;
00066             const RecordT& rec = this->get<RecordT>();
00067             rec.get(iHolder);
00068          }
00069       template< typename T>
00070          void getData(const std::string& iLabel, T& iHolder) const {
00071             typedef typename T::value_type data_type;
00072             typedef typename eventsetup::data_default_record_trait<data_type>::type RecordT;
00073             const RecordT& rec = this->get<RecordT>();
00074             rec.get(iLabel,iHolder);
00075          }
00076       
00077       const IOVSyncValue& iovSyncValue() const { return syncValue_;}
00078 
00079       const eventsetup::EventSetupRecord* find(const eventsetup::EventSetupRecordKey&) const;
00080       
00082       void fillAvailableRecordKeys(std::vector<eventsetup::EventSetupRecordKey>& oToFill) const;
00083       
00084       // ---------- static member functions --------------------
00085 
00086       // ---------- member functions ---------------------------
00087       template< typename T>
00088          void
00089          getAvoidCompilerBug(const T*& iValue) const {
00090             iValue = &(get<T>());
00091          }
00092    protected:
00093       //Only called by EventSetupProvider
00094       void setIOVSyncValue(const IOVSyncValue&);
00095 
00096       template<typename T>
00097          void add(const T& iRecord) {
00098             insert(eventsetup::heterocontainer::makeKey<T, eventsetup::EventSetupRecordKey>(), &iRecord);
00099          }
00100       
00101       void clear();
00102       
00103    private:
00104       EventSetup();
00105       
00106       EventSetup(EventSetup const&); // stop default
00107 
00108       EventSetup const& operator=(EventSetup const&); // stop default
00109 
00110       void insert(const eventsetup::EventSetupRecordKey&,
00111                   const eventsetup::EventSetupRecord*);
00112 
00113       // ---------- member data --------------------------------
00114       IOVSyncValue syncValue_;
00115       
00116       //NOTE: the records are not owned
00117       std::map<eventsetup::EventSetupRecordKey, eventsetup::EventSetupRecord const *> recordMap_;
00118 };
00119 
00120 }
00121 #endif

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