Changeset View
Changeset View
Standalone View
Standalone View
source/ps/ConfigDB.h
Show First 20 Lines • Show All 190 Lines • ▼ Show 20 Lines | public: | ||||
* This is simple on purpose, the hook is responsible for checking if it should do something. | * This is simple on purpose, the hook is responsible for checking if it should do something. | ||||
* When RegisterHookAndCall is called, the hook is immediately triggered. | * When RegisterHookAndCall is called, the hook is immediately triggered. | ||||
* NB: CConfigDBHook will auto-unregister the hook when destroyed, | * NB: CConfigDBHook will auto-unregister the hook when destroyed, | ||||
* so you can use it to tie the lifetime of the hook to your object. | * so you can use it to tie the lifetime of the hook to your object. | ||||
* The hook will be deleted alongside ConfigDB anyways. | * The hook will be deleted alongside ConfigDB anyways. | ||||
*/ | */ | ||||
[[nodiscard]] CConfigDBHook RegisterHookAndCall(const CStr& name, std::function<void()> hook); | [[nodiscard]] CConfigDBHook RegisterHookAndCall(const CStr& name, std::function<void()> hook); | ||||
/** | |||||
* Same as RegisterHookAndCall, but doesn't immediately call the hook. | |||||
*/ | |||||
[[nodiscard]] CConfigDBHook RegisterHook(const CStr& name, std::function<void()> hook); | |||||
void UnregisterHook(CConfigDBHook&& hook); | void UnregisterHook(CConfigDBHook&& hook); | ||||
void UnregisterHook(std::unique_ptr<CConfigDBHook> hook); | void UnregisterHook(std::unique_ptr<CConfigDBHook> hook); | ||||
private: | private: | ||||
std::array<std::map<CStr, CConfigValueSet>, CFG_LAST> m_Map; | std::array<std::map<CStr, CConfigValueSet>, CFG_LAST> m_Map; | ||||
std::multimap<CStr, std::function<void()>> m_Hooks; | std::multimap<CStr, std::function<void()>> m_Hooks; | ||||
std::array<VfsPath, CFG_LAST> m_ConfigFile; | std::array<VfsPath, CFG_LAST> m_ConfigFile; | ||||
std::array<bool, CFG_LAST> m_HasChanges; | std::array<bool, CFG_LAST> m_HasChanges; | ||||
Show All 38 Lines |
Wildfire Games · Phabricator