CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
edm::eventsetup::DataProxy Class Referenceabstract

#include <DataProxy.h>

Inheritance diagram for edm::eventsetup::DataProxy:
edm::eventsetup::CallbackProxy< CallbackT, RecordT, DataT > edm::eventsetup::DataProxyTemplate< RecordT, DataT > edm::test::TestDataProxy< T > DataProxy< RecordT, DataT, Initializer >

Public Member Functions

bool cacheIsValid () const
 
 DataProxy ()
 
void doGet (EventSetupRecordImpl const &iRecord, DataKey const &iKey, bool iTransiently, ActivityRegistry *) const
 
void const * get (EventSetupRecordImpl const &, DataKey const &iKey, bool iTransiently, ActivityRegistry *) const
 
void invalidate ()
 
ComponentDescription const * providerDescription () const
 returns the description of the DataProxyProvider which owns this Proxy More...
 
void resetIfTransient ()
 
void setProviderDescription (ComponentDescription const *iDesc)
 
virtual ~DataProxy ()
 

Protected Member Functions

void clearCacheIsValid ()
 
virtual void const * getImpl (EventSetupRecordImpl const &, DataKey const &iKey)=0
 
virtual void invalidateCache ()=0
 
virtual void invalidateTransientCache ()
 

Private Member Functions

 DataProxy (DataProxy const &)=delete
 
DataProxy const & operator= (DataProxy const &)=delete
 

Private Attributes

void const * cache_
 
std::atomic< bool > cacheIsValid_
 
ComponentDescription const * description_
 
std::atomic< bool > nonTransientAccessRequested_
 

Detailed Description

Definition at line 37 of file DataProxy.h.

Constructor & Destructor Documentation

DataProxy< RecordT, DataT, Initializer >::DataProxy ( )

Definition at line 42 of file DataProxy.cc.

Referenced by setProviderDescription().

42  :
43  cache_(nullptr),
44  cacheIsValid_(false),
47 {
48 }
std::atomic< bool > nonTransientAccessRequested_
Definition: DataProxy.h:96
std::atomic< bool > cacheIsValid_
Definition: DataProxy.h:95
ComponentDescription const * description_
Definition: DataProxy.h:97
static const ComponentDescription * dummyDescription()
Definition: DataProxy.cc:34
DataProxy< RecordT, DataT, Initializer >::~DataProxy ( )
virtual

Definition at line 55 of file DataProxy.cc.

56 {
57 }
edm::eventsetup::DataProxy::DataProxy ( DataProxy const &  )
privatedelete

Member Function Documentation

bool edm::eventsetup::DataProxy::cacheIsValid ( ) const
inline

Definition at line 44 of file DataProxy.h.

References cacheIsValid_, and doGet().

Referenced by get(), and edm::eventsetup::EventSetupRecordImpl::wasGotten().

44 { return cacheIsValid_.load(std::memory_order_acquire); }
std::atomic< bool > cacheIsValid_
Definition: DataProxy.h:95
void DataProxy< RecordT, DataT, Initializer >::clearCacheIsValid ( )
protected

Definition at line 74 of file DataProxy.cc.

References cache_, cacheIsValid_, and nonTransientAccessRequested_.

Referenced by invalidate(), resetIfTransient(), and setProviderDescription().

74  {
75  cacheIsValid_.store(false, std::memory_order_release);
76  nonTransientAccessRequested_.store(false, std::memory_order_release);
77  cache_ = nullptr;
78 }
std::atomic< bool > nonTransientAccessRequested_
Definition: DataProxy.h:96
std::atomic< bool > cacheIsValid_
Definition: DataProxy.h:95
void DataProxy< RecordT, DataT, Initializer >::doGet ( EventSetupRecordImpl const &  iRecord,
DataKey const &  iKey,
bool  iTransiently,
ActivityRegistry  
) const

Definition at line 159 of file DataProxy.cc.

Referenced by cacheIsValid(), and edm::eventsetup::EventSetupRecordImpl::doGet().

159  {
160  get(iRecord, iKey, iTransiently, activityRegistry);
161 }
const void * DataProxy< RecordT, DataT, Initializer >::get ( EventSetupRecordImpl const &  ,
DataKey const &  iKey,
bool  iTransiently,
ActivityRegistry  
) const

Definition at line 135 of file DataProxy.cc.

References cache_, cacheIsValid(), cacheIsValid_, getImpl(), nonTransientAccessRequested_, and providerDescription().

Referenced by Options.Options::__getitem__(), betterConfigParser.BetterConfigParser::__updateDict(), rrapi.RRApi::columns(), rrapi.RRApi::count(), rrapi.RRApi::data(), betterConfigParser.BetterConfigParser::getCompares(), edm::eventsetup::EventSetupRecordImpl::getFromProxy(), betterConfigParser.BetterConfigParser::getGeneral(), betterConfigParser.BetterConfigParser::getResultingSection(), rrapi.RRApi::report(), rrapi.RRApi::reports(), rrapi.RRApi::tables(), rrapi.RRApi::tags(), rrapi.RRApi::templates(), and rrapi.RRApi::workspaces().

