Public Member Functions | Protected Member Functions | Private Attributes

StateManager Class Reference

Implements a Finite State Machine model that switches between State objects. More...

#include <StateManager.h>

Inheritance diagram for StateManager:
Listener

List of all members.

Public Member Functions

 StateManager (Gui *gui)
 ~StateManager ()
void setState (State *state)
 Sets the StateManager to run specified State.
bool updateState ()

Protected Member Functions

void push (Event *event)

Private Attributes

GuimGui
StatemActiveState
bool mActive

Detailed Description

Implements a Finite State Machine model that switches between State objects.

Note:
StateManager handles distribution of input and system events to both State objects and to the Gui.

Constructor & Destructor Documentation

StateManager::StateManager ( Gui g  ) 
Parameters:
fs Pointer to a Filesystem Class.
r Pointer to a Renderer Class.
m Pointer to a Mixer Class.
g Pointer to a Gui Class.
StateManager::~StateManager (  ) 
Note:
Any active states are destroyed at this point as are any cross-state values.
Todo:
Ensure that all objects are properly destroyed and cleared.

Member Function Documentation

void StateManager::push ( Event event  )  [protected, virtual]

Implements Listener.

void StateManager::setState ( State state  ) 

Sets the StateManager to run specified State.

Note:
State objects are destroyed when setting a new state so cross-state values will need to be saved upon destruction in the overloaded finalize() function.
Parameters:
state Pointer to a new State.
bool StateManager::updateState (  ) 

Executes the updateState() on the active State

Returns:
bool Returns true if there is still an active State. Otherwise returns false.
Todo:
Check to see if there are any memory leaks in the 'if' block. I have a sneaking suspicion that we may be leaking a few KB's when we switch to a different state.

Member Data Documentation

bool StateManager::mActive [private]
Gui* StateManager::mGui [private]

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines