14 #ifndef GK_APPLICATIONSTATESTACK_HPP_ 15 #define GK_APPLICATIONSTATESTACK_HPP_ 38 template<
typename T,
typename... Args>
39 auto push(Args &&...args) ->
typename std::enable_if<std::is_base_of<ApplicationState, T>::value, T&>::type {
40 m_states.emplace(std::make_shared<T>(std::forward<Args>(args)...));
42 return static_cast<T&
>(
top());
121 std::stack<std::shared_ptr<ApplicationState>>
m_states;
122 std::stack<std::shared_ptr<ApplicationState>>
m_trash;
127 #endif // GK_APPLICATIONSTATESTACK_HPP_ void clear()
Clear the stack.
ApplicationState & top() const
Get the top ApplicationState in the stack.
std::stack< std::shared_ptr< ApplicationState > > m_trash
Removed states waiting to be deleted.
static ApplicationStateStack & getInstance()
Get the current singleton instance.
void pop()
Remove the top ApplicationState in the stack.
void clearDeletedStates()
Clear the removed states of the stack.
std::size_t size() const
Get the amount of ApplicationState in the stack.
bool empty() const
Check if the container is empty.
static void setInstance(ApplicationStateStack &instance)
Set the current singleton instance.
static ApplicationStateStack * s_instance
Current singleton instance.
Stack containing ApplicationState instances.
auto push(Args &&...args) -> typename std::enable_if< std::is_base_of< ApplicationState, T >::value, T &>::type
Push a new gk::ApplicationState to the stack.
Abstract base class for game states.
std::stack< std::shared_ptr< ApplicationState > > m_states
Stack containing the states.