CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
edm::eventsetup::EventSetupRecordImpl Class Reference

#include <EventSetupRecordImpl.h>

Public Member Functions

bool add (DataKey const &iKey, DataProxy const *iProxy)
 
void addTraceInfoToCmsException (cms::Exception &iException, char const *iName, ComponentDescription const *, DataKey const &) const
 
unsigned long long cacheIdentifier () const
 
void cacheReset ()
 
void changeStdExceptionToCmsException (char const *iExceptionWhatMessage, char const *iName, ComponentDescription const *, DataKey const &) const
 
void clearProxies ()
 
std::vector< ComponentDescription const * > componentsForRegisteredDataKeys () const
 there is a 1-to-1 correspondence between elements returned and the elements returned from fillRegisteredDataKey. More...
 
bool doGet (DataKey const &aKey, bool aGetTransiently=false) const
 returns false if no data available for key More...
 
EventSetupImpl const & eventSetup () const
 
 EventSetupRecordImpl (const EventSetupRecordKey &iKey)
 
void fillRegisteredDataKeys (std::vector< DataKey > &oToFill) const
 clears the oToFill vector and then fills it with the keys for all registered data keys More...
 
DataProxy const * find (DataKey const &aKey) const
 
void getESProducers (std::vector< ComponentDescription const * > &esproducers)
 
EventSetupRecordKey const & key () const
 
ComponentDescription const * providerDescription (DataKey const &aKey) const
 
void set (ValidityInterval const &)
 
void setEventSetup (EventSetupImpl const *iEventSetup)
 
void transientAccessRequested () const
 
bool transientReset ()
 returns 'true' if a transient request has occurred since the last call to transientReset. More...
 
void validate (ComponentDescription const *, ESInputTag const &) const
 
ValidityInterval const & validityInterval () const
 
bool wasGotten (DataKey const &aKey) const
 

Private Member Functions

 EventSetupRecordImpl (EventSetupRecordImpl const &)=delete
 
void const * getFromProxy (DataKey const &iKey, ComponentDescription const *&iDesc, bool iTransientAccessOnly) const
 
void const * getFromProxy (ESProxyIndex iProxyIndex, bool iTransientAccessOnly, ComponentDescription const *&iDesc, DataKey const *&oGottenKey) const
 
template<typename DataT >
void getImplementation (DataT const *&iData, char const *iName, ComponentDescription const *&iDesc, bool iTransientAccessOnly, std::shared_ptr< ESHandleExceptionFactory > &whyFailedFactory) const
 
template<typename DataT >
void getImplementation (DataT const *&iData, ESProxyIndex iProxyIndex, bool iTransientAccessOnly, ComponentDescription const *&oDesc, std::shared_ptr< ESHandleExceptionFactory > &whyFailedFactory) const
 
EventSetupRecordImpl const & operator= (EventSetupRecordImpl const &)=delete
 

Private Attributes

unsigned long long cacheIdentifier_
 
EventSetupImpl const * eventSetup_
 
EventSetupRecordKey key_
 
std::vector< DataKeykeysForProxies_
 
std::vector< DataProxy const * > proxies_
 
std::atomic< bool > transientAccessRequested_
 
ValidityInterval validity_
 

Friends

class EventSetupRecord
 

Detailed Description

Definition at line 83 of file EventSetupRecordImpl.h.

Constructor & Destructor Documentation

edm::eventsetup::EventSetupRecordImpl::EventSetupRecordImpl ( const EventSetupRecordKey iKey)
edm::eventsetup::EventSetupRecordImpl::EventSetupRecordImpl ( EventSetupRecordImpl const &  )
privatedelete

Member Function Documentation

bool EventSetupRecordImpl::add ( DataKey const &  iKey,
DataProxy const *  iProxy 
)

Definition at line 74 of file EventSetupRecordImpl.cc.

References SoftLeptonByDistance_cfi::distance, Exception, edm::eventsetup::EventSetupRecord::find(), edm::eventsetup::ComponentDescription::isLooper_, edm::eventsetup::ComponentDescription::isSource_, edm::eventsetup::EventSetupRecord::key(), edm::eventsetup::ComponentDescription::label_, pfDeepBoostedJetPreprocessParams_cfi::lower_bound, edm::eventsetup::heterocontainer::HCTypeTag::name(), edm::eventsetup::DataKey::name(), edm::eventsetup::DataProxy::providerDescription(), edm::eventsetup::EventSetupRecordKey::type(), edm::eventsetup::DataKey::type(), edm::eventsetup::ComponentDescription::type_, and edm::eventsetup::SimpleStringTag::value().

