Opt-in cross-process auto-reload for a RuleStore. More...
#include <PhosphorRules/RuleStoreWatcher.h>
Public Member Functions | |
| RuleStoreWatcher (RuleStore &store, QObject *parent=nullptr) | |
| ~RuleStoreWatcher () override | |
| RuleStoreWatcher (const RuleStoreWatcher &)=delete | |
| RuleStoreWatcher & | operator= (const RuleStoreWatcher &)=delete |
| void | start () |
| Begin watching. | |
Opt-in cross-process auto-reload for a RuleStore.
Watches the store's backing rules.json and calls RuleStore::load() when it changes on disk, so a process that OWNS a store reflects another process's writes (or a hand edit of the file) without a manual reload. The daemon, the standalone plasmazones-settings and plasmazones-editor each run one over their own store.
The hard parts are delegated to PhosphorFsLoader::WatchedDirectorySet:
QFileSystemWatcher silently drops),Self-writes need no special handling: RuleStore::load() is idempotent — it re-reads the file but only emits rulesChanged when the content actually differs — so a watcher event from the store's own save() reloads to identical content and emits nothing.
Opt-in by construction — a consumer creates this only when it wants the behaviour, so the base RuleStore carries no watcher overhead and a test fixture that only needs the store never installs a file watch.
GUI-thread only — inherits WatchedDirectorySet's thread affinity: construct and call start() from the thread that owns the store.
|
explicit |
| store | Borrowed store to reload on external change. Must outlive this watcher. |
| parent | Qt parent. |
|
override |
|
delete |
|
delete |
| void PhosphorRules::RuleStoreWatcher::start | ( | ) |
Begin watching.
Registers the store file's parent directory with live reload and installs the initial per-file watch. Deferred from the ctor so a consumer can connect to the store's rulesChanged before the first scan runs. Calling more than once is a no-op after the first.
The registration triggers one immediate synchronous reload of the store; because RuleStore::load() is idempotent, that is a no-op when the file has not changed since the store's own constructor load.