summaryrefslogtreecommitdiffstats
path: root/signal-composer-binding/signal-composer.cpp
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-12-07 18:49:09 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2017-12-14 11:00:49 +0100
commite599b4ba129df475a9c8bb8290c3803f9dda664a (patch)
tree98ed8edbd2bb1bcc481fadc5ac0037c87b0608d2 /signal-composer-binding/signal-composer.cpp
parentfb487caec38c0da7a43bab850af6aa79b07befde (diff)
Load additionnals object at runtime
Later integrated in controller submodule Change-Id: I7d5c7431e60fc16cc2053747674fe4f14efd6a14 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'signal-composer-binding/signal-composer.cpp')
-rw-r--r--signal-composer-binding/signal-composer.cpp32
1 files changed, 31 insertions, 1 deletions
diff --git a/signal-composer-binding/signal-composer.cpp b/signal-composer-binding/signal-composer.cpp
index 3ad2d4e..8461748 100644
--- a/signal-composer-binding/signal-composer.cpp
+++ b/signal-composer-binding/signal-composer.cpp
@@ -634,6 +634,18 @@ int Composer::loadConfig(const std::string& filepath)
// return -1;
}
+int Composer::loadSources(json_object* sourcesJ)
+{
+ int err = loadSourcesAPI(nullptr, nullptr, sourcesJ);
+ if(err)
+ {
+ AFB_ERROR("Loading sources failed. JSON: %s", json_object_to_json_string(sourcesJ));
+ return err;
+ }
+ initSourcesAPI();
+ return err;
+}
+
int Composer::loadSignals(json_object* signalsJ)
{
return loadSignals(nullptr, nullptr, signalsJ);
@@ -646,10 +658,23 @@ CtlConfigT* Composer::ctlConfig()
void Composer::initSourcesAPI()
{
- for(auto& src: sourcesListV_)
+ for(int i=0; i < newSourcesListV_.size(); i++)
{
+ std::shared_ptr<SourceAPI> src = newSourcesListV_.back();
+ newSourcesListV_.pop_back();
src->init();
+ sourcesListV_.push_back(src);
+ }
+}
+
+void Composer::initSignals()
+{
+ for(int i=0; i < sourcesListV_.size(); i++)
+ {
+ std::shared_ptr<SourceAPI> src = sourcesListV_[i];
+ src->initSignals();
}
+ execSignalsSubscription();
}
std::shared_ptr<SourceAPI> Composer::getSourceAPI(const std::string& api)
@@ -659,6 +684,11 @@ std::shared_ptr<SourceAPI> Composer::getSourceAPI(const std::string& api)
if (source->api() == api)
{return source;}
}
+ for(auto& source: newSourcesListV_)
+ {
+ if (source->api() == api)
+ {return source;}
+ }
return nullptr;
}