36 #include <unordered_map>
38 #ifdef SVFS_THREAD_SAFE
49 #pragma mark - Exceptions
51 namespace Exceptions {
58 [[nodiscard]]
const std::string &
message()
const {
return msg; }
88 #pragma mark - The SVFS class
101 void insert(
const std::string &
id,
double mod_time);
104 void remove(
const std::string &
id);
113 [[nodiscard]]
bool has(
const std::string &
id)
const noexcept {
return m_svfs.find(
id) !=
m_svfs.end(); }
116 [[nodiscard]]
size_t size() const noexcept {
return m_svfs.size(); }
119 [[nodiscard]]
size_t size_of() const noexcept;
122 [[nodiscard]]
size_t num_bytes() const noexcept;
125 [[nodiscard]]
size_t num_blocks() const noexcept;
128 [[nodiscard]] std::vector<std::
string>
keys() const noexcept;
146 #ifdef SVFS_THREAD_SAFE
Exception specialisation for the SparseVirtualFileSystem.
ExceptionSparseVirtualFileSystem(const std::string &in_msg)
const std::string & message() const
Exception specialisation on insert error.
ExceptionSparseVirtualFileSystemInsert(const std::string &msg)
Exception specialisation for out of range error.
ExceptionSparseVirtualFileSystemOutOfRange(const std::string &msg)
Exception specialisation on remove error.
ExceptionSparseVirtualFileSystemRemove(const std::string &msg)
Implementation of a Sparse Virtual File.
A SparseVirtualFileSystem is a key/value store where the key is a file ID as a string and the value i...
size_t size() const noexcept
const SparseVirtualFile & at(const std::string &id) const
Return the const SparseVirtualFile at the given ID.
void insert(const std::string &id, double mod_time)
Inserts a new SparseVirtualFile corresponding to the given ID and file modification timestamp.
tSparseVirtualFileConfig m_config
The configuration for all SVF values.
SparseVirtualFileSystem(const SparseVirtualFileSystem &rhs)=delete
Eliminate copying.
SparseVirtualFileSystem(const tSparseVirtualFileConfig &config=tSparseVirtualFileConfig())
Constructor takes a tSparseVirtualFileConfig that is passed to every new SparseVirtualFile.
size_t num_blocks() const noexcept
Returns the total number of blocks in the SparseVirtualFileSystem.
size_t num_bytes() const noexcept
Returns the total number of readable bytes in the SparseVirtualFileSystem.
const tSparseVirtualFileConfig & config() const noexcept
The configuration.
std::unordered_map< std::string, SparseVirtualFile > m_svfs
The key/value store of SVF values.
std::vector< std::string > keys() const noexcept
Return all the SVF IDs (unordered).
~SparseVirtualFileSystem() noexcept
Destructor.
bool has(const std::string &id) const noexcept
void remove(const std::string &id)
Remove the SparseVirtualFile corresponding to the given ID.
size_t size_of() const noexcept
Returns the total in-memory size of the SparseVirtualFileSystem structure in bytes.
SparseVirtualFileSystem operator=(const SparseVirtualFileSystem &rhs)=delete
Eliminate copying.
The namespace for all svfsc code.
struct SVFS::SparseVirtualFileConfig tSparseVirtualFileConfig
Configuration for the Sparse Virtual File.
Configuration for the Sparse Virtual File.