Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: N5110 PinDetect PowerControl mbed
StateManager.h
- Committer:
- Siriagus
- Date:
- 2015-05-01
- Revision:
- 4:d6661b976359
- Child:
- 5:100d960fc6d5
File content as of revision 4:d6661b976359:
#ifndef STATE_MANAGER_H
#define STATE_MANAGER_H
#include "State.h"
#include <map>
// Main Finite State Machine - controls the flow between the main states
class StateManager
{
public:
StateManager(N5110 *lcd, InputManager* input)
: lcd(lcd), input(input){currentState = 0;}
void update(time_t dt);
void render();
template <typename T>
void changeState(MainState newState); // Deletes the current main state and creates a new one
private:
N5110 *lcd;
InputManager *input;
State* currentState; // Current state object
};
template <typename T>
void StateManager::changeState(MainState newState)
{
if (currentState != 0) // if a state exist
delete currentState; // clear allocated memory
// Create new state
currentState = new T(*this, lcd, input);
// TODO: Work on this
}
#endif STATE_MANAGER_H