Referenced by counter.Counter::register(), SequenceTypes.Task::remove(), and SequenceTypes.Task::replace().

74  {
75  //
76  const DataProxy* proxy = find(iKey);
77  if (nullptr != proxy) {
78  //
79  // we already know the field exist, so do not need to check against end()
80  //
81 
82  // POLICY: If a Producer and a Source both claim to deliver the same data, the
83  // Producer 'trumps' the Source. If two modules of the same type claim to deliver the
84  // same data, this is an error unless the configuration specifically states which one
85  // is to be chosen. A Looper trumps both a Producer and a Source.
86 
87  assert(proxy->providerDescription());
88  assert(iProxy->providerDescription());
89  if (iProxy->providerDescription()->isLooper_) {
91  std::lower_bound(keysForProxies_.begin(), keysForProxies_.end(), iKey))] = iProxy;
92  return true;
93  }
94 
95  if (proxy->providerDescription()->isSource_ == iProxy->providerDescription()->isSource_) {
96  //should lookup to see if there is a specified 'chosen' one and only if not, throw the exception
97  throw cms::Exception("EventSetupConflict")
98  << "two EventSetup " << (proxy->providerDescription()->isSource_ ? "Sources" : "Producers")
99  << " want to deliver type=\"" << iKey.type().name() << "\" label=\"" << iKey.name().value() << "\"\n"
100  << " from record " << key().type().name() << ". The two providers are \n"
101  << "1) type=\"" << proxy->providerDescription()->type_ << "\" label=\""
102  << proxy->providerDescription()->label_ << "\"\n"
103  << "2) type=\"" << iProxy->providerDescription()->type_ << "\" label=\""
104  << iProxy->providerDescription()->label_ << "\"\n"
105  << "Please either\n remove one of these "
106  << (proxy->providerDescription()->isSource_ ? "Sources" : "Producers")
107  << "\n or find a way of configuring one of them so it does not deliver this data"
108  << "\n or use an es_prefer statement in the configuration to choose one.";
109  } else if (proxy->providerDescription()->isSource_) {
111  std::lower_bound(keysForProxies_.begin(), keysForProxies_.end(), iKey))] = iProxy;
112  } else {
113  return false;
114  }
115  } else {
116  auto lb = std::lower_bound(keysForProxies_.begin(), keysForProxies_.end(), iKey);
117  auto index = std::distance(keysForProxies_.begin(), lb);
118  keysForProxies_.insert(lb, iKey);
119  proxies_.insert(proxies_.begin() + index, iProxy);
120  }
121  return true;
122  }
DataProxy const * find(DataKey const &aKey) const
std::vector< DataProxy const * > proxies_
ComponentDescription const * providerDescription() const
returns the description of the DataProxyProvider which owns this Proxy
Definition: DataProxy.h:55
EventSetupRecordKey const & key() const
void EventSetupRecordImpl::addTraceInfoToCmsException ( cms::Exception iException,
char const *  iName,
ComponentDescription const *  ,
DataKey const &   
) const

Definition at line 267 of file EventSetupRecordImpl.cc.

References cms::Exception::addContext(), edm::eventsetup::EventSetupRecord::key(), edm::eventsetup::ComponentDescription::label_, edm::eventsetup::heterocontainer::HCTypeTag::name(), edm::eventsetup::EventSetupRecordKey::type(), edm::eventsetup::DataKey::type(), and edm::eventsetup::ComponentDescription::type_.

270  {
271  std::ostringstream ost;
272  ost << "Using EventSetup component " << iDescription->type_ << "/'" << iDescription->label_ << "' to make data "
273  << iKey.type().name() << "/'" << iName << "' in record " << this->key().type().name();
274  iException.addContext(ost.str());
275  }
void addContext(std::string const &context)
Definition: Exception.cc:165
EventSetupRecordKey const & key() const
unsigned long long edm::eventsetup::EventSetupRecordImpl::cacheIdentifier ( ) const
inline

If you are caching data from the Record, you should also keep this number. If this number changes then you know that the data you have cached is invalid. This is NOT true if if the validityInterval() hasn't changed since it is possible that the job has gone to a new Record and then come back to the previous SyncValue and your algorithm didn't see the intervening Record. The value of '0' will never be returned so you can use that to denote that you have not yet checked the value.

Definition at line 118 of file EventSetupRecordImpl.h.

References PVValHelper::add().

118 { return cacheIdentifier_; }
void EventSetupRecordImpl::cacheReset ( )

Definition at line 129 of file EventSetupRecordImpl.cc.

