summaryrefslogtreecommitdiffstats
path: root/signal-composer-binding/signal.hpp
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-09-12 00:29:28 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-12-14 11:00:25 +0100
commitd663f702c0e4fa562783504a483dce8f362d628e (patch)
treefdb656d0467a935aa6790dd9e05d3e373606a3e1 /signal-composer-binding/signal.hpp
parent75cfbf3d0206f12422091e6479c508c69445bf4a (diff)
Progression on config parsing.
Change-Id: Idd8d8987ccabef381f6d79c1d508930a2d4bae3c Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'signal-composer-binding/signal.hpp')
-rw-r--r--signal-composer-binding/signal.hpp44
1 files changed, 28 insertions, 16 deletions
diff --git a/signal-composer-binding/signal.hpp b/signal-composer-binding/signal.hpp
index 94878c9..ad944aa 100644
--- a/signal-composer-binding/signal.hpp
+++ b/signal-composer-binding/signal.hpp
@@ -17,30 +17,42 @@
#pragma once
+#include <map>
#include <string>
#include <memory>
#include <vector>
+#include <ctl-config.h>
+
+#include "observer.hpp"
class Signal;
-class Signal
+//TODO: claneys: define observer and observable interface then inherit
+class Signal: public Observer, public Subject
{
private:
- std::string api_;
- std::string name_;
- std::vector<> history_;
- float frequency_;
- st::string unit_;
- float min_;
- float max_;
- float last_;
+ std::string id_;
+ std::vector<std::string> sources_;
+ std::map<long, double> history_; ///< history_ - Hold signal value history in map with <timestamp, value>
+ double frequency_;
+ std::string unit_;
+ CtlActionT* onReceived_;
- std::vector<std::shared_ptr<Signal>> Observers_;
+ std::vector<std::shared_ptr<Signal>> observers_;
+ int recursionCheck(const std::string& origId);
public:
- void notify();
- void infiniteRecursionCheck();
- void attach();
- void detach();
- void notify();
-}
+ Signal();
+ Signal(const std::string& id, std::vector<std::string>& sources, const std::string& unit, double frequency, CtlActionT* onReceived);
+ explicit operator bool() const;
+
+ std::string id() const;
+
+ int recursionCheck();
+ /* virtual */ void update(double timestamp, double value);
+
+ virtual double average() const;
+ virtual double min() const;
+ virtual double max() const;
+ double lastValue() const;
+};