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

Fix for refresh net config

parent 406428a6
No related branches found
No related tags found
1 merge request!187Resolves #256 Net config refresh
Pipeline #16885 passed
......@@ -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_;
......
......@@ -60,3 +60,7 @@ void Configurable::on(const string &prop, function<void(const ftl::config::Event
(*ix).second.push_back(f);
}
}
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.
Please register or to comment