129  {
132  }
void edm::eventsetup::EventSetupRecordImpl::changeStdExceptionToCmsException ( char const *  iExceptionWhatMessage,
char const *  iName,
ComponentDescription const *  ,
DataKey const &   
) const
void EventSetupRecordImpl::clearProxies ( )

Definition at line 124 of file EventSetupRecordImpl.cc.

124  {
125  keysForProxies_.clear();
126  proxies_.clear();
127  }
std::vector< DataProxy const * > proxies_
std::vector< ComponentDescription const * > EventSetupRecordImpl::componentsForRegisteredDataKeys ( ) const

there is a 1-to-1 correspondence between elements returned and the elements returned from fillRegisteredDataKey.

Definition at line 65 of file EventSetupRecordImpl.cc.

65  {
66  std::vector<ComponentDescription const*> ret;
67  ret.reserve(proxies_.size());
68  for (auto const& proxy : proxies_) {
69  ret.push_back(proxy->providerDescription());
70  }
71  return ret;
72  }
std::vector< DataProxy const * > proxies_
bool EventSetupRecordImpl::doGet ( DataKey const &  aKey,
bool  aGetTransiently = false 
) const

returns false if no data available for key

Definition at line 210 of file EventSetupRecordImpl.cc.

References edm::eventsetup::EventSetupRecord::addTraceInfoToCmsException(), edm::eventsetup::DataProxy::doGet(), MillePedeFileConverter_cfg::e, edm::eventsetup::EventSetupRecord::find(), edm::eventsetup::DataKey::name(), edm::eventsetup::DataProxy::providerDescription(), edm::eventsetup::SimpleStringTag::value(), and edm::convertException::wrap().

Referenced by edm::eventsetup::EventSetupRecord::doGet().

210  {
211  const DataProxy* proxy = find(aKey);
212  if (nullptr != proxy) {
213  try {
215  [&]() { proxy->doGet(*this, aKey, aGetTransiently, eventSetup_->activityRegistry()); });
216  } catch (cms::Exception& e) {
217  addTraceInfoToCmsException(e, aKey.name().value(), proxy->providerDescription(), aKey);
218  //NOTE: the above function can't do the 'throw' since it causes the C++ class type
219  // of the throw to be changed, a 'rethrow' does not have that problem
220  throw;
221  }
222  }
223  return nullptr != proxy;
224  }
void addTraceInfoToCmsException(cms::Exception &iException, char const *iName, ComponentDescription const *, DataKey const &) const
DataProxy const * find(DataKey const &aKey) const
void doGet(EventSetupRecordImpl const &iRecord, DataKey const &iKey, bool iTransiently, ActivityRegistry const *) const
Definition: DataProxy.cc:148
ActivityRegistry const * activityRegistry() const
ComponentDescription const * providerDescription() const
returns the description of the DataProxyProvider which owns this Proxy
Definition: DataProxy.h:55
auto wrap(F iFunc) -> decltype(iFunc())
EventSetupImpl const& edm::eventsetup::EventSetupRecordImpl::eventSetup ( ) const
inline

Definition at line 143 of file EventSetupRecordImpl.h.

143 { return *eventSetup_; }
void EventSetupRecordImpl::fillRegisteredDataKeys ( std::vector< DataKey > &  oToFill) const

clears the oToFill vector and then fills it with the keys for all registered data keys

Definition at line 242 of file EventSetupRecordImpl.cc.

242  {
243  oToFill = keysForProxies_;
244  }
const DataProxy * EventSetupRecordImpl::find ( DataKey const &  aKey) const

Definition at line 202 of file EventSetupRecordImpl.cc.

References SoftLeptonByDistance_cfi::distance, pfDeepBoostedJetPreprocessParams_cfi::lower_bound, and or.

202  {
203  auto lb = std::lower_bound(keysForProxies_.begin(), keysForProxies_.end(), iKey);
204  if ((lb == keysForProxies_.end()) or (*lb != iKey)) {
205  return nullptr;
206  }
207  return proxies_[std::distance(keysForProxies_.begin(), lb)];
208  }
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
std::vector< DataProxy const * > proxies_
void EventSetupRecordImpl::getESProducers ( std::vector< ComponentDescription const * > &  esproducers)

Definition at line 54 of file EventSetupRecordImpl.cc.

References edm::eventsetup::ComponentDescription::isLooper_, and edm::eventsetup::ComponentDescription::isSource_.

