CMS 3D CMS Logo

List of all members | Public Member Functions | Protected 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 ()
 
 DataProxy (DataProxy const &)=delete
 
void doGet (EventSetupRecordImpl const &, DataKey const &, bool iTransiently, ActivityRegistry const *, EventSetupImpl const *) const
 
void const * get (EventSetupRecordImpl const &, DataKey const &, bool iTransiently, ActivityRegistry const *, EventSetupImpl const *) const
 
virtual void initializeForNewIOV ()
 
void invalidate ()
 
DataProxy const & operator= (DataProxy const &)=delete
 
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, EventSetupImpl const *)=0
 
virtual void invalidateCache ()=0
 
virtual void invalidateTransientCache ()
 

Private Attributes

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

Detailed Description

Description: Base class for data Proxies held by a EventSetupRecord

Usage: This class defines the interface used to handle retrieving data from an EventSetup Record.

Definition at line 38 of file DataProxy.h.

Constructor & Destructor Documentation

◆ DataProxy() [1/2]

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

Definition at line 32 of file DataProxy.cc.

34  cache_(nullptr),
35  cacheIsValid_(false),

◆ DataProxy() [2/2]

edm::eventsetup::DataProxy::DataProxy ( DataProxy const &  )
delete

◆ ~DataProxy()

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

Definition at line 38 of file DataProxy.cc.

38 {}

Member Function Documentation

◆ cacheIsValid()

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

Definition at line 46 of file DataProxy.h.

46 { return cacheIsValid_.load(std::memory_order_acquire); }

References cacheIsValid_.

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

◆ clearCacheIsValid()

void DataProxy< RecordT, DataT, Initializer >::clearCacheIsValid ( )
protected

Definition at line 40 of file DataProxy.cc.

40  {
41  cacheIsValid_.store(false, std::memory_order_release);
42  nonTransientAccessRequested_.store(false, std::memory_order_release);
43  cache_ = nullptr;
44  }

References cache_, cacheIsValid_, and nonTransientAccessRequested_.

Referenced by invalidate(), and resetIfTransient().

◆ doGet()

void DataProxy< RecordT, DataT, Initializer >::doGet ( EventSetupRecordImpl const &  iRecord,
DataKey const &  iKey,
bool  iTransiently,
ActivityRegistry const *  activityRegistry,
EventSetupImpl const *  iEventSetupImpl 
) const

Definition at line 122 of file DataProxy.cc.

126  {
127  get(iRecord, iKey, iTransiently, activityRegistry, iEventSetupImpl);
128  }

References get().

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

◆ get()

const void * DataProxy< RecordT, DataT, Initializer >::get ( EventSetupRecordImpl const &  iRecord,
DataKey const &  iKey,
bool  iTransiently,
ActivityRegistry const *  activityRegistry,
EventSetupImpl const *  iEventSetupImpl 
) const

Definition at line 93 of file DataProxy.cc.

97  {
98  if (!cacheIsValid()) {
99  ESSignalSentry signalSentry(iRecord, iKey, providerDescription(), activityRegistry);
100  std::lock_guard<std::recursive_mutex> guard(esGlobalMutex());
101  signalSentry.sendPostLockSignal();
102  if (!cacheIsValid()) {
103  cache_ = const_cast<DataProxy*>(this)->getImpl(iRecord, iKey, iEventSetupImpl);
104  cacheIsValid_.store(true, std::memory_order_release);
105  }
106  }
107 
108  //We need to set the AccessType for each request so this can't be called in the if block above.
109  //This also must be before the cache_ check since we want to setCacheIsValid before a possible
110  // exception throw. If we don't, 'getImpl' will be called again on a second request for the data.
111 
112  if (!iTransiently) {
113  nonTransientAccessRequested_.store(true, std::memory_order_release);
114  }
115 
116  if (nullptr == cache_) {
117  throwMakeException(iRecord, iKey);
118  }
119  return cache_;
120  }

References cache_, cacheIsValid(), cacheIsValid_, edm::esGlobalMutex(), nonTransientAccessRequested_, and providerDescription().

