Out-of-office display, GFX
 All Classes Files Functions Variables Enumerations Enumerator Groups
stateMachine.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 Andreas Misje
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
27 #ifndef STATEMACHINE_H
28 #define STATEMACHINE_H
29 
30 #include <stddef.h>
31 #include <stdbool.h>
32 
43 struct event
44 {
46  int type;
54  void *data;
55 };
56 
57 struct state;
58 
110 {
121  void *condition;
135  bool ( *guard )( void *condition, struct event *event );
144  void ( *action )( struct event *event );
152  struct state *nextState;
153 };
154 
232 struct state
233 {
242  struct state *entryState;
255  void *data;
266  void ( *entryAction )( void *stateData, struct event *event );
277  void ( *exitAction )( void *stateData, struct event *event );
278 };
279 
286 {
300  struct state *errorState;
301 };
302 
321  struct state *initialState, struct state *errorState );
322 
327 {
350 };
351 
366  struct event *event );
367 
377 
388 
399 
400 #endif // STATEMACHINE_H
401