migration to platformio
This commit is contained in:
commit
cad91967b1
22 changed files with 2985 additions and 0 deletions
37
src/statemachine.cpp
Normal file
37
src/statemachine.cpp
Normal file
|
@ -0,0 +1,37 @@
|
|||
#include "statemachine.h"
|
||||
#include "station.h"
|
||||
#include "context.h"
|
||||
|
||||
StateMachine::StateMachine(State* initialState)
|
||||
: currentState(initialState) {}
|
||||
|
||||
StateMachine::~StateMachine() {
|
||||
delete currentState;
|
||||
}
|
||||
|
||||
void StateMachine::updateState(State* newState) {
|
||||
if (newState != currentState) {
|
||||
delete currentState;
|
||||
currentState = newState;
|
||||
}
|
||||
}
|
||||
|
||||
void StateMachine::pickedUp(const Context& context) {
|
||||
State* newState = currentState->pickedUp(context);
|
||||
updateState(newState);
|
||||
}
|
||||
|
||||
void StateMachine::putDown(const Context& context, Station* newStation) {
|
||||
State* newState = currentState->putDown(context, newStation);
|
||||
updateState(newState);
|
||||
}
|
||||
|
||||
void StateMachine::update(const Context& context) {
|
||||
State* newState = currentState->update(context);
|
||||
updateState(newState);
|
||||
}
|
||||
|
||||
String StateMachine::updateDisplay() const
|
||||
{
|
||||
return currentState->updateDisplay();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue