aboutsummaryrefslogtreecommitdiffstats
path: root/signal-composer-binding
diff options
context:
space:
mode:
Diffstat (limited to 'signal-composer-binding')
-rw-r--r--signal-composer-binding/signal-composer-binding.cpp1
-rw-r--r--signal-composer-binding/signal-composer.cpp17
-rw-r--r--signal-composer-binding/signal-composer.hpp2
3 files changed, 16 insertions, 4 deletions
diff --git a/signal-composer-binding/signal-composer-binding.cpp b/signal-composer-binding/signal-composer-binding.cpp
index fb99c89..7cdda91 100644
--- a/signal-composer-binding/signal-composer-binding.cpp
+++ b/signal-composer-binding/signal-composer-binding.cpp
@@ -279,6 +279,7 @@ int execConf()
int err = 0;
CtlConfigExec(nullptr, composer.ctlConfig());
+ composer.initSourcesAPI();
composer.initSignals();
AFB_DEBUG("Signal Composer Control configuration Done.");
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();
diff --git a/signal-composer-binding/signal-composer.hpp b/signal-composer-binding/signal-composer.hpp
index b3e1fed..90bd354 100644
--- a/signal-composer-binding/signal-composer.hpp
+++ b/signal-composer-binding/signal-composer.hpp
@@ -46,7 +46,6 @@ private:
int loadOneSignal(json_object* signalsJ);
static int loadSignals(AFB_ApiT apihandle, CtlSectionT* section, json_object *signalsJ);
- void initSourcesAPI();
void execSignalsSubscription();
std::shared_ptr<SourceAPI> getSourceAPI(const std::string& api);
void processOptions(const std::map<std::string, int>& opts, std::shared_ptr<Signal> sig, json_object* response) const;
@@ -59,6 +58,7 @@ public:
int loadSources(json_object* sourcesJ);
int loadSignals(json_object* signalsJ);
void initSignals();
+ void initSourcesAPI();
CtlConfigT* ctlConfig();
std::vector<std::shared_ptr<Signal>> getAllSignals();