-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathState.h
28 lines (22 loc) · 776 Bytes
/
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
#ifndef _STATE_H_
#define _STATE_H_
#define MAX_ARR_SIZE_STS_EVT 16
class Event;
class StateMachine;
class State {
private:
StateMachine& _owner;
Event* _evtList[MAX_ARR_SIZE_STS_EVT];
State* _nextState[MAX_ARR_SIZE_STS_EVT];
uint32_t _evtListIdx;
void (*_evtProcLambda[MAX_ARR_SIZE_STS_EVT])(StateMachine& stateMachine);
void (*_duringLambda)(StateMachine& stateMachine);
public:
explicit State(StateMachine& owner);
virtual ~State();
void registerDuring(void (*duringLambda)(StateMachine& stateMachine)) { _duringLambda = duringLambda; }
void registerEvent(Event* evt, State* nextState, void (*evtProcLambda)(StateMachine& stateMachine));
State* processEvent(Event& evt);
void during() { (_duringLambda)(_owner); }
};
#endif