Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
novadaq::Cache Class Referenceabstract

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N21-02-24/NovaDAQUtilities/cxx/include/Cache.h"

Inheritance diagram for novadaq::Cache:
novadaq::EnvVarCache

Public Member Functions

void flush ()
 
virtual ~Cache ()
 

Protected Member Functions

 Cache (CachePolicy policy)
 
void _reloadIfNeeded ()
 
virtual void _loadDataIntoCache ()=0
 
virtual void _clearCachedData ()=0
 

Protected Attributes

CachePolicy _policy
 
bool _cacheIsEmpty
 
boost::mutex _cacheMutex
 

Detailed Description

A base class to be used when implementing a cache of data. That is, a set of data that is not expected to change often, but which may need to be updated at some point (either through some automatic means or via user or application request).

Author
Kurt Biery
Version
Revision
1.1.34.1
Date
2019/09/27 00:07:20

Definition at line 19 of file Cache.h.

Constructor & Destructor Documentation

virtual novadaq::Cache::~Cache ( )
inlinevirtual

Definition at line 25 of file Cache.h.

References _clearCachedData(), _loadDataIntoCache(), _reloadIfNeeded(), and Cache().

25 {};
novadaq::Cache::Cache ( CachePolicy  policy)
explicitprotected

Constructor.

Parameters
policythe CachePolicy to use for automatically expiring the cache.

Definition at line 20 of file Cache.cpp.

Referenced by ~Cache().

20 : _policy(policy), _cacheIsEmpty(true) {}
bool _cacheIsEmpty
Definition: Cache.h:40
CachePolicy _policy
Definition: Cache.h:39

Member Function Documentation

virtual void novadaq::Cache::_clearCachedData ( )
protectedpure virtual

Implemented in novadaq::EnvVarCache.

Referenced by _reloadIfNeeded(), flush(), and ~Cache().

virtual void novadaq::Cache::_loadDataIntoCache ( )
protectedpure virtual

Implemented in novadaq::EnvVarCache.

Referenced by _reloadIfNeeded(), and ~Cache().

void novadaq::Cache::_reloadIfNeeded ( )
protected

Reloads the cache if needed.

Definition at line 25 of file Cache.cpp.

References _cacheIsEmpty, _clearCachedData(), _loadDataIntoCache(), _policy, novadaq::CachePolicy::cacheUpdated(), and novadaq::CachePolicy::isExpired().

Referenced by ~Cache().

25  {
26  if (_cacheIsEmpty || _policy.isExpired()) {
29  _cacheIsEmpty = false;
31  }
32 }
bool _cacheIsEmpty
Definition: Cache.h:40
virtual void _clearCachedData()=0
CachePolicy _policy
Definition: Cache.h:39
virtual void _loadDataIntoCache()=0
void novadaq::Cache::flush ( )

Flushes the cache. (Removes any saved data.)

Definition at line 8 of file Cache.cpp.

References _cacheIsEmpty, _cacheMutex, and _clearCachedData().

Referenced by CacheTests::testEnvVarCacheBasic(), and CacheTests::testEnvVarCacheNumbers().

8  {
9  boost::mutex::scoped_lock lock(_cacheMutex);
11  _cacheIsEmpty = true;
12 }
bool _cacheIsEmpty
Definition: Cache.h:40
virtual void _clearCachedData()=0
boost::mutex _cacheMutex
Definition: Cache.h:41

Member Data Documentation

bool novadaq::Cache::_cacheIsEmpty
protected

Definition at line 40 of file Cache.h.

Referenced by _reloadIfNeeded(), and flush().

boost::mutex novadaq::Cache::_cacheMutex
protected
CachePolicy novadaq::Cache::_policy
protected

Definition at line 39 of file Cache.h.

Referenced by _reloadIfNeeded().


The documentation for this class was generated from the following files: