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

Add property change wrapper

parent 1c07dccd
No related branches found
No related tags found
1 merge request!316Resolves #343 GUI and Frame Refactor
...@@ -184,10 +184,7 @@ static void run(ftl::Configurable *root) { ...@@ -184,10 +184,7 @@ static void run(ftl::Configurable *root) {
float latency = 0.0f; float latency = 0.0f;
int64_t stats_time = 0; int64_t stats_time = 0;
quiet = root->value("quiet", false); root->on("quiet", quiet, false);
root->on("quiet", [root](const ftl::config::Event &e) {
quiet = root->value("quiet", false);
});
auto *pipeline = ftl::config::create<ftl::operators::Graph>(root, "pipeline"); auto *pipeline = ftl::config::create<ftl::operators::Graph>(root, "pipeline");
pipeline->append<ftl::operators::DetectAndTrack>("facedetection")->value("enabled", false); pipeline->append<ftl::operators::DetectAndTrack>("facedetection")->value("enabled", false);
......
...@@ -95,6 +95,19 @@ class Configurable { ...@@ -95,6 +95,19 @@ class Configurable {
*/ */
void on(const std::string &prop, std::function<void(const config::Event&)>); void on(const std::string &prop, std::function<void(const config::Event&)>);
//void on(const std::string &prop, const std::function<void()> &);
template <typename T>
void on(const std::string &prop, T &v) {
on(prop, [&v,this,prop](const config::Event &e) { v = *this->get<T>(prop); });
}
template <typename T>
void on(const std::string &prop, T &v, const T &def) {
v = this->value(prop, def);
on(prop, [&v,this,prop](const config::Event &e) { v = *this->get<T>(prop); });
}
void patchPtr(nlohmann::json &newcfg) { config_ = &newcfg; } void patchPtr(nlohmann::json &newcfg) { config_ = &newcfg; }
/** /**
......
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