diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-09-25 18:29:48 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2017-12-14 11:00:25 +0100 |
commit | b7dd0a6e19d5387bc8d499bd1b3a99d457fa58d9 (patch) | |
tree | 0d1a26964435e8f91b96713e2b5beb3c1e94d0b2 /signal-composer-binding/signal.cpp | |
parent | db45a68715c07e6b8fe35e322ddcbbc6c473cb2b (diff) |
Enhance pointer manage and container browsing
- SourceAPI now holds share_ptr of Signal
- Signal are stored in a map<string,signal> that change
way to browse the signals
- subscribed property included in SourceAPI.
- Clean old code
- renaming struct SignalValue->signalValue
Change-Id: Ic5c28296ddd7197c6562e12fbc91c504c1cc0b4d
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'signal-composer-binding/signal.cpp')
-rw-r--r-- | signal-composer-binding/signal.cpp | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/signal-composer-binding/signal.cpp b/signal-composer-binding/signal.cpp index faae4a3..51e16f9 100644 --- a/signal-composer-binding/signal.cpp +++ b/signal-composer-binding/signal.cpp @@ -22,6 +22,19 @@ #define MICRO 1000000 +Signal::Signal() +:id_(""), + event_(""), + dependsSigV_(), + timestamp_(0.0), + value_({0,0,0,0,0,""}), + frequency_(0), + unit_(""), + onReceived_(nullptr), + getSignalsArgs_(nullptr), + subscribed_(false) +{} + Signal::Signal(const std::string& id, const std::string& event, std::vector<std::string>& depends, const std::string& unit, double frequency, CtlActionT* onReceived, json_object* getSignalsArgs) :id_(id), event_(event), @@ -31,7 +44,8 @@ Signal::Signal(const std::string& id, const std::string& event, std::vector<std: frequency_(frequency), unit_(unit), onReceived_(onReceived), - getSignalsArgs_(getSignalsArgs) + getSignalsArgs_(getSignalsArgs), + subscribed_(false) {} Signal::Signal(const std::string& id, @@ -47,7 +61,8 @@ Signal::Signal(const std::string& id, frequency_(frequency), unit_(unit), onReceived_(onReceived), - getSignalsArgs_() + getSignalsArgs_(), + subscribed_(false) {} Signal::operator bool() const @@ -119,7 +134,7 @@ json_object* Signal::toJSON() const /// /// @param[in] timestamp - timestamp of occured signal /// @param[in] value - value of change -void Signal::set(long long int timestamp, struct SignalValue& value) +void Signal::set(long long int timestamp, struct signalValue& value) { timestamp_ = timestamp; value_ = value; @@ -147,21 +162,6 @@ int Signal::onReceivedCB(json_object *queryJ) return err; } -/// @brief Make a Signal observer observes a Signal observable if not already -/// present in the Observers vector. -/// -/// @param[in] obs - pointer to a Signal observable -/*void Signal::attach(Signal* obs) -{ - for ( auto& sig : Observers_) - { - if (obs == sig) - {return;} - } - - Observers_.push_back(obs); -}*/ - /// @brief Make a Signal observer observes Signals observables /// set in its observable vector. /// @@ -172,7 +172,7 @@ void Signal::attachToSourceSignals(Composer& composer) { if(srcSig.find("/") == std::string::npos) { - std::vector<Signal*> observables = composer.searchSignals(srcSig); + std::vector<std::shared_ptr<Signal>> observables = composer.searchSignals(srcSig); if(observables[0]) { AFB_NOTICE("Attaching %s to %s", id_.c_str(), srcSig.c_str()); |