summaryrefslogtreecommitdiffstats
path: root/signal-composer-binding/signal.hpp
diff options
context:
space:
mode:
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;
+};