54  {
55  esproducers.clear();
56  esproducers.reserve(proxies_.size());
57  for (auto const& iData : proxies_) {
58  ComponentDescription const* componentDescription = iData->providerDescription();
59  if (!componentDescription->isLooper_ && !componentDescription->isSource_) {
60  esproducers.push_back(componentDescription);
61  }
62  }
63  }
std::vector< DataProxy const * > proxies_
void const* edm::eventsetup::EventSetupRecordImpl::getFromProxy ( DataKey const &  iKey,
ComponentDescription const *&  iDesc,
bool  iTransientAccessOnly 
) const
private

Referenced by transientReset().

void const* edm::eventsetup::EventSetupRecordImpl::getFromProxy ( ESProxyIndex  iProxyIndex,
bool  iTransientAccessOnly,
ComponentDescription const *&  iDesc,
DataKey const *&  oGottenKey 
) const
private
template<typename DataT >
void edm::eventsetup::EventSetupRecordImpl::getImplementation ( DataT const *&  iData,
char const *  iName,
ComponentDescription const *&  iDesc,
bool  iTransientAccessOnly,
std::shared_ptr< ESHandleExceptionFactory > &  whyFailedFactory 
) const
inlineprivate

Definition at line 173 of file EventSetupRecordImpl.h.

References crabWrapper::key, and edm::makeESHandleExceptionFactory().

177  {
178  DataKey dataKey(DataKey::makeTypeTag<DataT>(), iName, DataKey::kDoNotCopyMemory);
179 
180  void const* pValue = this->getFromProxy(dataKey, iDesc, iTransientAccessOnly);
181  if (nullptr == pValue) {
182  whyFailedFactory = makeESHandleExceptionFactory([=] {
183  NoProxyException<DataT> ex(this->key(), dataKey);
184  return std::make_exception_ptr(ex);
185  });
186  }
187  iData = reinterpret_cast<DataT const*>(pValue);
188  }
std::shared_ptr< ESHandleExceptionFactory > makeESHandleExceptionFactory(T &&iFunctor)
void const * getFromProxy(DataKey const &iKey, ComponentDescription const *&iDesc, bool iTransientAccessOnly) const
EventSetupRecordKey const & key() const
template<typename DataT >
void edm::eventsetup::EventSetupRecordImpl::getImplementation ( DataT const *&  iData,
ESProxyIndex  iProxyIndex,
bool  iTransientAccessOnly,
ComponentDescription const *&  oDesc,
std::shared_ptr< ESHandleExceptionFactory > &  whyFailedFactory 
) const
inlineprivate

Definition at line 191 of file EventSetupRecordImpl.h.

References crabWrapper::key, edm::makeESHandleExceptionFactory(), SiStripPI::max, and edm::ESProxyIndex::value().

195  {
196  DataKey const* dataKey = nullptr;
197  if (iProxyIndex.value() == std::numeric_limits<int>::max()) {
198  whyFailedFactory = makeESHandleExceptionFactory([=] {
199  NoProxyException<DataT> ex(this->key(), {});
200  return std::make_exception_ptr(ex);
201  });
202  iData = nullptr;
203  return;
204  }
205  assert(iProxyIndex.value() > -1 and
206  iProxyIndex.value() < static_cast<ESProxyIndex::Value_t>(keysForProxies_.size()));
207  void const* pValue = this->getFromProxy(iProxyIndex, iTransientAccessOnly, oDesc, dataKey);
208  if (nullptr == pValue) {
209  whyFailedFactory = makeESHandleExceptionFactory([=] {
210  NoProxyException<DataT> ex(this->key(), *dataKey);
211  return std::make_exception_ptr(ex);
212  });
213  }
214  iData = reinterpret_cast<DataT const*>(pValue);
215  }
std::shared_ptr< ESHandleExceptionFactory > makeESHandleExceptionFactory(T &&iFunctor)
void const * getFromProxy(DataKey const &iKey, ComponentDescription const *&iDesc, bool iTransientAccessOnly) const
EventSetupRecordKey const & key() const
EventSetupRecordKey const& edm::eventsetup::EventSetupRecordImpl::key ( ) const
inline
EventSetupRecordImpl const& edm::eventsetup::EventSetupRecordImpl::operator= ( EventSetupRecordImpl const &  )
privatedelete
edm::eventsetup::ComponentDescription const * EventSetupRecordImpl::providerDescription ( DataKey const &  aKey) const

returns the ComponentDescription for the module which creates the data or 0 if no module has been registered for the data. This does not cause the data to actually be constructed.

Definition at line 234 of file EventSetupRecordImpl.cc.

References edm::eventsetup::EventSetupRecord::find(), and edm::eventsetup::DataProxy::providerDescription().

Referenced by edm::eventsetup::EventSetupRecord::providerDescription().

