27#ifndef INCLUDED_CONFIGDB
28#define INCLUDED_CONFIGDB
219 using TConfigMap = std::map<CStr, CConfigValueSet, std::less<>>;
220 std::array<TConfigMap, CFG_LAST>
m_Map;
221 std::multimap<CStr, std::function<void()>>
m_Hooks;
238 m_Ptr = std::move(h.m_Ptr);
251 std::multimap<CStr, std::function<void()>>::iterator
m_Ptr;
255#define g_ConfigDB (*CConfigDB::Instance())
std::vector< CStr > CConfigValueSet
Definition: ConfigDB.h:61
EConfigNamespace
Namespace priorities:
Definition: ConfigDB.h:51
@ CFG_HWDETECT
Definition: ConfigDB.h:55
@ CFG_COMMAND
Definition: ConfigDB.h:57
@ CFG_SYSTEM
Definition: ConfigDB.h:54
@ CFG_DEFAULT
Definition: ConfigDB.h:52
@ CFG_LAST
Definition: ConfigDB.h:58
@ CFG_MOD
Definition: ConfigDB.h:53
@ CFG_USER
Definition: ConfigDB.h:56
Definition: ConfigDB.h:229
CConfigDBHook(const CConfigDBHook &)=delete
~CConfigDBHook()
Definition: ConfigDB.h:242
CConfigDBHook(CConfigDBHook &&h)
Definition: ConfigDB.h:236
CConfigDBHook(CConfigDB &cdb, std::multimap< CStr, std::function< void()> >::iterator p)
Definition: ConfigDB.h:247
std::multimap< CStr, std::function< void()> >::iterator m_Ptr
Definition: ConfigDB.h:251
CConfigDB & m_ConfigDB
Definition: ConfigDB.h:252
Definition: ConfigDB.h:69
void GetValue(EConfigNamespace ns, const std::string_view name, std::string &value)
Attempt to retrieve the value of a config variable with the given name; will search CFG_COMMAND first...
~CConfigDB()
Definition: ConfigDB.cpp:168
bool Reload(EConfigNamespace)
Reload the config file associated with the specified config namespace (the last config file path set ...
Definition: ConfigDB.cpp:308
CConfigDB(const CConfigDB &)=delete
static T GetIfInitialised(const std::string_view name, T defaultValue, const EConfigNamespace ns=CFG_USER)
Definition: ConfigDB.h:107
std::map< CStr, CConfigValueSet > GetValuesWithPrefix(EConfigNamespace ns, const CStr &prefix) const
Retrieve a map of values corresponding to settings whose names begin with the given prefix; will sear...
Definition: ConfigDB.cpp:230
void GetValue(EConfigNamespace ns, const std::string_view name, double &value)
Attempt to retrieve the value of a config variable with the given name; will search CFG_COMMAND first...
bool RemoveValue(EConfigNamespace ns, const CStr &name)
Remove a config value in the specified namespace.
Definition: ConfigDB.cpp:286
void GetValue(EConfigNamespace ns, const std::string_view name, float &value)
Attempt to retrieve the value of a config variable with the given name; will search CFG_COMMAND first...
T Get(const std::string_view name, T value, const EConfigNamespace ns=CFG_USER)
Definition: ConfigDB.h:100
void UnregisterHook(CConfigDBHook &&hook)
Definition: ConfigDB.cpp:558
void SetValueString(EConfigNamespace ns, const CStr &name, const CStr &value)
Save a config value in the specified namespace.
Definition: ConfigDB.cpp:251
void SetValueBool(EConfigNamespace ns, const CStr &name, const bool value)
Definition: ConfigDB.cpp:268
void SetChanges(EConfigNamespace ns, bool value)
Definition: ConfigDB.cpp:180
bool WriteValueToFile(EConfigNamespace ns, const CStr &name, const CStr &value, const VfsPath &path)
Write a config value to the file specified by 'path'.
Definition: ConfigDB.cpp:535
std::recursive_mutex m_Mutex
Definition: ConfigDB.h:225
CConfigDBHook RegisterHookAndCall(const CStr &name, std::function< void()> hook)
Register a simple lambda that will be called anytime the value changes in any namespace This is simpl...
Definition: ConfigDB.cpp:551
void SetConfigFile(EConfigNamespace ns, const VfsPath &path)
Set the path to the config file used to populate the specified namespace Note that this function does...
Definition: ConfigDB.cpp:300
std::multimap< CStr, std::function< void()> > m_Hooks
Definition: ConfigDB.h:221
CConfigDB()
Definition: ConfigDB.cpp:163
std::array< TConfigMap, CFG_LAST > m_Map
Definition: ConfigDB.h:220
void GetValue(EConfigNamespace ns, const std::string_view name, bool &value)
Attempt to retrieve the value of a config variable with the given name; will search CFG_COMMAND first...
static void Shutdown()
Definition: ConfigDB.cpp:147
void GetValues(EConfigNamespace ns, const CStr &name, CConfigValueSet &values) const
Attempt to retrieve a vector of values corresponding to the given setting; will search CFG_COMMAND fi...
Definition: ConfigDB.cpp:188
void GetValue(EConfigNamespace ns, const std::string_view name, std::uint32_t &value)
Attempt to retrieve the value of a config variable with the given name; will search CFG_COMMAND first...
static void Initialise()
Definition: ConfigDB.cpp:142
EConfigNamespace GetValueNamespace(EConfigNamespace ns, const CStr &name) const
Returns the namespace that the value returned by GetValues was defined in, or CFG_LAST if it wasn't d...
Definition: ConfigDB.cpp:211
void SetValueList(EConfigNamespace ns, const CStr &name, std::vector< CStr > values)
Definition: ConfigDB.cpp:274
void GetValue(EConfigNamespace ns, const std::string_view name, int &value)
Attempt to retrieve the value of a config variable with the given name; will search CFG_COMMAND first...
static CConfigDB * Instance()
Definition: ConfigDB.cpp:158
std::map< CStr, CConfigValueSet, std::less<> > TConfigMap
Definition: ConfigDB.h:219
static bool IsInitialised()
Definition: ConfigDB.cpp:153
bool HasChanges(EConfigNamespace ns) const
Returns true if changed with respect to last write on file.
Definition: ConfigDB.cpp:172
friend CConfigDBHook
Definition: ConfigDB.h:70
bool WriteFile(EConfigNamespace ns, const VfsPath &path) const
Write the current state of the specified config namespace to the file specified by 'path'.
Definition: ConfigDB.cpp:490
CConfigDB(CConfigDB &&)=delete
std::array< VfsPath, CFG_LAST > m_ConfigFile
Definition: ConfigDB.h:222
std::array< bool, CFG_LAST > m_HasChanges
Definition: ConfigDB.h:223
#define T(string_literal)
Definition: secure_crt.cpp:81