Referenced by Options.Options::__getitem__(), betterConfigParser.BetterConfigParser::__updateDict(), rrapi.RRApi::columns(), rrapi.RRApi::count(), rrapi.RRApi::data(), doGet(), 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().

◆ getImpl()

virtual void const* edm::eventsetup::DataProxy::getImpl ( EventSetupRecordImpl const &  ,
DataKey const &  iKey,
EventSetupImpl const *   
)
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 >, edm::eventsetup::DataProxyTemplate< RecordT, DataT >, and edm::eventsetup::CallbackProxy< CallbackT, RecordT, DataT >.

◆ initializeForNewIOV()

virtual void edm::eventsetup::DataProxy::initializeForNewIOV ( )
inlinevirtual

Reimplemented in DataProxy< RecordT, DataT, Initializer >.

Definition at line 72 of file DataProxy.h.

72 {}

◆ invalidate()

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

Definition at line 63 of file DataProxy.h.

63  {
66  }

References clearCacheIsValid(), and invalidateCache().

◆ invalidateCache()

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 >, DataProxy< RecordT, DataT, Initializer >, and edm::test::TestDataProxy< T >.

Referenced by invalidate(), and invalidateTransientCache().

◆ invalidateTransientCache()

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 53 of file DataProxy.cc.

53 { invalidateCache(); }

References invalidateCache().

Referenced by resetIfTransient().

◆ operator=()

DataProxy const& edm::eventsetup::DataProxy::operator= ( DataProxy const &  )
delete

◆ providerDescription()

ComponentDescription const* edm::eventsetup::DataProxy::providerDescription ( ) const
inline

◆ resetIfTransient()

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

Definition at line 46 of file DataProxy.cc.

46  {
47  if (!nonTransientAccessRequested_.load(std::memory_order_acquire)) {
50  }
51  }

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

◆ setProviderDescription()

void edm::eventsetup::DataProxy::setProviderDescription ( ComponentDescription const *  iDesc)
inline

Definition at line 70 of file DataProxy.h.

70 { description_ = iDesc; }

References description_.

Member Data Documentation

◆ cache_

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

Definition at line 100 of file DataProxy.h.

Referenced by clearCacheIsValid(), and get().

◆ cacheIsValid_

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

Definition at line 101 of file DataProxy.h.

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

◆ description_

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

Definition at line 99 of file DataProxy.h.

Referenced by providerDescription(), and setProviderDescription().

◆ nonTransientAccessRequested_

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

Definition at line 134 of file DataProxy.h.

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

edm::eventsetup::DataProxy::cacheIsValid_
std::atomic< bool > cacheIsValid_
Definition: DataProxy.h:101
edm::eventsetup::DataProxy::clearCacheIsValid
void clearCacheIsValid()
Definition: DataProxy.cc:40
edm::eventsetup::dummyDescription
static const ComponentDescription * dummyDescription()
Definition: DataProxy.cc:27
edm::eventsetup::DataProxy::get
void const * get(EventSetupRecordImpl const &, DataKey const &, bool iTransiently, ActivityRegistry const *, EventSetupImpl const *) const
Definition: DataProxy.cc:93
edm::eventsetup::DataProxy::invalidateTransientCache
virtual void invalidateTransientCache()
Definition: DataProxy.cc:53
edm::eventsetup::DataProxy::description_
ComponentDescription const * description_
Definition: DataProxy.h:99
edm::eventsetup::DataProxy::invalidateCache
virtual void invalidateCache()=0
edm::eventsetup::DataProxy::cache_
void const * cache_
Definition: DataProxy.h:100
edm::esGlobalMutex
std::recursive_mutex & esGlobalMutex()
Definition: ESGlobalMutex.cc:7
edm::eventsetup::DataProxy::cacheIsValid
bool cacheIsValid() const
Definition: DataProxy.h:46
edm::eventsetup::DataProxy::providerDescription
ComponentDescription const * providerDescription() const
returns the description of the DataProxyProvider which owns this Proxy
Definition: DataProxy.h:60
edm::eventsetup::DataProxy::nonTransientAccessRequested_
std::atomic< bool > nonTransientAccessRequested_
Definition: DataProxy.h:134