234  {
235  const DataProxy* proxy = find(aKey);
236  if (nullptr != proxy) {
237  return proxy->providerDescription();
238  }
239  return nullptr;
240  }
DataProxy const * find(DataKey const &aKey) const
ComponentDescription const * providerDescription() const
returns the description of the DataProxyProvider which owns this Proxy
Definition: DataProxy.h:55
void EventSetupRecordImpl::set ( ValidityInterval const &  )

Definition at line 52 of file EventSetupRecordImpl.cc.

52 { validity_ = iInterval; }
void edm::eventsetup::EventSetupRecordImpl::setEventSetup ( EventSetupImpl const *  iEventSetup)
inline

Definition at line 136 of file EventSetupRecordImpl.h.

References spr::find().

Referenced by edm::eventsetup::EventSetupProvider::addRecordToEventSetup().

136 { eventSetup_ = iEventSetup; }
void edm::eventsetup::EventSetupRecordImpl::transientAccessRequested ( ) const
inline

Definition at line 156 of file EventSetupRecordImpl.h.

bool EventSetupRecordImpl::transientReset ( )
void EventSetupRecordImpl::validate ( ComponentDescription const *  ,
ESInputTag const &   
) const

Definition at line 246 of file EventSetupRecordImpl.cc.

References edm::ESInputTag::data(), Exception, edm::eventsetup::ComponentDescription::label_, electrons_cff::matched, edm::ESInputTag::module(), and edm::eventsetup::ComponentDescription::type_.

246  {
247  if (iDesc && !iTag.module().empty()) {
248  bool matched = false;
249  if (iDesc->label_.empty()) {
250  matched = iDesc->type_ == iTag.module();
251  } else {
252  matched = iDesc->label_ == iTag.module();
253  }
254  if (!matched) {
255  throw cms::Exception("EventSetupWrongModule")
256  << "EventSetup data was retrieved using an ESInputTag with the values\n"
257  << " moduleLabel = '" << iTag.module() << "'\n"
258  << " dataLabel = '" << iTag.data() << "'\n"
259  << "but the data matching the C++ class type and dataLabel comes from module type=" << iDesc->type_
260  << " label='" << iDesc->label_ << "'.\n Please either change the ESInputTag's 'module' label to be "
261  << (iDesc->label_.empty() ? iDesc->type_ : iDesc->label_) << "\n or add the EventSetup module "
262  << iTag.module() << " to the configuration.";
263  }
264  }
265  }
ValidityInterval const& edm::eventsetup::EventSetupRecordImpl::validityInterval ( ) const
inline

Definition at line 90 of file EventSetupRecordImpl.h.

90 { return validity_; }
bool EventSetupRecordImpl::wasGotten ( DataKey const &  aKey) const

returns true only if someone has already requested data for this key and the data was retrieved

Definition at line 226 of file EventSetupRecordImpl.cc.

References edm::eventsetup::DataProxy::cacheIsValid(), and edm::eventsetup::EventSetupRecord::find().

Referenced by edm::eventsetup::EventSetupRecord::wasGotten().

226  {
227  const DataProxy* proxy = find(aKey);
228  if (nullptr != proxy) {
229  return proxy->cacheIsValid();
230  }
231  return false;
232  }
bool cacheIsValid() const
Definition: DataProxy.h:43
DataProxy const * find(DataKey const &aKey) const

Friends And Related Function Documentation

friend class EventSetupRecord
friend

Definition at line 84 of file EventSetupRecordImpl.h.

Member Data Documentation

unsigned long long edm::eventsetup::EventSetupRecordImpl::cacheIdentifier_
private

Definition at line 223 of file EventSetupRecordImpl.h.

EventSetupImpl const* edm::eventsetup::EventSetupRecordImpl::eventSetup_
private

Definition at line 222 of file EventSetupRecordImpl.h.

EventSetupRecordKey edm::eventsetup::EventSetupRecordImpl::key_
private

Definition at line 219 of file EventSetupRecordImpl.h.

std::vector<DataKey> edm::eventsetup::EventSetupRecordImpl::keysForProxies_
private

Definition at line 220 of file EventSetupRecordImpl.h.

std::vector<DataProxy const*> edm::eventsetup::EventSetupRecordImpl::proxies_
private

Definition at line 221 of file EventSetupRecordImpl.h.

std::atomic<bool> edm::eventsetup::EventSetupRecordImpl::transientAccessRequested_
mutableprivate

Definition at line 224 of file EventSetupRecordImpl.h.

ValidityInterval edm::eventsetup::EventSetupRecordImpl::validity_
private

Definition at line 218 of file EventSetupRecordImpl.h.