Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
N21-03-07
NovaDAQUtilities
cxx
src
Cache.cpp
Go to the documentation of this file.
1
#include <NovaDAQUtilities/Cache.h>
2
3
namespace
novadaq
{
4
5
/**
6
* Flushes the cache. (Removes any saved data.)
7
*/
8
void
Cache::flush
() {
9
boost::mutex::scoped_lock lock(
_cacheMutex
);
10
_clearCachedData
();
11
_cacheIsEmpty
=
true
;
12
}
13
14
/**
15
* Constructor.
16
*
17
* @param policy the CachePolicy to use for automatically expiring
18
* the cache.
19
*/
20
Cache::Cache
(
CachePolicy
policy) :
_policy
(policy),
_cacheIsEmpty
(true) {}
21
22
/**
23
* Reloads the cache if needed.
24
*/
25
void
Cache::_reloadIfNeeded
() {
26
if
(
_cacheIsEmpty
||
_policy
.
isExpired
()) {
27
_clearCachedData
();
28
_loadDataIntoCache
();
29
_cacheIsEmpty
=
false
;
30
_policy
.
cacheUpdated
();
31
}
32
}
33
34
}
// end of namespace novadaq
novadaq::Cache::flush
void flush()
Definition:
Cache.cpp:8
novadaq::Cache::_cacheIsEmpty
bool _cacheIsEmpty
Definition:
Cache.h:40
novadaq::Cache::_clearCachedData
virtual void _clearCachedData()=0
novadaq
Definition:
RawDAQData.h:46
novadaq::Cache::Cache
Cache(CachePolicy policy)
Definition:
Cache.cpp:20
novadaq::Cache::_reloadIfNeeded
void _reloadIfNeeded()
Definition:
Cache.cpp:25
novadaq::CachePolicy::cacheUpdated
void cacheUpdated()
Definition:
CachePolicy.cpp:9
novadaq::Cache::_policy
CachePolicy _policy
Definition:
Cache.h:39
novadaq::CachePolicy::isExpired
bool isExpired()
Definition:
CachePolicy.cpp:19
novadaq::CachePolicy
Definition:
CachePolicy.h:16
novadaq::Cache::_loadDataIntoCache
virtual void _loadDataIntoCache()=0
novadaq::Cache::_cacheMutex
boost::mutex _cacheMutex
Definition:
Cache.h:41
Generated on Sun Mar 7 2021 14:13:14 for NOvA by
1.8.11