State machine as a stack (#123)

* State machine as a stack

* Fix comments linked to code review

* I will think to compile, next time
This commit is contained in:
Gawaboumga
2017-04-20 12:30:43 +02:00
committed by Jérôme Leclercq
parent 0a75bce99d
commit eb70453574
3 changed files with 186 additions and 29 deletions

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2017 Jérôme Leclercq
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
@@ -10,6 +10,7 @@
#include <NDK/Prerequesites.hpp>
#include <NDK/State.hpp>
#include <memory>
#include <vector>
namespace Ndk
{
@@ -25,14 +26,21 @@ namespace Ndk
inline const std::shared_ptr<State>& GetCurrentState() const;
inline bool IsTopState(const State* state) const;
inline std::shared_ptr<State> PopState();
inline bool PopStatesUntil(std::shared_ptr<State> state);
inline void PushState(std::shared_ptr<State> state);
inline void SetState(std::shared_ptr<State> state);
inline bool Update(float elapsedTime);
inline StateMachine& operator=(StateMachine&& fsm) = default;
StateMachine& operator=(const StateMachine&) = delete;
private:
std::shared_ptr<State> m_currentState;
std::shared_ptr<State> m_nextState;
std::vector<std::shared_ptr<State>> m_states;
};
}