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

A CacheLocalStore implemented on the local filesystem. More...

#include <Cache.h>

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

Public Member Functions

 operator bool () const noexcept
 Return false if mErrorCode is zero. More...
 
 CacheFileSystem (std::filesystem::path rootPath)
 Constructor. More...
 
 CacheFileSystem (const std::string &rootPath)
 Constructor. More...
 
 CacheFileSystem (const std::filesystem::path &rootPath, const std::string &cacheName)
 Constructor. More...
 
const std::filesystem::path & rootPath () const
 Accessor for cache root path. More...
 
CacheError create (const CacheObject &object) override
 Create an item on a Cache. More...
 
bool find (const CacheObject &object) override
 Find an item on a Cache. More...
 
std::ofstream openWrite (const CacheObject &object, bool temp) override
 Open a cache object for writing. More...
 
std::ifstream openRead (const CacheObject &object) override
 Open a cache object for reading. More...
 
void moveFromTemp (const CacheObject &object) override
 Move object from temporary cache location to permanent cache location. More...
 
void removeTemp (const CacheObject &object) override
 Remove a temporary cache location. More...
 
void setCacheTime (const CacheObject &object, std::chrono::system_clock::duration cacheTimeInc) override
 Set file update time to the current system time.
 
std::optional< std::string > fileSystemName (const CacheObject &object) const override
 Get a filesystem name locator for the object, if available. More...
 

Protected Attributes

std::error_code mErrorCode
 Store the last error code.
 
std::filesystem::path mRootPath
 Store the filesystem path to the cache storage.
 

Detailed Description

A CacheLocalStore implemented on the local filesystem.

Constructor & Destructor Documentation

◆ CacheFileSystem() [1/3]

rose::CacheFileSystem::CacheFileSystem ( std::filesystem::path  rootPath)
explicit

Constructor.

Parameters
rootPathThe root path of the filesystem cache tree.

◆ CacheFileSystem() [2/3]

rose::CacheFileSystem::CacheFileSystem ( const std::string &  rootPath)
inlineexplicit

Constructor.

Parameters
rootPathThe root path of the filesystem cache tree.

◆ CacheFileSystem() [3/3]

rose::CacheFileSystem::CacheFileSystem ( const std::filesystem::path &  rootPath,
const std::string &  cacheName 
)
inline

Constructor.

Parameters
rootPathThe root path to all application related filesystem cache.
cacheNameThe specific cache name, will be a directory under rootPath.

Member Function Documentation

◆ create()

CacheError rose::CacheFileSystem::create ( const CacheObject object)
overridevirtual

Create an item on a Cache.

Parameters
objectThe cache object to be created.
Returns
A CacheError code.

Implements rose::CacheLocalStore.

◆ fileSystemName()

std::optional< std::string > rose::CacheFileSystem::fileSystemName ( const CacheObject object) const
overridevirtual

Get a filesystem name locator for the object, if available.

Returns
A std::optional<std::string>

Reimplemented from rose::CacheLocalStore.

◆ find()

bool rose::CacheFileSystem::find ( const CacheObject object)
overridevirtual

Find an item on a Cache.

Parameters
objectThe cache object to be found.
Returns
A CacheError code.

Implements rose::CacheLocalStore.

◆ moveFromTemp()

void rose::CacheFileSystem::moveFromTemp ( const CacheObject object)
overridevirtual

Move object from temporary cache location to permanent cache location.

Parameters
objectThe object to move.

Implements rose::CacheLocalStore.

◆ openRead()

std::ifstream rose::CacheFileSystem::openRead ( const CacheObject object)
overridevirtual

Open a cache object for reading.

Returns
A std::istream to read from.

Implements rose::CacheLocalStore.

◆ openWrite()

std::ofstream rose::CacheFileSystem::openWrite ( const CacheObject object,
bool  temp 
)
overridevirtual

Open a cache object for writing.

Returns
A std::ostream to write to.

Implements rose::CacheLocalStore.

◆ operator bool()

rose::CacheFileSystem::operator bool ( ) const
inlineexplicitnoexcept

Return false if mErrorCode is zero.

Returns
true if there is an error code, false otherwise.

◆ removeTemp()

void rose::CacheFileSystem::removeTemp ( const CacheObject object)
overridevirtual

Remove a temporary cache location.

This is used when an attempt to update a cached object either failed, or did not result in new data.

Parameters
objectThe object to remove.

Implements rose::CacheLocalStore.

◆ rootPath()

const std::filesystem::path& rose::CacheFileSystem::rootPath ( ) const
inline

Accessor for cache root path.

Returns
The filesystem path to the cache.

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