#pragma once #include #include "../ValueBroker.h" namespace crepe { class DB; } namespace crepe::api { class SaveManager { public: //! Get a reference to a value and initialize it with a value if it does not yet exist template ValueBroker get(const std::string & key, const T & default_value); //! Get a reference to a value template ValueBroker get(const std::string & key); //! Set a value directly template void set(const std::string & key, const T & value); //! Check if the save file has a value for this \c key bool has(const std::string & key); private: SaveManager(); virtual ~SaveManager() = default; private: template std::string serialize(const T &); template T deserialize(const std::string &); public: // singleton static SaveManager & get_instance(); SaveManager(const SaveManager &) = delete; SaveManager(SaveManager &&) = delete; SaveManager & operator = (const SaveManager &) = delete; SaveManager & operator = (SaveManager &&) = delete; private: static DB & get_db(); }; }