FOSSredder 0.5.0
Loading...
Searching...
No Matches
StorageManager.h
Go to the documentation of this file.
1
5
6#pragma once
7
8#include <functional>
9#include <memory>
10#include <optional>
11#include <string>
12#include <utility>
13
18
19namespace core::storage {
20
25public:
29
31 explicit StorageManager(std::shared_ptr<core::ports::storage::IRegistry> registry = nullptr);
32
33 void setAtomicStoreSave(AtomicStoreSave saveFn) override;
34 void setAtomicStoreLoad(AtomicStoreLoad loadFn) override;
36 std::optional<std::string> loadLatestPath() const override;
37 core::application::workspace::WorkspaceSessionState loadFrom(const std::string& filePath) override;
38 void save(const core::application::workspace::WorkspaceSessionState& document) override;
39 void saveAs(const std::string& filePath, const core::application::workspace::WorkspaceSessionState& document) override;
40 void createNew(const std::string& filePath) override;
41 const std::string& currentPath() const noexcept override { return currentPath_; }
42
43private:
44 std::shared_ptr<core::ports::storage::IRegistry> registry_;
45 std::string currentPath_;
46 AtomicStoreSave atomicSave_;
47 AtomicStoreLoad atomicLoad_;
48 DeletionImpactCallback onDeletionImpact_;
49 void rememberLatestPath(const std::string& filePath);
50};
51
52} // namespace core::storage
Declares deleted-id summaries reported after workspace mutations.
Registry port used by storage adapters.
Storage manager port used by application services.
Internal mutable workspace session state for application services.
std::function< void(const core::domain::DeletionImpact &)> DeletionImpactCallback
std::function< core::application::workspace::WorkspaceSessionState(const std::string &dbPath)> AtomicStoreLoad
std::function< core::domain::DeletionImpact(const std::string &dbPath, const core::application::workspace::WorkspaceSessionState &document)> AtomicStoreSave
Destroy the storage manager port.
void setAtomicStoreSave(AtomicStoreSave saveFn) override
Configure the atomic save callback.
core::ports::storage::IStorageManager::AtomicStoreLoad AtomicStoreLoad
void save(const core::application::workspace::WorkspaceSessionState &document) override
Save the current application state.
void setDeletionImpactCallback(DeletionImpactCallback cb) override
Configure the deletion impact callback.
void saveAs(const std::string &filePath, const core::application::workspace::WorkspaceSessionState &document) override
Save the current application state to a specific file path.
core::ports::storage::IStorageManager::DeletionImpactCallback DeletionImpactCallback
void createNew(const std::string &filePath) override
Create a new storage target.
std::optional< std::string > loadLatestPath() const override
Load the latest known path.
core::ports::storage::IStorageManager::AtomicStoreSave AtomicStoreSave
core::application::workspace::WorkspaceSessionState loadFrom(const std::string &filePath) override
Load an application state from a file path.
StorageManager(std::shared_ptr< core::ports::storage::IRegistry > registry=nullptr)
Creates a storage manager with an optional latest-path registry backend.
const std::string & currentPath() const noexcept override
Get the current storage path.
void setAtomicStoreLoad(AtomicStoreLoad loadFn) override
Configure the atomic load callback.