diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2018-04-24 15:11:44 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2018-07-05 15:43:09 +0200 |
commit | 7229918a064a862c51217f1294a320c7260da937 (patch) | |
tree | b482145bdee1c68ac59d3eeebdb2ab671c87ec48 /signal-composer-binding/signal-composer.cpp | |
parent | 27776f5a89ba71cb102e5c2e08b813025c55c663 (diff) |
Initialize sources at binding start.
This has changed and is now explicitly launched because
last step of Controller configuration doesn't execute it.
Change-Id: I104011b912172da62114b62eeab90c76e41459dd
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.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/signal-composer-binding/signal-composer.cpp b/signal-composer-binding/signal-composer.cpp index c83aee6..0ee210b 100644 --- a/signal-composer-binding/signal-composer.cpp +++ b/signal-composer-binding/signal-composer.cpp @@ -295,7 +295,7 @@ int Composer::loadOneSourceAPI(json_object* sourceJ) onReceivedCtl = onReceivedJ ? convert2Action("onReceived", onReceivedJ) : nullptr; - sourcesListV_.push_back(std::make_shared<SourceAPI>(uid, api, info, initCtl, getSignalsCtl, onReceivedCtl, retention)); + newSourcesListV_.push_back(std::make_shared<SourceAPI>(uid, api, info, initCtl, getSignalsCtl, onReceivedCtl, retention)); return err; } @@ -421,7 +421,17 @@ int Composer::loadOneSignal(json_object* signalJ) } dependsV.push_back(sourceStr); } - if(!src) {src=*sourcesListV_.rbegin();} + if(!src) { + if (!sourcesListV_.empty()) + src = *sourcesListV_.rbegin(); + else if (!newSourcesListV_.empty()) + src = *newSourcesListV_.rbegin(); + else + { + AFB_WARNING("Signal '%s' not correctly attached to its source. Abort this one", json_object_to_json_string(signalJ)); + return -1; + } + } } // Set default retention if not specified @@ -644,7 +654,8 @@ CtlConfigT* Composer::ctlConfig() void Composer::initSourcesAPI() { - for(int i=0; i < newSourcesListV_.size(); i++) + size_t toInitialize = newSourcesListV_.size(); + for(int i=0; i < toInitialize; i++) { std::shared_ptr<SourceAPI> src = newSourcesListV_.back(); newSourcesListV_.pop_back(); |