Rose
Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
rose::WebFileCache Class Reference

A cache with a source on the World Wide Web, and local store on the filesystem. More...

#include <Cache.h>

Inheritance diagram for rose::WebFileCache:
Inheritance graph
[legend]
Collaboration diagram for rose::WebFileCache:
Collaboration graph
[legend]

Public Member Functions

 WebFileCache (const std::string &sourceURI, const std::filesystem::path &rootPath, const std::string &cacheName)
 Constructor. More...
 
 WebFileCache (const std::string &sourceURI, const std::filesystem::path &rootPath, const std::string &cacheName, std::chrono::system_clock::duration cacheValidityDuration)
 Constructor. More...
 
void connect (Signal< int > &futureCheck, Signal< int > &validityCheck)
 Connect the WebFileCache to signals to trigger regular data checks. More...
 
 operator bool () const
 Determine local store validity.
 
auto cacheRootPath () const
 Get the Cache root path. More...
 
void fetchAll ()
 Attempt to fetch all expired or not yet fetched objects.
 
- Public Member Functions inherited from rose::Cache
template<typename S >
std::optional< uint32_t > findByUserName (S userName)
 

Public Attributes

Signal< uint32_t > itemFetched {}
 Signal to transmit when a cache object is fetched.
 

Protected Member Functions

void checkFutures ()
 Check for completed futures and process.
 

Static Protected Member Functions

static uint32_t asyncFetch (WebFileCache *self, uint32_t id, time_t cacheTime)
 A std::async capable method of fetching a single CacheObject. More...
 

Protected Attributes

SignalSerialNumber mSignalSerialNumber {}
 The signal serial number for this object.
 
std::mutex mMutex
 Mutex for locking the WebFileCache.
 
std::shared_ptr< Slot< int > > mCheckValidity
 Slot for check validity timing signal.
 
std::shared_ptr< Slot< int > > mCheckFutures
 Slot for check futures timeing signal.
 
std::vector< std::future< uint32_t > > mFutureList
 The list of outstanding futures.
 
- Protected Attributes inherited from rose::Cache
std::unique_ptr< CacheLocalStorelocalStore
 The local store for the Cache.
 
std::unique_ptr< CacheSourcesource
 The source for cache objects.
 

Detailed Description

A cache with a source on the World Wide Web, and local store on the filesystem.

Constructor & Destructor Documentation

◆ WebFileCache() [1/2]

rose::WebFileCache::WebFileCache ( const std::string &  sourceURI,
const std::filesystem::path &  rootPath,
const std::string &  cacheName 
)

Constructor.

See: CacheWebSource and CacheFileSystem

Parameters
sourceURIThe source URI to initialize the cache source.
rootPathThe filesystem root path to initialize the local store.
cacheNameThe cache name to initialize the local store.

◆ WebFileCache() [2/2]

rose::WebFileCache::WebFileCache ( const std::string &  sourceURI,
const std::filesystem::path &  rootPath,
const std::string &  cacheName,
std::chrono::system_clock::duration  cacheValidityDuration 
)

Constructor.

See: CacheWebSource and CacheFileSystem

Parameters
sourceURIThe source URI to initialize the cache source.
rootPathThe filesystem root path to initialize the local store.
cacheNameThe cache name to initialize the local store.
cacheValidityDurationThe duration cache objects should be considered valid for.

Member Function Documentation

◆ asyncFetch()

uint32_t rose::WebFileCache::asyncFetch ( WebFileCache self,
uint32_t  id,
time_t  cacheTime 
)
staticprotected

A std::async capable method of fetching a single CacheObject.

Parameters
selfA pointer to the WebFileCache (this).
idThe identifier of the CacheObject
cacheTimeThe cache time of the object.
Returns
The identifier if the fetch was successful, empty if not.

◆ cacheRootPath()

auto rose::WebFileCache::cacheRootPath ( ) const
inline

Get the Cache root path.

Returns
std::filesystem::path to the cache root.

◆ connect()

void rose::WebFileCache::connect ( Signal< int > &  futureCheck,
Signal< int > &  validityCheck 
)

Connect the WebFileCache to signals to trigger regular data checks.

Parameters
futureCheckThe signal used to time checks for completed asynchronous fetches.
validityCheckThe signal used to time checks for cache object validity.

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