From dee50239be8fff566b3ca687bc70900b391a8164 Mon Sep 17 00:00:00 2001 From: LaG1924 <12997935+LaG1924@users.noreply.github.com> Date: Wed, 16 Aug 2017 20:11:07 +0500 Subject: 2017-08-16 --- src/FSM.hpp | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 src/FSM.hpp (limited to 'src/FSM.hpp') 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 -#include -#include - -template -class FSM { -public: - using Transaction = std::pair; - using Handler = std::function; - - 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 handlers; -}; \ No newline at end of file -- cgit v1.2.3