// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp #pragma once #ifndef NDK_STATEMACHINE_HPP #define NDK_STATEMACHINE_HPP #include #include #include #include namespace Ndk { class StateMachine { public: inline StateMachine(std::shared_ptr originalState); StateMachine(const StateMachine&) = delete; inline StateMachine(StateMachine&& fsm) = default; inline ~StateMachine(); inline void ChangeState(std::shared_ptr state); inline bool IsTopState(const State* state) const; inline void PopState(); inline void PopStatesUntil(std::shared_ptr state); inline void PushState(std::shared_ptr state); inline void ResetState(std::shared_ptr state); inline bool Update(float elapsedTime); inline StateMachine& operator=(StateMachine&& fsm) = default; StateMachine& operator=(const StateMachine&) = delete; private: enum class TransitionType { Pop, PopUntil, Push, }; struct StateTransition { TransitionType type; std::shared_ptr state; }; std::vector> m_states; std::vector m_transitions; }; } #include #endif // NDK_STATEMACHINE_HPP