aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api/SaveManager.h
blob: 37463cab83945f26914860c306245ac848c8d58f (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 "../Proxy.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>
	Proxy<T> & get(const char * key, const T & default_value);

	//! Get a reference to a value
	template <typename T>
	Proxy<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();
	virtual ~SaveManager();

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"