diff options
Diffstat (limited to 'src/config/ConfigWatcher.hpp')
| -rw-r--r-- | src/config/ConfigWatcher.hpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/config/ConfigWatcher.hpp b/src/config/ConfigWatcher.hpp new file mode 100644 index 00000000..0a698fc8 --- /dev/null +++ b/src/config/ConfigWatcher.hpp @@ -0,0 +1,32 @@ +#pragma once +#include <memory> +#include <vector> +#include <string> +#include <functional> + +class CConfigWatcher { + public: + CConfigWatcher(); + ~CConfigWatcher(); + + struct SConfigWatchEvent { + std::string file; + }; + + int getInotifyFD(); + void setWatchList(const std::vector<std::string>& paths); + void setOnChange(const std::function<void(const SConfigWatchEvent&)>& fn); + void onInotifyEvent(); + + private: + struct SInotifyWatch { + int wd = -1; + std::string file; + }; + + std::function<void(const SConfigWatchEvent&)> m_watchCallback; + std::vector<SInotifyWatch> m_watches; + int m_inotifyFd = -1; +}; + +inline std::unique_ptr<CConfigWatcher> g_pConfigWatcher = std::make_unique<CConfigWatcher>();
\ No newline at end of file |
