cff8288bb68905adbaae1dbb9dfd512b057f23d5
[olsrd.git] / lib / pud / src / state.h
1 #ifndef _PUD_STATE_H_
2 #define _PUD_STATE_H_
3
4 /* Plugin includes */
5
6 /* OLSRD includes */
7
8 /* System includes */
9 #include <stdbool.h>
10
11 /*
12  * Types
13  */
14
15 /** Type describing a tri-state boolean */
16 typedef enum _TristateBoolean {
17         TRISTATE_BOOLEAN_UNKNOWN = 0,
18         TRISTATE_BOOLEAN_UNSET = 1,
19         TRISTATE_BOOLEAN_SET = 2
20 } TristateBoolean;
21
22 #define TristateBooleanToString(s)      ((s == TRISTATE_BOOLEAN_SET) ? "set" : \
23                                                                          (s == TRISTATE_BOOLEAN_UNSET) ? "unset" : \
24                                                                          "unknown")
25
26 /** Type describing movement state */
27 typedef enum _MovementState {
28         MOVEMENT_STATE_STATIONARY = 0,
29         MOVEMENT_STATE_MOVING = 1
30 } MovementState;
31
32 #define MovementStateToString(s)        ((s == MOVEMENT_STATE_MOVING) ? "moving" : \
33                                                                          "stationary")
34
35 /** Type describing substate indexes */
36 typedef enum _SubStateIndex {
37         SUBSTATE_POSITION = 0,
38         SUBSTATE_GATEWAY = 1,
39         SUBSTATE_COUNT = 2
40 } SubStateIndex;
41
42 /*
43  * Functions
44  */
45
46 bool initState(void);
47 void destroyState(void);
48 MovementState getExternalState(void);
49 MovementState getInternalState(SubStateIndex subStateIndex);
50 bool determineStateWithHysteresis(SubStateIndex subStateIndex, TristateBoolean movingNow,
51                 MovementState * externalState);
52
53 #endif /* _PUD_STATE_H_ */