aboutsummaryrefslogtreecommitdiffstats
path: root/signal-composer-binding/signal.hpp
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-09-14 19:31:42 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-12-14 11:00:25 +0100
commiteabae24ea592420de46e36f0b1af5d39eee5b8a4 (patch)
tree16cbc39e84eb71d655add40e715f7d87b4b02132 /signal-composer-binding/signal.hpp
parent140fd3d8f76a8cbbde8f6b0bf997808855f3da43 (diff)
Attach and recursion check working
Change-Id: I2f9509d4b6aa63a16df8db2187810337fd802ef4 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'signal-composer-binding/signal.hpp')
-rw-r--r--signal-composer-binding/signal.hpp37
1 files changed, 20 insertions, 17 deletions
diff --git a/signal-composer-binding/signal.hpp b/signal-composer-binding/signal.hpp
index ad944aa..cb50c67 100644
--- a/signal-composer-binding/signal.hpp
+++ b/signal-composer-binding/signal.hpp
@@ -19,40 +19,43 @@
#include <map>
#include <string>
-#include <memory>
#include <vector>
#include <ctl-config.h>
-#include "observer.hpp"
+class bindingApp;
-class Signal;
-
-//TODO: claneys: define observer and observable interface then inherit
-class Signal: public Observer, public Subject
+class Signal
{
private:
std::string id_;
- std::vector<std::string> sources_;
- std::map<long, double> history_; ///< history_ - Hold signal value history in map with <timestamp, value>
+ std::vector<std::string> sourcesSig_;
+ long long int timestamp_;
+ double value_;
+ std::map<long long int, double> history_; ///< history_ - Hold signal value history in map with <timestamp, value>
double frequency_;
std::string unit_;
CtlActionT* onReceived_;
+ std::vector<Signal*> Observers_;
- std::vector<std::shared_ptr<Signal>> observers_;
-
+ void attach(Signal *obs);
int recursionCheck(const std::string& origId);
+
public:
- Signal();
Signal(const std::string& id, std::vector<std::string>& sources, const std::string& unit, double frequency, CtlActionT* onReceived);
explicit operator bool() const;
+ bool operator==(const Signal& other) const;
+ bool operator==(const std::string& aName) const;
std::string id() const;
- int recursionCheck();
- /* virtual */ void update(double timestamp, double value);
+ void update(long long int timestamp, double value);
+ int onReceivedCB(json_object *queryJ);
+ void attachToSources(bindingApp& bApp);
+ void notify();
- virtual double average() const;
- virtual double min() const;
- virtual double max() const;
- double lastValue() const;
+ //virtual double average() const;
+ //virtual double min() const;
+ //virtual double max() const;
+ //double lastValue() const;
+ int recursionCheck();
};