/
orthogonal.hpp
139 lines (100 loc) · 5.12 KB
/
orthogonal.hpp
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
namespace hfsm2 {
namespace detail {
////////////////////////////////////////////////////////////////////////////////
template <typename TIndices,
typename TArgs,
typename THead,
typename... TSubStates>
struct O_ final {
using Indices = TIndices;
static constexpr StateID HEAD_ID = Indices::STATE_ID;
static constexpr ShortIndex COMPO_INDEX = Indices::COMPO_INDEX;
static constexpr ShortIndex ORTHO_INDEX = Indices::ORTHO_INDEX;
static constexpr ShortIndex ORTHO_UNIT = Indices::ORTHO_UNIT;
static constexpr ShortIndex REGION_ID = COMPO_INDEX + ORTHO_INDEX;
static constexpr ForkID ORTHO_ID = (ForkID) -ORTHO_INDEX - 1;
using Args = TArgs;
using Rank = typename Args::Rank;
using Utility = typename Args::Utility;
using UP = typename Args::UP;
using StateList = typename Args::StateList;
using RegionList = typename Args::RegionList;
using Payload = typename Args::Payload;
using Head = THead;
using Info = OI_<Head, TSubStates...>;
static constexpr ShortIndex WIDTH = Info::WIDTH;
static constexpr ShortIndex REGION_SIZE = Info::STATE_COUNT;
static constexpr ShortIndex ORTHO_UNITS = Info::ORTHO_UNITS;
using Request = RequestT<Payload>;
using RequestType = typename Request::Type;
using StateRegistry = StateRegistryT<Args>;
using StateParents = typename StateRegistry::StateParents;
using OrthoForks = typename StateRegistry::AllForks::Ortho;
using ProngBits = typename OrthoForks::Bits;
using ProngConstBits= typename OrthoForks::ConstBits;
using Control = ControlT<Args>;
using PlanControl = PlanControlT<Args>;
using ScopedOrigin = typename PlanControl::Origin;
using ScopedRegion = typename PlanControl::Region;
using FullControl = FullControlT<Args>;
using ControlLock = typename FullControl::Lock;
using GuardControl = GuardControlT<Args>;
using HeadState = S_<Indices, Args, Head>;
using SubStates = OS_<I_<HEAD_ID + 1,
COMPO_INDEX,
ORTHO_INDEX + 1,
ORTHO_UNIT + (WIDTH + 7) / 8>,
Args,
0,
TSubStates...>;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
HFSM_INLINE ProngBits orthoRequested( StateRegistry& stateRegistry) { return stateRegistry.requested.ortho.template bits<ORTHO_UNIT, WIDTH>(); }
HFSM_INLINE ProngConstBits orthoRequested(const StateRegistry& stateRegistry) const { return stateRegistry.requested.ortho.template bits<ORTHO_UNIT, WIDTH>(); }
HFSM_INLINE ProngBits orthoRequested( Control& control) { return orthoRequested(control._stateRegistry); }
HFSM_INLINE ProngConstBits orthoRequested(const Control& control) const { return orthoRequested(control._stateRegistry); }
HFSM_INLINE void deepRegister (StateRegistry& stateRegistry, const Parent parent);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
HFSM_INLINE bool deepForwardEntryGuard(GuardControl& control);
HFSM_INLINE bool deepEntryGuard (GuardControl& control);
HFSM_INLINE void deepEnter (PlanControl& control);
HFSM_INLINE void deepReenter (PlanControl& control);
HFSM_INLINE Status deepUpdate (FullControl& control);
template <typename TEvent>
HFSM_INLINE Status deepReact (FullControl& control, const TEvent& event);
HFSM_INLINE bool deepForwardExitGuard (GuardControl& control);
HFSM_INLINE bool deepExitGuard (GuardControl& control);
HFSM_INLINE void deepExit (PlanControl& control);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
HFSM_INLINE void deepForwardActive (Control& control, const RequestType request);
HFSM_INLINE void deepForwardRequest (Control& control, const RequestType request);
HFSM_INLINE void deepRequest (Control& control, const RequestType request);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
HFSM_INLINE void deepRequestChange (Control& control);
HFSM_INLINE void deepRequestRemain (StateRegistry& stateRegistry);
HFSM_INLINE void deepRequestRestart (StateRegistry& stateRegistry);
HFSM_INLINE void deepRequestResume (StateRegistry& stateRegistry);
HFSM_INLINE void deepRequestUtilize (Control& control);
HFSM_INLINE void deepRequestRandomize (Control& control);
HFSM_INLINE UP deepReportChange (Control& control);
HFSM_INLINE UP deepReportUtilize (Control& control);
HFSM_INLINE Rank deepReportRank (Control& control);
HFSM_INLINE Utility deepReportRandomize (Control& control);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
HFSM_INLINE void deepEnterRequested (PlanControl& control);
HFSM_INLINE void deepChangeToRequested(PlanControl& control);
#ifdef HFSM_ENABLE_STRUCTURE_REPORT
using StructureStateInfos = typename Args::StructureStateInfos;
using RegionType = typename StructureStateInfo::RegionType;
static constexpr LongIndex NAME_COUNT = HeadState::NAME_COUNT + SubStates::NAME_COUNT;
void deepGetNames(const LongIndex parent,
const RegionType region,
const ShortIndex depth,
StructureStateInfos& stateInfos) const;
#endif
HeadState _headState;
SubStates _subStates;
};
////////////////////////////////////////////////////////////////////////////////
}
}
#include "orthogonal.inl"