CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EventSetupRecord.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_EventSetupRecord_h
2 #define FWCore_Framework_EventSetupRecord_h
3 // -*- C++ -*-
4 //
5 // Package: Framework
6 // Class : EventSetupRecord
7 //
45 //
46 // Author: Chris Jones
47 // Created: Fri Mar 25 14:38:35 EST 2005
48 //
49 
50 
51 // user include files
56 
57 // system include files
58 #include <map>
59 #include <vector>
60 
61 // forward declarations
62 namespace cms {
63  class Exception;
64 }
65 
66 namespace edm {
67  class ESInputTag;
68  class EventSetup;
69 
70  namespace eventsetup {
71  struct ComponentDescription;
72  class DataProxy;
73  class EventSetupRecordKey;
74 
76 
77  public:
79  virtual ~EventSetupRecord();
80 
81  // ---------- const member functions ---------------------
83  return validity_;
84  }
85 
86  template<typename HolderT>
87  void get(HolderT& iHolder) const {
88  typename HolderT::value_type const* value = 0;
89  ComponentDescription const* desc = 0;
90  this->getImplementation(value, "", desc, iHolder.transientAccessOnly);
91 
92  iHolder = HolderT(value, desc);
93  }
94 
95  template<typename HolderT>
96  void get(char const* iName, HolderT& iHolder) const {
97  typename HolderT::value_type const* value = 0;
98  ComponentDescription const* desc = 0;
99  this->getImplementation(value, iName, desc, iHolder.transientAccessOnly);
100  iHolder = HolderT(value, desc);
101  }
102  template<typename HolderT>
103  void get(std::string const& iName, HolderT& iHolder) const {
104  typename HolderT::value_type const* value = 0;
105  ComponentDescription const* desc = 0;
106  this->getImplementation(value, iName.c_str(), desc, iHolder.transientAccessOnly);
107  iHolder = HolderT(value, desc);
108  }
109 
110  template<typename HolderT>
111  void get(ESInputTag const& iTag, HolderT& iHolder) const {
112  typename HolderT::value_type const* value = 0;
113  ComponentDescription const* desc = 0;
114  this->getImplementation(value, iTag.data().c_str(), desc, iHolder.transientAccessOnly);
115  validate(desc, iTag);
116  iHolder = HolderT(value, desc);
117  }
118 
119 
120 
122  bool doGet(DataKey const& aKey, bool aGetTransiently = false) const;
123 
127  bool wasGotten(DataKey const& aKey) const;
128 
133  ComponentDescription const* providerDescription(DataKey const& aKey) const;
134 
135  virtual EventSetupRecordKey key() const = 0;
136 
147  unsigned long long cacheIdentifier() const {
148  return cacheIdentifier_;
149  }
150 
152  void fillRegisteredDataKeys(std::vector<DataKey>& oToFill) const;
153  // ---------- static member functions --------------------
154 
155  // ---------- member functions ---------------------------
156 
157  // The following member functions should only be used by EventSetupRecordProvider
158  bool add(DataKey const& iKey ,
159  DataProxy const* iProxy) ;
160  void cacheReset() ;
162  bool transientReset() ;
163  void set(ValidityInterval const&);
164  void setEventSetup(EventSetup const* iEventSetup) {eventSetup_ = iEventSetup; }
165  protected:
166 
167  DataProxy const* find(DataKey const& aKey) const ;
168 
169  EventSetup const& eventSetup() const {
170  return *eventSetup_;
171  }
172 
173  void validate(ComponentDescription const*, ESInputTag const&) const;
174 
175  void addTraceInfoToCmsException(cms::Exception& iException, char const* iName, ComponentDescription const*, DataKey const&) const;
176  void changeStdExceptionToCmsException(char const* iExceptionWhatMessage, char const* iName, ComponentDescription const*, DataKey const&) const;
177 
179  private:
180  EventSetupRecord(EventSetupRecord const&); // stop default
181 
182  EventSetupRecord const& operator=(EventSetupRecord const&); // stop default
183 
184  void const* getFromProxy(DataKey const& iKey ,
185  ComponentDescription const*& iDesc,
186  bool iTransientAccessOnly) const;
187 
188  template <typename DataT>
189  void getImplementation(DataT const*& iData ,
190  char const* iName,
191  ComponentDescription const*& iDesc,
192  bool iTransientAccessOnly) const {
193  DataKey dataKey(DataKey::makeTypeTag<DataT>(),
194  iName,
196 
197  void const* pValue = this->getFromProxy(dataKey, iDesc, iTransientAccessOnly);
198  if(0 == pValue) {
199  throw NoProxyException<DataT>(this->key(), dataKey);
200  }
201  iData = reinterpret_cast<DataT const*> (pValue);
202  }
203 
204  // ---------- member data --------------------------------
206  std::map<DataKey, DataProxy const*> proxies_ ;
208  unsigned long long cacheIdentifier_;
210  };
211  }
212 }
213 #endif
void getImplementation(DataT const *&iData, char const *iName, ComponentDescription const *&iDesc, bool iTransientAccessOnly) const
unsigned long long cacheIdentifier() const
void fillRegisteredDataKeys(std::vector< DataKey > &oToFill) const
clears the oToFill vector and then fills it with the keys for all registered data keys ...
bool wasGotten(DataKey const &aKey) const
virtual EventSetupRecordKey key() const =0
void addTraceInfoToCmsException(cms::Exception &iException, char const *iName, ComponentDescription const *, DataKey const &) const
EventSetup const & eventSetup() const
std::map< DataKey, DataProxy const * > proxies_
ComponentDescription const * providerDescription(DataKey const &aKey) const
DataProxy const * find(DataKey const &aKey) const
Container::value_type value_type
bool add(DataKey const &iKey, DataProxy const *iProxy)
string const
Definition: compareJSON.py:14
bool transientReset()
returns &#39;true&#39; if a transient request has occurred since the last call to transientReset.
EventSetupRecord const & operator=(EventSetupRecord const &)
void validate(ComponentDescription const *, ESInputTag const &) const
void setEventSetup(EventSetup const *iEventSetup)
bool doGet(DataKey const &aKey, bool aGetTransiently=false) const
returns false if no data available for key
void changeStdExceptionToCmsException(char const *iExceptionWhatMessage, char const *iName, ComponentDescription const *, DataKey const &) const
void set(ValidityInterval const &)
void const * getFromProxy(DataKey const &iKey, ComponentDescription const *&iDesc, bool iTransientAccessOnly) const
ValidityInterval const & validityInterval() const