Add simple input signal processor
Add a simple input signal manager. When the manager is invoked with
input source signal change, it recomputes the expected output and
notifies all output signal listeners.
Change-Id: Iac130441fc814d8d71b2ac3026e9735b0db4badb
diff --git a/src/manager/StateManager.h b/src/manager/StateManager.h
new file mode 100644
index 0000000..013bc85
--- /dev/null
+++ b/src/manager/StateManager.h
@@ -0,0 +1,37 @@
+#pragma once
+
+#include <functional>
+#include <map>
+#include <memory>
+#include <mutex>
+#include "AbstractManager.h"
+#include "State.h"
+#include "utils/log-fwd.h"
+
+namespace velia {
+
+class AbstractInput;
+
+/**
+ * @short Stores registered inputs, output signal and also states of all currently registered inputs.
+ */
+class StateManager : public AbstractManager {
+public:
+ StateManager();
+ ~StateManager() override;
+
+ void registerInput(void* input, State value) override;
+ void unregisterInput(void* input) override;
+
+ void updateState(void* input, State value) override;
+
+private:
+ velia::Log m_log;
+
+ /** Registered inputs are identified by their memory location. The pointer only serves as an ID, this class does not manage the input pointers lifetime */
+ std::map<void*, State> m_inputs;
+
+ /** @brief Recompute output and fire output signal. Should be called on every input change. */
+ void computeOutput();
+};
+}
\ No newline at end of file