6#include <nlohmann/json_fwd.hpp>
90 std::optional<std::vector<DeviceParameter>>
load(uint32_t vendorId, uint32_t productCode,
91 uint32_t revisionNumber)
const;
98 void store(uint32_t vendorId, uint32_t productCode, uint32_t revisionNumber,
99 const std::vector<DeviceParameter>& parameters)
const;
114 static std::string
makeId(uint32_t vendorId, uint32_t productCode, uint32_t revisionNumber);
122 std::vector<CacheEntry>
list()
const;
130 std::expected<std::vector<uint8_t>, std::string>
readRaw(std::string_view
id)
const;
134 std::expected<void, std::string>
remove(std::string_view
id)
const;
140 std::filesystem::path resolveDir()
const;
144 std::filesystem::path pathFor(uint32_t vendorId, uint32_t productCode,
145 uint32_t revisionNumber)
const;
On-disk cache of CoE parameter definitions, keyed by device identity.
Definition parameter_cache.h:53
bool enabledForVendor(uint32_t vendorId) const
Whether the cache is active for vendorId under the current policy.
Definition parameter_cache.cc:129
static constexpr int kFormatVersion
Bumped when an older file's contents can no longer be trusted, whatever its shape.
Definition parameter_cache.h:68
void store(uint32_t vendorId, uint32_t productCode, uint32_t revisionNumber, const std::vector< DeviceParameter > ¶meters) const
Persists parameter definitions for an identity (atomic temp-file + rename).
Definition parameter_cache.cc:194
std::expected< void, std::string > remove(std::string_view id) const
Deletes one cache file addressed by its id. Policy-independent.
Definition parameter_cache.cc:281
static std::string makeId(uint32_t vendorId, uint32_t productCode, uint32_t revisionNumber)
Builds the opaque id a client uses to address one cache file, from an identity triple....
Definition parameter_cache.cc:147
std::optional< std::vector< DeviceParameter > > load(uint32_t vendorId, uint32_t productCode, uint32_t revisionNumber) const
Loads the cached parameter definitions for an identity.
Definition parameter_cache.cc:158
std::expected< std::vector< uint8_t >, std::string > readRaw(std::string_view id) const
Reads the raw JSON bytes of one cache file, addressed by its id (for download).
Definition parameter_cache.cc:267
void configure(ParameterCacheConfig config)
Replaces the active policy/location. Called by DeviceManager::init.
Definition parameter_cache.cc:127
std::vector< CacheEntry > list() const
Lists every valid cache file in the cache directory.
Definition parameter_cache.cc:227
Definition bus_health_source.h:7
void to_json(nlohmann::json &j, const Cia402Status &s)
Serialises a Cia402Status. Emits state/modeName as human-readable strings alongside the numeric statu...
Definition cia402_drive.cc:13
Policy and location for the on-disk parameter cache.
Definition parameter_cache.h:26
std::string directory
"" = a standard per-user cache directory (see resolveDir).
Definition parameter_cache.h:29
bool cacheAllVendors
false: cache Synapticon (0x22D2) only; true: cache every vendor.
Definition parameter_cache.h:27
bool enabled
Master switch for the whole cache (false disables it entirely).
Definition parameter_cache.h:30
Summary of one cache file on disk, for the management UI.
Definition parameter_cache.h:102
uint32_t revisionNumber
Revision number from the file header.
Definition parameter_cache.h:106
std::uintmax_t sizeBytes
File size on disk, in bytes.
Definition parameter_cache.h:108
std::string id
Opaque "<vendor>-<product>-<revision>" key (see makeId).
Definition parameter_cache.h:103
uint32_t vendorId
Vendor ID from the file header.
Definition parameter_cache.h:104
uint32_t productCode
Product code from the file header.
Definition parameter_cache.h:105
uint32_t parameterCount
Number of cached parameter definitions in the file.
Definition parameter_cache.h:107