Skip to content
Snippets Groups Projects
Commit be0c6665 authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Resolves #256 Net config refresh

parent 406428a6
No related branches found
No related tags found
No related merge requests found
......@@ -55,6 +55,7 @@ void ConfigWindow::_addElements(nanogui::FormHelper *form, const std::string &su
Configurable *configurable = ftl::config::find(suri);
ftl::config::json_t data;
if (configurable) {
configurable->refresh();
data = configurable->getConfig();
}
......
......@@ -101,6 +101,12 @@ class Configurable {
void patchPtr(nlohmann::json &newcfg) { config_ = &newcfg; }
/**
* Allow configurables to refresh their internal state, perhaps from a
* remote source.
*/
virtual void refresh();
protected:
nlohmann::json *config_;
......
......@@ -59,4 +59,8 @@ void Configurable::on(const string &prop, function<void(const ftl::config::Event
} else {
(*ix).second.push_back(f);
}
}
\ No newline at end of file
}
void Configurable::refresh() {
// Do nothing by default
}
......@@ -12,6 +12,8 @@ namespace ftl {
NetConfigurable(ftl::UUID peer, const std::string &suri, ftl::ctrl::Master &ctrl, ftl::config::json_t &config);
~NetConfigurable();
void refresh() override;
protected:
void inject(const std::string &name, nlohmann::json &value);
......
......@@ -10,3 +10,7 @@ ftl::NetConfigurable::~NetConfigurable(){}
void ftl::NetConfigurable::inject(const std::string &name, nlohmann::json &value) {
ctrl.set(peer, suri + std::string("/") + name, value);
}
void ftl::NetConfigurable::refresh() {
(*config_) = ctrl.get(peer, suri);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment