CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EventSetup.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_EventSetup_h
2 #define FWCore_Framework_EventSetup_h
3 // -*- C++ -*-
4 //
5 // Package: Framework
6 // Class: EventSetup
7 //
16 //
17 // Author: Chris Jones
18 // Created: Thu Mar 24 13:50:04 EST 2005
19 //
20 
21 // system include files
22 #include <map>
23 #include <string>
24 #include <vector>
25 #include <cassert>
26 #include "boost/type_traits/is_base_and_derived.hpp"
27 #include "boost/static_assert.hpp"
28 // user include files
33 
34 // forward declarations
35 
36 namespace edm {
37  class ESInputTag;
38 
39  namespace eventsetup {
40  class EventSetupProvider;
41  class EventSetupRecord;
42  template<class T> struct data_default_record_trait;
43  }
45 {
48  public:
49  virtual ~EventSetup();
50 
51  // ---------- const member functions ---------------------
54  template< typename T>
55  const T& get() const {
56  //NOTE: this will catch the case where T does not inherit from EventSetupRecord
57  // HOWEVER the error message under gcc 3.x is awful
59  const T* value = 0;
60  eventSetupGetImplementation(*this, value);
61  //NOTE: by construction, eventSetupGetImplementation should thrown an exception rather than return a null value
62  assert(0 != value);
63  return *value;
64  }
66  template< typename T>
67  void getData(T& iHolder) const {
68  typedef typename T::value_type data_type;
70  const RecordT& rec = this->get<RecordT>();
71  rec.get(iHolder);
72  }
73  template< typename T>
74  void getData(const std::string& iLabel, T& iHolder) const {
75  typedef typename T::value_type data_type;
77  const RecordT& rec = this->get<RecordT>();
78  rec.get(iLabel,iHolder);
79  }
80 
81  template< typename T>
82  void getData(const edm::ESInputTag& iTag, T& iHolder) const {
83  typedef typename T::value_type data_type;
85  const RecordT& rec = this->get<RecordT>();
86  rec.get(iTag,iHolder);
87  }
88 
89  const IOVSyncValue& iovSyncValue() const { return syncValue_;}
90 
92 
94  void fillAvailableRecordKeys(std::vector<eventsetup::EventSetupRecordKey>& oToFill) const;
95 
96  // ---------- static member functions --------------------
97 
98  // ---------- member functions ---------------------------
99  template< typename T>
100  void
101  getAvoidCompilerBug(const T*& iValue) const {
102  iValue = &(get<T>());
103  }
104  protected:
105  //Only called by EventSetupProvider
106  void setIOVSyncValue(const IOVSyncValue&);
107 
108  void add(const eventsetup::EventSetupRecord& iRecord);
109 
110  void clear();
111 
112  private:
113  EventSetup();
114 
115  EventSetup(EventSetup const&); // stop default
116 
117  EventSetup const& operator=(EventSetup const&); // stop default
118 
121 
122  // ---------- member data --------------------------------
124 
125  //NOTE: the records are not owned
126  std::map<eventsetup::EventSetupRecordKey, eventsetup::EventSetupRecord const *> recordMap_;
127 };
128 
129 }
130 #endif
void insert(const eventsetup::EventSetupRecordKey &, const eventsetup::EventSetupRecord *)
Definition: EventSetup.cc:68
void getData(T &iHolder) const
Definition: EventSetup.h:67
const eventsetup::EventSetupRecord * find(const eventsetup::EventSetupRecordKey &) const
Definition: EventSetup.cc:90
void getData(const edm::ESInputTag &iTag, T &iHolder) const
Definition: EventSetup.h:82
IOVSyncValue syncValue_
Definition: EventSetup.h:123
virtual ~EventSetup()
Definition: EventSetup.cc:42
void eventSetupGetImplementation(EventSetup const &, T const *&)
std::map< eventsetup::EventSetupRecordKey, eventsetup::EventSetupRecord const * > recordMap_
Definition: EventSetup.h:126
void fillAvailableRecordKeys(std::vector< eventsetup::EventSetupRecordKey > &oToFill) const
clears the oToFill vector and then fills it with the keys for all available records ...
Definition: EventSetup.cc:101
void getData(const std::string &iLabel, T &iHolder) const
Definition: EventSetup.h:74
Container::value_type value_type
void add(const eventsetup::EventSetupRecord &iRecord)
Definition: EventSetup.cc:81
const IOVSyncValue & iovSyncValue() const
Definition: EventSetup.h:89
EventSetup const & operator=(EventSetup const &)
void setIOVSyncValue(const IOVSyncValue &)
Definition: EventSetup.cc:62
long double T
void getAvoidCompilerBug(const T *&iValue) const
Definition: EventSetup.h:101