aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--signal-composer-binding/signal-composer.cpp12
-rw-r--r--signal-composer-binding/source.cpp22
-rw-r--r--signal-composer-binding/source.hpp6
3 files changed, 34 insertions, 6 deletions
diff --git a/signal-composer-binding/signal-composer.cpp b/signal-composer-binding/signal-composer.cpp
index 4a0346c..0fb3f3d 100644
--- a/signal-composer-binding/signal-composer.cpp
+++ b/signal-composer-binding/signal-composer.cpp
@@ -300,6 +300,16 @@ int Composer::loadOneSourceAPI(json_object* sourceJ)
return err;
}
+ // Checking duplicate entry and ignore if so
+ for(auto& src: sourcesListV_)
+ {
+ if(*src == uid)
+ {
+ json_object_put(sourceJ);
+ return 0;
+ }
+ }
+
if(ctlConfig_ && ctlConfig_->requireJ)
{
const char* requireS = json_object_to_json_string(ctlConfig_->requireJ);
@@ -322,7 +332,7 @@ int Composer::loadOneSourceAPI(json_object* sourceJ)
onReceivedCtl = onReceivedJ ? convert2Action("onReceived", onReceivedJ) : nullptr;
- sourcesListV_.push_back(std::make_shared<SourceAPI>(api, info, initCtl, getSignalsCtl, onReceivedCtl, retention));
+ sourcesListV_.push_back(std::make_shared<SourceAPI>(uid, api, info, initCtl, getSignalsCtl, onReceivedCtl, retention));
return err;
}
diff --git a/signal-composer-binding/source.cpp b/signal-composer-binding/source.cpp
index f616e51..f34b88f 100644
--- a/signal-composer-binding/source.cpp
+++ b/signal-composer-binding/source.cpp
@@ -21,13 +21,27 @@
SourceAPI::SourceAPI()
{}
-SourceAPI::SourceAPI(const std::string& api, const std::string& info, CtlActionT* init, CtlActionT* getSignals, CtlActionT* onReceived, int retention):api_(api),
- info_(info),
- init_(init),
- getSignals_(getSignals),
+SourceAPI::SourceAPI(const std::string& uid, const std::string& api, const std::string& info, CtlActionT* init, CtlActionT* getSignals, CtlActionT* onReceived, int retention):
+ uid_{uid},
+ api_{api},
+ info_{info},
+ init_{init},
+ getSignals_{getSignals},
signalsDefault_({onReceived, retention})
{}
+bool SourceAPI::operator ==(const SourceAPI& other) const
+{
+ if(uid_ == other.uid_) {return true;}
+ return false;
+}
+
+bool SourceAPI::operator ==(const std::string& other) const
+{
+ if(uid_ == other) {return true;}
+ return false;
+}
+
void SourceAPI::init()
{
if(init_)
diff --git a/signal-composer-binding/source.hpp b/signal-composer-binding/source.hpp
index 3d44922..8dd18e5 100644
--- a/signal-composer-binding/source.hpp
+++ b/signal-composer-binding/source.hpp
@@ -26,6 +26,7 @@ struct signalsDefault {
class SourceAPI {
private:
+ std::string uid_;
std::string api_;
std::string info_;
CtlActionT* init_;
@@ -38,7 +39,10 @@ private:
public:
SourceAPI();
- SourceAPI(const std::string& api, const std::string& info, CtlActionT* init, CtlActionT* getSignal, CtlActionT* onReceived, int retention);
+ SourceAPI(const std::string& uid_, const std::string& api, const std::string& info, CtlActionT* init, CtlActionT* getSignal, CtlActionT* onReceived, int retention);
+
+ bool operator==(const SourceAPI& other) const;
+ bool operator==(const std::string& aName) const;
void init();
std::string api() const;