|
GameKit
0.0.1a
C++ gamedev tools
|
Stack containing ApplicationState instances. More...
#include <ApplicationStateStack.hpp>
Public Member Functions | |
| template<typename T , typename... Args> | |
| 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. More... | |
| void | pop () |
| Remove the top ApplicationState in the stack. More... | |
| void | clear () |
| Clear the stack. More... | |
| void | clearDeletedStates () |
| Clear the removed states of the stack. More... | |
| ApplicationState & | top () const |
| Get the top ApplicationState in the stack. More... | |
| bool | empty () const |
| Check if the container is empty. More... | |
| std::size_t | size () const |
| Get the amount of ApplicationState in the stack. More... | |
Static Public Member Functions | |
| static ApplicationStateStack & | getInstance () |
| Get the current singleton instance. More... | |
| static void | setInstance (ApplicationStateStack &instance) |
| Set the current singleton instance. More... | |
Private Attributes | |
| std::stack< std::shared_ptr< ApplicationState > > | m_states |
| Stack containing the states. More... | |
| std::stack< std::shared_ptr< ApplicationState > > | m_trash |
| Removed states waiting to be deleted. More... | |
Static Private Attributes | |
| static ApplicationStateStack * | s_instance = nullptr |
| Current singleton instance. More... | |
Stack containing ApplicationState instances.
gk::ApplicationStateStack is a stack container of gk::ApplicationState instances.
Usage example:
Definition at line 28 of file ApplicationStateStack.hpp.
|
inline |
Clear the stack.
Definition at line 57 of file ApplicationStateStack.hpp.
| void gk::ApplicationStateStack::clearDeletedStates | ( | ) |
Clear the removed states of the stack.
This function is automatically called in CoreApplication::mainLoop()
Definition at line 25 of file ApplicationStateStack.cpp.
|
inline |
Check if the container is empty.
true if the container is empty, otherwise false Definition at line 81 of file ApplicationStateStack.hpp.
|
inlinestatic |
Get the current singleton instance.
Definition at line 99 of file ApplicationStateStack.hpp.
| void gk::ApplicationStateStack::pop | ( | ) |
Remove the top ApplicationState in the stack.
The state is moved to another stack while waiting for clearDeleteStates() to remove it.
Definition at line 20 of file ApplicationStateStack.cpp.
|
inline |
Push a new gk::ApplicationState to the stack.
| args | Constructor arguments of type T |
This function will populate ApplicationState::m_stateStack
Definition at line 39 of file ApplicationStateStack.hpp.
|
inlinestatic |
Set the current singleton instance.
| instance | New singleton instance |
Definition at line 111 of file ApplicationStateStack.hpp.
|
inline |
Get the amount of ApplicationState in the stack.
Definition at line 89 of file ApplicationStateStack.hpp.
|
inline |
Get the top ApplicationState in the stack.
Definition at line 73 of file ApplicationStateStack.hpp.
|
private |
Stack containing the states.
Definition at line 121 of file ApplicationStateStack.hpp.
|
private |
Removed states waiting to be deleted.
Definition at line 122 of file ApplicationStateStack.hpp.
|
staticprivate |
Current singleton instance.
Definition at line 119 of file ApplicationStateStack.hpp.
1.8.12