-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathState.h
67 lines (53 loc) · 1.4 KB
/
State.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* State.h
*
* Created on: Dec 29, 2012
* Author: jeff
*/
#ifndef STATE_H_
#define STATE_H_
#include <cstdio>
#include "Common.h"
#include "StateParent.h"
#include "DataProvider.h"
class StateContext; //forward declaration because we can't #include in both directions
class State : public StateParent, public DataProvider {
public:
State(StateParent* parent, StateContext* context);
/**
* Accept an event and a context; transitions context to a new
* state if applicable.
*
* @param event - the event that the state is accepting
*/
virtual void accept(Event event) = 0;
/**
* Entry action of the state when a transition occurs.
*/
virtual void entryAction();
/**
* Exit action of the state when a transition occurs.
*/
virtual void exitAction();
/**
* @return the parent of this state.
*/
StateParent* getParent();
/**
* @return the StateContext this State belongs to
*/
StateContext* getStateContext();
/**
* This is a default hook so StateContext objects can delegate to the state
* with regards to DataProvider functionality.
*
* @return a DisplayInfo which creates a blank display.
*/
virtual DisplayInfo getData();
protected:
// Reference to the parent of this state.
StateParent* parent;
// Reference to the FSM that owns this state.
StateContext* context;
};
#endif /* STATE_H_ */