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
This commit is part of merge request !187. Comments created here will be created in the context of that merge request.
...@@ -55,6 +55,7 @@ void ConfigWindow::_addElements(nanogui::FormHelper *form, const std::string &su ...@@ -55,6 +55,7 @@ void ConfigWindow::_addElements(nanogui::FormHelper *form, const std::string &su
Configurable *configurable = ftl::config::find(suri); Configurable *configurable = ftl::config::find(suri);
ftl::config::json_t data; ftl::config::json_t data;
if (configurable) { if (configurable) {
configurable->refresh();
data = configurable->getConfig(); data = configurable->getConfig();
} }
......
...@@ -101,6 +101,12 @@ class Configurable { ...@@ -101,6 +101,12 @@ class Configurable {
void patchPtr(nlohmann::json &newcfg) { config_ = &newcfg; } void patchPtr(nlohmann::json &newcfg) { config_ = &newcfg; }
/**
* Allow configurables to refresh their internal state, perhaps from a
* remote source.
*/
virtual void refresh();
protected: protected:
nlohmann::json *config_; nlohmann::json *config_;
......
...@@ -60,3 +60,7 @@ void Configurable::on(const string &prop, function<void(const ftl::config::Event ...@@ -60,3 +60,7 @@ void Configurable::on(const string &prop, function<void(const ftl::config::Event
(*ix).second.push_back(f); (*ix).second.push_back(f);
} }
} }
void Configurable::refresh() {
// Do nothing by default
}
...@@ -12,6 +12,8 @@ namespace ftl { ...@@ -12,6 +12,8 @@ namespace ftl {
NetConfigurable(ftl::UUID peer, const std::string &suri, ftl::ctrl::Master &ctrl, ftl::config::json_t &config); NetConfigurable(ftl::UUID peer, const std::string &suri, ftl::ctrl::Master &ctrl, ftl::config::json_t &config);
~NetConfigurable(); ~NetConfigurable();
void refresh() override;
protected: protected:
void inject(const std::string &name, nlohmann::json &value); void inject(const std::string &name, nlohmann::json &value);
......
...@@ -10,3 +10,7 @@ ftl::NetConfigurable::~NetConfigurable(){} ...@@ -10,3 +10,7 @@ ftl::NetConfigurable::~NetConfigurable(){}
void ftl::NetConfigurable::inject(const std::string &name, nlohmann::json &value) { void ftl::NetConfigurable::inject(const std::string &name, nlohmann::json &value) {
ctrl.set(peer, suri + std::string("/") + name, 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