summaryrefslogtreecommitdiffstats
path: root/src/FSM.hpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-08-16 17:11:07 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-08-16 17:11:07 +0200
commitdee50239be8fff566b3ca687bc70900b391a8164 (patch)
tree6ff6ae2e8e2ea5109d031be8c588f4b8f38f68eb /src/FSM.hpp
parent2017-08-12 (diff)
downloadAltCraft-dee50239be8fff566b3ca687bc70900b391a8164.tar
AltCraft-dee50239be8fff566b3ca687bc70900b391a8164.tar.gz
AltCraft-dee50239be8fff566b3ca687bc70900b391a8164.tar.bz2
AltCraft-dee50239be8fff566b3ca687bc70900b391a8164.tar.lz
AltCraft-dee50239be8fff566b3ca687bc70900b391a8164.tar.xz
AltCraft-dee50239be8fff566b3ca687bc70900b391a8164.tar.zst
AltCraft-dee50239be8fff566b3ca687bc70900b391a8164.zip
Diffstat (limited to '')
-rw-r--r--src/FSM.hpp36
1 files changed, 0 insertions, 36 deletions
diff --git a/src/FSM.hpp b/src/FSM.hpp
deleted file mode 100644
index 346d0f0..0000000
--- a/src/FSM.hpp
+++ /dev/null
@@ -1,36 +0,0 @@
-#pragma once
-
-#include <utility>
-#include <functional>
-#include <map>
-
-template<class T>
-class FSM {
-public:
- using Transaction = std::pair<T, T>;
- using Handler = std::function<void(T &)>;
-
- FSM(T initialState) : state(initialState), previousState(initialState) {}
-
- ~FSM() = default;
-
- void Update() {
- auto &handler = handlers[Transaction{previousState, state}];
- if (handler)
- handler(state);
- previousState = state;
- }
-
- void RegisterHandler(T state, Handler handler) {
- handlers[Transaction{state, state}] = handler;
- }
-
- void RegisterTransactionHandler(Transaction transaction, Handler handler) {
- handlers[transaction] = handler;
- }
-
-private:
- T previousState;
- T state;
- std::map<Transaction, Handler> handlers;
-}; \ No newline at end of file