-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommonDefines.h
executable file
·111 lines (94 loc) · 2.7 KB
/
CommonDefines.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#pragma once
#include"RxFSM/IncludeExtLibs.h"
#include"RxFSM/Export.h"
namespace Reactor
{
typedef BaseLib::Templates::NameDescription StateDescription;
typedef BaseLib::Templates::NameDescription StateMachineDescription;
// ----------------------------------------------------
// StateStatus
// ----------------------------------------------------
enum class DLL_STATE StateStatusKind
{
INACTIVE,
ENTERING,
ENTERED,
INPUT,
INPUTTED,
TRANSITION,
EXITED,
};
typedef Status::EventStatusTracker<StateStatusKind, int> StateStatus;
static std::ostream& operator<<(std::ostream& ostr, const StateStatusKind& kind)
{
switch(kind)
{
#define CASE(t) case t: ostr << #t; break;
CASE(StateStatusKind::INACTIVE)
CASE(StateStatusKind::ENTERING)
CASE(StateStatusKind::ENTERED)
CASE(StateStatusKind::INPUT)
CASE(StateStatusKind::INPUTTED)
CASE(StateStatusKind::TRANSITION)
CASE(StateStatusKind::EXITED)
#undef CASE
default:
std::cerr << "Missing operator<< case for StateStatusKind" << std::endl;
break;
}
return ostr;
}
static std::ostream& operator<<(std::ostream& ostr, const StateStatus& status)
{
ostr << "["
<< status.CurrentState()
<< ", "
<< status.PreviousState()
<< "]";
return ostr;
}
// ----------------------------------------------------
// StateMachineStatus
// ----------------------------------------------------
enum class DLL_STATE StateMachineStatusKind
{
WAIT,
VIRTUAL_INPUT,
INPUT_ACTION_CONDITION,
EXECUTE_INPUT_ACTION,
TRANSITION_CONDITION,
EXECUTE_EXIT_ACTION,
CHANGE_STATE,
EXECUTE_ENTRY_ACTION
};
typedef Status::EventStatusTracker<StateMachineStatusKind, int> StateMachineStatus;
static std::ostream& operator<<(std::ostream& ostr, const StateMachineStatusKind& kind)
{
switch(kind)
{
#define CASE(t) case t: ostr << #t; break;
CASE(StateMachineStatusKind::WAIT)
CASE(StateMachineStatusKind::VIRTUAL_INPUT)
CASE(StateMachineStatusKind::INPUT_ACTION_CONDITION)
CASE(StateMachineStatusKind::EXECUTE_INPUT_ACTION)
CASE(StateMachineStatusKind::TRANSITION_CONDITION)
CASE(StateMachineStatusKind::EXECUTE_EXIT_ACTION)
CASE(StateMachineStatusKind::CHANGE_STATE)
CASE(StateMachineStatusKind::EXECUTE_ENTRY_ACTION)
#undef CASE
default:
std::cerr << "Missing operator<< case for StateStatusKind" << std::endl;
break;
}
return ostr;
}
static std::ostream& operator<<(std::ostream& ostr, const StateMachineStatus& status)
{
ostr << "["
<< status.CurrentState()
<< ", "
<< status.PreviousState()
<< "]";
return ostr;
}
}