aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/manager/SaveManager.h
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-12-11 13:58:19 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-12-11 13:58:19 +0100
commitd228d4b3856606ad4395723b2703759a0ebe9832 (patch)
treebfd3019ca2c9bec258fffca9a9204ddc88768264 /src/crepe/manager/SaveManager.h
parent770496ee9d0e45480c0e0f8951adb8eee247bfe1 (diff)
parentc45b60941b82dec2097d958b396a117b1634eada (diff)
Merge branch 'master' into loek/replay
Diffstat (limited to 'src/crepe/manager/SaveManager.h')
-rw-r--r--src/crepe/manager/SaveManager.h33
1 files changed, 11 insertions, 22 deletions
diff --git a/src/crepe/manager/SaveManager.h b/src/crepe/manager/SaveManager.h
index 3d8c852..27e625c 100644
--- a/src/crepe/manager/SaveManager.h
+++ b/src/crepe/manager/SaveManager.h
@@ -1,9 +1,12 @@
#pragma once
#include <memory>
+#include <functional>
#include "../ValueBroker.h"
+#include "Manager.h"
+
namespace crepe {
class DB;
@@ -18,7 +21,7 @@ class DB;
*
* The underlying database is a key-value store.
*/
-class SaveManager {
+class SaveManager : public Manager {
public:
/**
* \brief Get a read/write reference to a value and initialize it if it does not yet exist
@@ -63,8 +66,8 @@ public:
*/
bool has(const std::string & key);
-private:
- SaveManager();
+public:
+ SaveManager(Mediator & mediator);
virtual ~SaveManager() = default;
private:
@@ -89,26 +92,12 @@ private:
template <typename T>
T deserialize(const std::string & value) const noexcept;
-public:
- // singleton
- static SaveManager & get_instance();
- SaveManager(const SaveManager &) = delete;
- SaveManager(SaveManager &&) = delete;
- SaveManager & operator=(const SaveManager &) = delete;
- SaveManager & operator=(SaveManager &&) = delete;
-
+protected:
+ //! Create or return DB
+ virtual DB & get_db();
private:
- /**
- * \brief Create an instance of DB and return its reference
- *
- * \returns DB instance
- *
- * This function exists because DB is a facade class, which can't directly be used in the API
- * without workarounds
- *
- * TODO: better solution
- */
- static DB & get_db();
+ //! Database
+ std::unique_ptr<void, std::function<void(void*)>> db = nullptr;
};
} // namespace crepe