aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api/SaveManager.h
blob: 78cd4ba7c93f035dc23caab1951872cf10f747f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#pragma once

#include "../ValueBroker.h"

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 <typename T>
	ValueBroker<T> & get(const char * key, const T & default_value);

	//! Get a reference to a value
	template <typename T>
	ValueBroker<T> & get(const char * key);

	//! Set a value directly
	template <typename T>
	void set(const char * key, const T & value);

	//! Check if the save file has a value for this \c key
	bool has(const char * key);

private:
	SaveManager() = default;
	virtual ~SaveManager() = default;

public:
	// singleton
	static SaveManager & get_instance();
	SaveManager(const SaveManager &) = delete;
	SaveManager(SaveManager &&) = delete;
	SaveManager & operator = (const SaveManager &) = delete;
	SaveManager & operator = (SaveManager &&) = delete;
};

}

#include "SaveManager.hpp"