CommonLibVR
Loading...
Searching...
No Matches
Setting.h
Go to the documentation of this file.
1#pragma once
2
3#include "REX/REX/Singleton.h"
4
5namespace REX
6{
7 class ISetting
8 {
9 public:
10 virtual void Load(void* a_data, bool a_isBase) = 0;
11 virtual void Save(void* a_data) = 0;
12 };
13
15 {
16 public:
17 virtual void Init(const char* a_file, const char* a_fileCustom) = 0;
18 virtual void Load() = 0;
19 virtual void Save() = 0;
20 virtual void Register(ISetting* a_setting) = 0;
21 };
22
23 template <class T, class Store>
24 class TSetting :
25 public ISetting
26 {
27 public:
28 TSetting() = delete;
29
30 TSetting(T a_default) :
31 m_value(a_default),
32 m_valueDefault(a_default)
33 {
34 Store::GetSingleton()->Register(this);
35 }
36
37 public:
38 T GetValue() const { return m_value; }
39
40 T GetValueDefault() const { return m_valueDefault; }
41
42 void SetValue(T a_value) { m_value = a_value; }
43
44 protected:
47 };
48
49 template <class T>
51 public ISettingStore,
52 public Singleton<T>
53 {
54 public:
55 virtual void Init(const char* a_fileBase, const char* a_fileUser) override
56 {
57 m_fileBase = a_fileBase;
58 m_fileUser = a_fileUser;
59 }
60
61 virtual void Register(ISetting* a_setting) override
62 {
63 m_settings.emplace_back(a_setting);
64 }
65
66 protected:
67 std::string_view m_fileBase;
68 std::string_view m_fileUser;
69 std::vector<ISetting*> m_settings;
70 };
71}
Definition Setting.h:15
virtual void Register(ISetting *a_setting)=0
virtual void Save()=0
virtual void Init(const char *a_file, const char *a_fileCustom)=0
virtual void Load()=0
Definition Setting.h:8
virtual void Load(void *a_data, bool a_isBase)=0
virtual void Save(void *a_data)=0
Definition Singleton.h:7
Definition Setting.h:53
std::vector< ISetting * > m_settings
Definition Setting.h:69
virtual void Register(ISetting *a_setting) override
Definition Setting.h:61
std::string_view m_fileUser
Definition Setting.h:68
virtual void Init(const char *a_fileBase, const char *a_fileUser) override
Definition Setting.h:55
std::string_view m_fileBase
Definition Setting.h:67
Definition Setting.h:26
TSetting(T a_default)
Definition Setting.h:30
T GetValue() const
Definition Setting.h:38
T GetValueDefault() const
Definition Setting.h:40
void SetValue(T a_value)
Definition Setting.h:42
T m_valueDefault
Definition Setting.h:46
T m_value
Definition Setting.h:45
TSetting()=delete
Definition BSDirectInputManager.h:8