105 std::string mObjectSrcName{};
106 std::string mObjectUsrName{};
110 bool mFirstProcess{
false};
121 explicit CacheObject(std::string srcName, std::string userName =
"")
122 : mObjectSrcName(
std::move(srcName)), mObjectUsrName(
std::move(userName)), mStatusCode(0) {}
128 [[nodiscard]]
const std::string&
objectSrcName()
const {
return mObjectSrcName; }
134 [[nodiscard]]
const std::string&
objectUsrName()
const {
return mObjectUsrName; }
169 std::chrono::system_clock::duration mCacheValidDuration{};
181 virtual void fetch(
CacheObject &cacheObject, std::ostream &ostrm, time_t cacheTime) = 0;
194 class Cache :
public std::map<uint32_t,CacheObject> {
201 virtual ~
Cache() =
default;
204 std::optional<uint32_t> findByUserName(S userName) {
205 std::string un{userName};
206 for (
auto & it : *
this) {
207 if (it.second.objectUsrName() == un)
231 explicit operator bool() const noexcept {
232 return mErrorCode.operator bool();
253 mRootPath.append(cacheName);
255 std::filesystem::create_directory(mRootPath, mErrorCode);
262 [[nodiscard]]
const std::filesystem::path&
rootPath()
const {
return mRootPath; }
323 long mResponseCode{0};
344 CacheWebSource(std::string sourceURI, std::chrono::system_clock::duration cacheValidityDuration);
352 void fetch(
CacheObject &cacheObject, std::ostream &ostrm, time_t cacheTime)
override;
360 [[nodiscard]]
const std::string& sourceURI()
const {
return mSourceURI; }
371 SignalSerialNumber mSignalSerialNumber{};
389 static uint32_t asyncFetch(
WebFileCache *
self, uint32_t
id, time_t cacheTime);
402 const std::filesystem::path& rootPath,
const std::string& cacheName);
412 WebFileCache(
const std::string& sourceURI,
const std::filesystem::path& rootPath,
413 const std::string& cacheName, std::chrono::system_clock::duration cacheValidityDuration);
424 explicit operator bool()
const {
return localStore.operator bool(); }
std::unique_ptr< CacheLocalStore > localStore
The local store for the Cache.
Definition: Cache.h:196
virtual void setCacheTime(const CacheObject &object, std::chrono::system_clock::duration cacheTimeInc)=0
Modify the object cache time.
std::string CacheObjectURI
Type for a cache object URI value.
Definition: Cache.h:27
virtual void removeTemp(const CacheObject &object)=0
Remove a temporary cache location.
The base class for an object to be cached.
Definition: Cache.h:103
virtual std::optional< std::string > fileSystemName(const CacheObject &object) const
Get a filesystem name locator for the object, if available.
Definition: Cache.h:96
virtual void moveFromTemp(const CacheObject &object)=0
Move object from temporary cache location to permanent cache location.
CacheError
Error values return by the cache.
Definition: Constants.h:110
A collection CacheObject objects associated with.
Definition: Cache.h:194
std::mutex mMutex
Mutex for locking the WebFileCache.
Definition: Cache.h:373
Virtual ase class for data sources to be cached.
Definition: Cache.h:167
const std::filesystem::path & rootPath() const
Accessor for cache root path.
Definition: Cache.h:262
CacheObject(std::string srcName, std::string userName="")
Constructor.
Definition: Cache.h:121
bool getFirstProcess() const
Get the value of the first process flag.
Definition: Cache.h:160
auto cacheValidDuration() const
Access the cache object validity period.
Definition: Cache.h:187
A CacheLocalStore implemented on the local filesystem.
Definition: Cache.h:218
std::vector< std::future< uint32_t > > mFutureList
The list of outstanding futures.
Definition: Cache.h:378
auto cacheRootPath() const
Get the Cache root path.
Definition: Cache.h:430
virtual std::ofstream openWrite(const CacheObject &object, bool temp)=0
Open a cache object for writing.
Constants and Enumerations.
std::shared_ptr< Slot< int > > mCheckFutures
Slot for check futures timeing signal.
Definition: Cache.h:376
virtual bool find(const CacheObject &object)=0
Find an item on a Cache.
A cache source on the World Wide Web.
Definition: Cache.h:320
std::error_code mErrorCode
Store the last error code.
Definition: Cache.h:220
CacheFileSystem(const std::filesystem::path &rootPath, const std::string &cacheName)
Constructor.
Definition: Cache.h:252
long responseCode() const
Get the response code returned by the server.
Definition: Cache.h:358
std::string CacheURI
Type for a cache URI value.
Definition: Cache.h:26
std::string mSourceURI
The URI for the source.
Definition: Cache.h:322
const std::string & objectUsrName() const
Accessor for the object user name.
Definition: Cache.h:134
CacheFileSystem(const std::string &rootPath)
Constructor.
Definition: Cache.h:245
const std::string & objectSrcName() const
Accessor for the object source name.
Definition: Cache.h:128
void setFirstProcess()
Called after the first process.
Definition: Cache.h:154
A cache with a source on the World Wide Web, and local store on the filesystem.
Definition: Cache.h:367
long getStatusCode() const
Get the cache fetch status code.
Definition: Cache.h:146
ToDo: There is an issue that the initial scroll interaction is lost if the click/press lands on a Wid...
Definition: CelestialOverlay.cpp:13
The transmitter portion of a Signal-Slot transmitter receiver pair.
Definition: Signals.h:40
long mStatusCode
The status code for the last fetch.
Definition: Cache.h:108
std::filesystem::path mRootPath
Store the filesystem path to the cache storage.
Definition: Cache.h:221
Establish an intra-application signaling protocol.
void setStatusCode(long statusCode)
Set the cash fetch status code.
Definition: Cache.h:140
std::shared_ptr< Slot< int > > mCheckValidity
Slot for check validity timing signal.
Definition: Cache.h:375
A pure virtual class specifying the interface to a cache store system.
Definition: Cache.h:35
std::unique_ptr< CacheSource > source
The source for cache objects.
Definition: Cache.h:197
virtual std::ifstream openRead(const CacheObject &object)=0
Open a cache object for reading.
virtual CacheError create(const CacheObject &object)=0
Create an item on a Cache.