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.hpp | |
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.hpp')
-rw-r--r-- | signal-composer-binding/signal.hpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/signal-composer-binding/signal.hpp b/signal-composer-binding/signal.hpp index 46caa23..7bc6b4a 100644 --- a/signal-composer-binding/signal.hpp +++ b/signal-composer-binding/signal.hpp @@ -31,12 +31,12 @@ class Composer; /// possibility. /// Not very efficient or optimized, maybe use of Variant in /// C++17 but this is a bit too new to uses it for now -struct SignalValue { - bool hasBool = false; +struct signalValue { + bool hasBool; bool boolVal; - bool hasNum = false; + bool hasNum; double numVal; - bool hasStr = false; + bool hasStr; std::string strVal; }; @@ -53,15 +53,16 @@ private: std::string event_; std::vector<std::string> dependsSigV_; long long int timestamp_; - struct SignalValue value_; - std::map<long long int, struct SignalValue> history_; ///< history_ - Hold signal value history in map with <timestamp, value> + struct signalValue value_; + std::map<long long int, struct signalValue> history_; ///< history_ - Hold signal value history in map with <timestamp, value> double frequency_; std::string unit_; CtlActionT* onReceived_; json_object* getSignalsArgs_; - //int recursionCheck(const std::string& origId) const; public: + bool subscribed_; ///< subscribed_ - boolean value telling if yes or no the signal has been subcribed to the low level binding. + 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); Signal(const std::string& id, std::vector<std::string>& depends, const std::string& unit, double frequency, CtlActionT* onReceived); @@ -72,7 +73,7 @@ public: const std::string id() const; json_object* toJSON() const; - void set(long long int timestamp, struct SignalValue& value); + void set(long long int timestamp, struct signalValue& value); void update(Signal* sig); int onReceivedCB(json_object *queryJ); void attachToSourceSignals(Composer& composer); @@ -80,8 +81,7 @@ public: double average(int seconds = 0) const; double minimum(int seconds = 0) const; double maximum(int seconds = 0) const; - struct SignalValue last() const; - //int recursionCheck() const; + struct signalValue last() const; int initialRecursionCheck(); int recursionCheck(Signal* obs); |