27#ifndef INCLUDED_CONFIGDB
28#define INCLUDED_CONFIGDB
64#define g_ConfigDB (*CConfigDB::Instance())
204 std::multimap<CStr, std::function<void()>>
m_Hooks;
221 m_Ptr = std::move(h.m_Ptr);
234 std::multimap<CStr, std::function<void()>>::iterator
m_Ptr;
241#define CFG_GET_VAL(name, destination)\
242 g_ConfigDB.GetValue(CFG_USER, name, destination)
std::vector< CStr > CConfigValueSet
Definition: ConfigDB.h:57
EConfigNamespace
Namespace priorities:
Definition: ConfigDB.h:47
@ CFG_HWDETECT
Definition: ConfigDB.h:51
@ CFG_COMMAND
Definition: ConfigDB.h:53
@ CFG_SYSTEM
Definition: ConfigDB.h:50
@ CFG_DEFAULT
Definition: ConfigDB.h:48
@ CFG_LAST
Definition: ConfigDB.h:54
@ CFG_MOD
Definition: ConfigDB.h:49
@ CFG_USER
Definition: ConfigDB.h:52
Definition: ConfigDB.h:212
CConfigDBHook(const CConfigDBHook &)=delete
~CConfigDBHook()
Definition: ConfigDB.h:225
CConfigDBHook(CConfigDBHook &&h)
Definition: ConfigDB.h:219
CConfigDBHook(CConfigDB &cdb, std::multimap< CStr, std::function< void()> >::iterator p)
Definition: ConfigDB.h:230
std::multimap< CStr, std::function< void()> >::iterator m_Ptr
Definition: ConfigDB.h:234
CConfigDB & m_ConfigDB
Definition: ConfigDB.h:235
Definition: ConfigDB.h:67
~CConfigDB()
Definition: ConfigDB.cpp:149
bool Reload(EConfigNamespace)
Reload the config file associated with the specified config namespace (the last config file path set ...
Definition: ConfigDB.cpp:289
CConfigDB(const CConfigDB &)=delete
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:211
bool RemoveValue(EConfigNamespace ns, const CStr &name)
Remove a config value in the specified namespace.
Definition: ConfigDB.cpp:267
void UnregisterHook(CConfigDBHook &&hook)
Definition: ConfigDB.cpp:524
void SetValueString(EConfigNamespace ns, const CStr &name, const CStr &value)
Save a config value in the specified namespace.
Definition: ConfigDB.cpp:232
void SetValueBool(EConfigNamespace ns, const CStr &name, const bool value)
Definition: ConfigDB.cpp:249
void GetValue(EConfigNamespace ns, const CStr &name, bool &value)
Attempt to retrieve the value of a config variable with the given name; will search CFG_COMMAND first...
void SetChanges(EConfigNamespace ns, bool value)
Definition: ConfigDB.cpp:161
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:501
std::recursive_mutex m_Mutex
Definition: ConfigDB.h:208
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:517
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:281
std::multimap< CStr, std::function< void()> > m_Hooks
Definition: ConfigDB.h:204
CConfigDB()
Definition: ConfigDB.cpp:144
void GetValue(EConfigNamespace ns, const CStr &name, double &value)
Attempt to retrieve the value of a config variable with the given name; will search CFG_COMMAND first...
void GetValue(EConfigNamespace ns, const CStr &name, float &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:129
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:169
void GetValue(EConfigNamespace ns, const CStr &name, u32 &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:124
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:192
void SetValueList(EConfigNamespace ns, const CStr &name, std::vector< CStr > values)
Definition: ConfigDB.cpp:255
static CConfigDB * Instance()
Definition: ConfigDB.cpp:139
static bool IsInitialised()
Definition: ConfigDB.cpp:134
bool HasChanges(EConfigNamespace ns) const
Returns true if changed with respect to last write on file.
Definition: ConfigDB.cpp:153
friend CConfigDBHook
Definition: ConfigDB.h:68
void GetValue(EConfigNamespace ns, const CStr &name, int &value)
Attempt to retrieve the value of a config variable with the given name; will search CFG_COMMAND first...
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:461
CConfigDB(CConfigDB &&)=delete
std::array< VfsPath, CFG_LAST > m_ConfigFile
Definition: ConfigDB.h:205
std::array< std::map< CStr, CConfigValueSet >, CFG_LAST > m_Map
Definition: ConfigDB.h:203
void GetValue(EConfigNamespace ns, const CStr &name, std::string &value)
Attempt to retrieve the value of a config variable with the given name; will search CFG_COMMAND first...
std::array< bool, CFG_LAST > m_HasChanges
Definition: ConfigDB.h:206
uint32_t u32
Definition: types.h:39