136 {
137  if(!cacheIsValid()) {
138  ESSignalSentry signalSentry(iRecord, iKey, providerDescription(), activityRegistry);
139  std::lock_guard<std::recursive_mutex> guard(s_esGlobalMutex);
140  signalSentry.sendPostLockSignal();
141  if(!cacheIsValid()) {
142  cache_ = const_cast<DataProxy*>(this)->getImpl(iRecord, iKey);
143  cacheIsValid_.store(true,std::memory_order_release);
144  }
145  }
146  //We need to set the AccessType for each request so this can't be called in the if block above.
147  //This also must be before the cache_ check since we want to setCacheIsValid before a possible
148  // exception throw. If we don't, 'getImpl' will be called again on a second request for the data.
149  if(!iTransiently) {
150  nonTransientAccessRequested_.store(true, std::memory_order_release);
151  }
152 
153  if(nullptr == cache_) {
154  throwMakeException(iRecord, iKey);
155  }
156  return cache_;
157 }
bool cacheIsValid() const
Definition: DataProxy.h:44
std::atomic< bool > nonTransientAccessRequested_
Definition: DataProxy.h:96
std::atomic< bool > cacheIsValid_
Definition: DataProxy.h:95
virtual void const * getImpl(EventSetupRecordImpl const &, DataKey const &iKey)=0
ComponentDescription const * providerDescription() const
returns the description of the DataProxyProvider which owns this Proxy
Definition: DataProxy.h:50
static std::recursive_mutex s_esGlobalMutex
Definition: DataProxy.cc:28
virtual void const* edm::eventsetup::DataProxy::getImpl ( EventSetupRecordImpl const &  ,
DataKey const &  iKey 
)
protectedpure virtual

This is the function which does the real work of getting the data if it is not already cached. The returning 'void const*' must point to an instance of the class type corresponding to the type designated in iKey. So if iKey refers to a base class interface the pointer must be a pointer to that base class interface and not a pointer to an inheriting class instance.

Implemented in edm::test::TestDataProxy< T >.

Referenced by get(), and setProviderDescription().

void edm::eventsetup::DataProxy::invalidate ( )
inline

Definition at line 56 of file DataProxy.h.

References clearCacheIsValid(), invalidateCache(), and resetIfTransient().

56  {
59  }
virtual void invalidateCache()=0
virtual void edm::eventsetup::DataProxy::invalidateCache ( )
protectedpure virtual

indicates that the Proxy should invalidate any cached information as that information has 'expired' (i.e. we have moved to a new IOV)

Implemented in edm::eventsetup::CallbackProxy< CallbackT, RecordT, DataT >, edm::test::TestDataProxy< T >, and DataProxy< RecordT, DataT, Initializer >.

Referenced by invalidate(), invalidateTransientCache(), and setProviderDescription().

void DataProxy< RecordT, DataT, Initializer >::invalidateTransientCache ( )
protectedvirtual

indicates that the Proxy should invalidate any cached information as that information was accessed transiently and therefore is not intended to be kept over the entire IOV. Default is to call invalidateCache().

Reimplemented in DataProxy< RecordT, DataT, Initializer >.

Definition at line 89 of file DataProxy.cc.

References activityRegistry_, calledPostLock_, componentDescription_, dataKey_, eventSetupRecord_, invalidateCache(), edm::eventsetup::EventSetupRecordImpl::key(), noexcept, and edm::ActivityRegistry::preLockEventSetupGetSignal_.

Referenced by resetIfTransient(), and setProviderDescription().

89  {
91 }
virtual void invalidateCache()=0
DataProxy const& edm::eventsetup::DataProxy::operator= ( DataProxy const &  )
privatedelete

Referenced by setProviderDescription().

ComponentDescription const* edm::eventsetup::DataProxy::providerDescription ( ) const
inline
void DataProxy< RecordT, DataT, Initializer >::resetIfTransient ( )

Definition at line 81 of file DataProxy.cc.

References clearCacheIsValid(), invalidateTransientCache(), and nonTransientAccessRequested_.

Referenced by invalidate().

81  {
82  if (!nonTransientAccessRequested_.load(std::memory_order_acquire)) {
85  }
86 }
virtual void invalidateTransientCache()
Definition: DataProxy.cc:89
std::atomic< bool > nonTransientAccessRequested_
Definition: DataProxy.h:96
void edm::eventsetup::DataProxy::setProviderDescription ( ComponentDescription const *  iDesc)
inline

Definition at line 63 of file DataProxy.h.

References clearCacheIsValid(), DataProxy(), description_, getImpl(), invalidateCache(), invalidateTransientCache(), and operator=().

63  {
64  description_ = iDesc;
65  }
ComponentDescription const * description_
Definition: DataProxy.h:97

Member Data Documentation

void const* edm::eventsetup::DataProxy::cache_
mutableprivate

Definition at line 94 of file DataProxy.h.

Referenced by clearCacheIsValid(), and get().

std::atomic<bool> edm::eventsetup::DataProxy::cacheIsValid_
mutableprivate

Definition at line 95 of file DataProxy.h.

Referenced by cacheIsValid(), clearCacheIsValid(), and get().

ComponentDescription const* edm::eventsetup::DataProxy::description_
private

Definition at line 97 of file DataProxy.h.

Referenced by providerDescription(), and setProviderDescription().

std::atomic<bool> edm::eventsetup::DataProxy::nonTransientAccessRequested_
mutableprivate

Definition at line 96 of file DataProxy.h.

Referenced by clearCacheIsValid(), get(), and resetIfTransient().