Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6540097

Browse files
1.2.0 (#42)
Optimized memory footprint using EBCO
1 parentdad93ab commit6540097

File tree

13 files changed

+232
-214
lines changed

13 files changed

+232
-214
lines changed

‎development/ffsm2/detail/root.hpp‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,24 @@ namespace detail {
88
/// @tparam TApex Root region type
99
template<typename TConfig,
1010
typename TApex>
11-
classR_ {
11+
classR_
12+
: protected Material<0,typename RF_<TConfig, TApex>::Args, TApex>
13+
{
1214
public:
1315
staticconstexpr FeatureTag FEATURE_TAG = TConfig::FEATURE_TAG;
1416

1517
using Context=typename TConfig::Context;
1618
using Payload=typename TConfig::Payload;
1719

1820
protected:
19-
using Apex= TApex;
20-
21-
using Forward= RF_<TConfig, Apex>;
21+
using Forward= RF_<TConfig, TApex>;
2222
using StateList=typename Forward::StateList;
2323
using Args=typename Forward::Args;
2424

2525
static_assert(Args::STATE_COUNT < (unsigned) -1,"Too many states in the FSM. Change 'Short' type.");
2626
static_assert(Args::STATE_COUNT == (unsigned) StateList::SIZE,"STATE_COUNT != StateList::SIZE");
2727

28-
usingMaterialApex= Material<0, Args,Apex>;
28+
usingApex= Material<0, Args,TApex>;
2929

3030
using Control= ControlT <Args>;
3131
using PlanControl= PlanControlT <Args>;
@@ -205,8 +205,6 @@ class R_ {
205205

206206
Transition _request;
207207

208-
MaterialApex _apex;
209-
210208
FFSM2_IF_LOG_INTERFACE(Logger* _logger);
211209
};
212210

@@ -303,6 +301,8 @@ class RV_ <G_<NFeatureTag, TContext, Manual, NSubstitutionLimit FFSM2_IF_PLA
303301
using Base::finalExit;
304302

305303
#if FFSM2_TRANSITION_HISTORY_AVAILABLE()
304+
using Apex=typename Base::Apex;
305+
306306
using Base::applyRequest;
307307

308308
using Base::_previousTransition;
@@ -313,7 +313,6 @@ class RV_ <G_<NFeatureTag, TContext, Manual, NSubstitutionLimit FFSM2_IF_PLA
313313
using Base::_planData;
314314
#endif
315315
using Base::_request;
316-
using Base::_apex;
317316
#if FFSM2_LOG_INTERFACE_AVAILABLE()
318317
using Base::_logger;
319318
#endif
@@ -558,11 +557,11 @@ template <FeatureTag NFeatureTag
558557
FFSM2_IF_PLANS(, Long NTaskCapacity)
559558
, typename TPayload
560559
, typename TApex>
561-
class RC_<G_<NFeatureTag, EmptyContext, TActivation, NSubstitutionLimit FFSM2_IF_PLANS(, NTaskCapacity), TPayload>, TApex>final
562-
: publicRP_<G_<NFeatureTag, EmptyContext, TActivation, NSubstitutionLimit FFSM2_IF_PLANS(, NTaskCapacity), TPayload>, TApex>
560+
classFFSM2_EMPTY_BASESRC_<G_<NFeatureTag, EmptyContext, TActivation, NSubstitutionLimit FFSM2_IF_PLANS(, NTaskCapacity), TPayload>, TApex>final
561+
: publicRP_<G_<NFeatureTag, EmptyContext, TActivation, NSubstitutionLimit FFSM2_IF_PLANS(, NTaskCapacity), TPayload>, TApex>
563562
, EmptyContext
564563
{
565-
using Base = RP_<G_<NFeatureTag, EmptyContext, TActivation, NSubstitutionLimitFFSM2_IF_PLANS(, NTaskCapacity), TPayload>, TApex>;
564+
using Base = RP_<G_<NFeatureTag, EmptyContext, TActivation, NSubstitutionLimitFFSM2_IF_PLANS(, NTaskCapacity), TPayload>, TApex>;
566565

567566
public:
568567
staticconstexpr FeatureTag FEATURE_TAG = Base::FEATURE_TAG;

‎development/ffsm2/detail/root.inl‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ R_<TG, TA>::update() noexcept {
1616
FFSM2_IF_TRANSITION_HISTORY(, _previousTransition)
1717
FFSM2_IF_LOG_INTERFACE(, _logger)};
1818

19-
_apex.deepUpdate(control);
19+
Apex::deepUpdate(control);
2020

2121
FFSM2_IF_PLANS(FFSM2_IF_ASSERT(_planData.verifyPlans()));
2222

@@ -44,7 +44,7 @@ R_<TG, TA>::react(const TEvent& event) noexcept {
4444
FFSM2_IF_TRANSITION_HISTORY(, _previousTransition)
4545
FFSM2_IF_LOG_INTERFACE(, _logger)};
4646

47-
_apex.deepReact(control, event);
47+
Apex::deepReact(control, event);
4848

4949
FFSM2_IF_PLANS(FFSM2_IF_ASSERT(_planData.verifyPlans()));
5050

@@ -88,7 +88,7 @@ R_<TG, TA>::save(SerialBuffer& _buffer) const noexcept {
8888
// TODO: save _previousTransition// FFSM2_IF_TRANSITION_HISTORY()
8989
// TODO: save _activityHistory// FFSM2_IF_STRUCTURE_REPORT()
9090

91-
_apex.deepSaveActive(_registry, stream);
91+
Apex::deepSaveActive(_registry, stream);
9292
}
9393

9494
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -108,7 +108,7 @@ R_<TG, TA>::load(const SerialBuffer& buffer) noexcept {
108108
FFSM2_IF_TRANSITION_HISTORY(, _previousTransition)
109109
FFSM2_IF_LOG_INTERFACE(, _logger)};
110110

111-
_apex.deepExit(control);
111+
Apex::deepExit(control);
112112

113113
FFSM2_IF_TRANSITION_HISTORY(_previousTransition.clear());
114114

@@ -124,9 +124,9 @@ R_<TG, TA>::load(const SerialBuffer& buffer) noexcept {
124124
// TODO: load _previousTransition// FFSM2_IF_TRANSITION_HISTORY()
125125
// TODO: load _activityHistory// FFSM2_IF_STRUCTURE_REPORT()
126126

127-
_apex.deepLoadRequested(_registry, stream);
127+
Apex::deepLoadRequested(_registry, stream);
128128

129-
_apex.deepEnter(control);
129+
Apex::deepEnter(control);
130130
}
131131

132132
#endif
@@ -154,7 +154,7 @@ R_<TG, TA>::replayTransition(const StateID destination) noexcept {
154154
applyRequest(destination);
155155
_previousTransition = Transition{destination};
156156

157-
_apex.deepChangeToRequested(control);
157+
Apex::deepChangeToRequested(control);
158158

159159
_registry.clearRequests();
160160

@@ -213,7 +213,7 @@ R_<TG, TA>::initialEnter() noexcept {
213213
}
214214
FFSM2_IF_TRANSITION_HISTORY(_previousTransition = currentTransition);
215215

216-
_apex.deepEnter(control);
216+
Apex::deepEnter(control);
217217

218218
_registry.clearRequests();
219219

@@ -236,7 +236,7 @@ R_<TG, TA>::finalExit() noexcept {
236236
FFSM2_IF_TRANSITION_HISTORY(, _previousTransition)
237237
FFSM2_IF_LOG_INTERFACE(, _logger)};
238238

239-
_apex.deepExit(control);
239+
Apex::deepExit(control);
240240
}
241241

242242
//------------------------------------------------------------------------------
@@ -275,7 +275,7 @@ R_<TG, TA>::processTransitions(Transition& currentTransition) noexcept {
275275
}
276276

277277
if (currentTransition)
278-
_apex.deepChangeToRequested(control);
278+
Apex::deepChangeToRequested(control);
279279

280280
_registry.clearRequests();
281281

@@ -311,7 +311,7 @@ R_<TG, TA>::cancelledByEntryGuards(const Transition& currentTransition,
311311
FFSM2_IF_TRANSITION_HISTORY(, _previousTransition)
312312
FFSM2_IF_LOG_INTERFACE(, _logger)};
313313

314-
return_apex.deepEntryGuard(guardControl);
314+
returnApex::deepEntryGuard(guardControl);
315315
}
316316

317317
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -331,8 +331,8 @@ R_<TG, TA>::cancelledByGuards(const Transition& currentTransition,
331331
FFSM2_IF_TRANSITION_HISTORY(, _previousTransition)
332332
FFSM2_IF_LOG_INTERFACE(, _logger)};
333333

334-
return_apex.deepForwardExitGuard(guardControl) ||
335-
_apex.deepForwardEntryGuard(guardControl);
334+
returnApex::deepForwardExitGuard(guardControl) ||
335+
Apex::deepForwardEntryGuard(guardControl);
336336
}
337337

338338
//------------------------------------------------------------------------------
@@ -363,7 +363,7 @@ RV_<G_<NFT, TC, Manual, NSL FFSM2_IF_PLANS(, NTC), TP>, TA>::replayEnter(const S
363363

364364
FFSM2_IF_TRANSITION_HISTORY(_previousTransition = Transition{destination});
365365

366-
_apex.deepEnter(control);
366+
Apex::deepEnter(control);
367367

368368
_registry.clearRequests();
369369

‎development/ffsm2/detail/shared/macros_on.hpp‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@
6868

6969
//------------------------------------------------------------------------------
7070

71+
#if defined _MSC_VER
72+
#defineFFSM2_EMPTY_BASES__declspec(empty_bases)
73+
#else
74+
#defineFFSM2_EMPTY_BASES
75+
#endif
76+
77+
//------------------------------------------------------------------------------
78+
7179
#defineFFSM2_ARCHITECTURE(A)FFSM2_ARCHITECTURE_##A()
7280

7381
#if INTPTR_MAX == INT64_MAX

‎development/ffsm2/detail/structure/composite.hpp‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,15 @@ namespace detail {
66
template<typename TArgs,
77
typename THead,
88
typename... TSubStates>
9-
structC_final {
9+
structFFSM2_EMPTY_BASES C_
10+
: S_<INVALID_STATE_ID, TArgs, THead>
11+
, CS_<0, TArgs,0, TSubStates...>
12+
{
1013
using Args= TArgs;
1114

15+
using HeadState= S_<INVALID_STATE_ID, Args, THead>;
16+
using SubStates= CS_<0, Args,0, TSubStates...>;
17+
1218
using StateList=typename Args::StateList;
1319

1420
using Control= ControlT<Args>;
@@ -21,12 +27,9 @@ struct C_ final {
2127

2228
using GuardControl= GuardControlT<Args>;
2329

24-
using Head= THead;
25-
using HeadState= S_<INVALID_STATE_ID, Args, Head>;
26-
27-
using SubStates= CS_<0, Args,0, TSubStates...>;
2830

2931
#if FFSM2_SERIALIZATION_AVAILABLE()
32+
using Head= THead;
3033
using Info= CI_<Head, TSubStates...>;
3134

3235
staticconstexpr Short WIDTH = Info::WIDTH;
@@ -66,9 +69,6 @@ struct C_ final {
6669
#endif
6770

6871
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
69-
70-
HeadState _headState;
71-
SubStates _subStates;
7272
};
7373

7474
////////////////////////////////////////////////////////////////////////////////

‎development/ffsm2/detail/structure/composite.inl‎

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ C_<TA, TH, TS...>::deepForwardEntryGuard(GuardControl& control) noexcept {
1818
const Short requested = control._registry.requested;
1919
FFSM2_ASSERT(requested != INVALID_SHORT);
2020

21-
return_subStates.wideEntryGuard(control, requested);
21+
returnSubStates::wideEntryGuard(control, requested);
2222
}
2323

2424
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -30,8 +30,8 @@ C_<TA, TH, TS...>::deepEntryGuard(GuardControl& control) noexcept {
3030
const Short requested = control._registry.requested;
3131
FFSM2_ASSERT(requested != INVALID_SHORT);
3232

33-
return_headState.deepEntryGuard(control) ||
34-
_subStates.wideEntryGuard(control, requested);
33+
returnHeadState::deepEntryGuard(control) ||
34+
SubStates::wideEntryGuard(control, requested);
3535
}
3636

3737
//------------------------------------------------------------------------------
@@ -49,8 +49,8 @@ C_<TA, TH, TS...>::deepEnter(PlanControl& control) noexcept {
4949
active = requested;
5050
requested = INVALID_SHORT;
5151

52-
_headState.deepEnter(control);
53-
_subStates.wideEnter(control, active);
52+
HeadState::deepEnter(control);
53+
SubStates::wideEnter(control, active);
5454
}
5555

5656
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -67,17 +67,17 @@ C_<TA, TH, TS...>::deepUpdate(FullControl& control) noexcept {
6767

6868
FFSM2_ASSERT(control._registry.requested == INVALID_SHORT);
6969

70-
if (_headState.deepUpdate(control)) {
70+
if (HeadState::deepUpdate(control)) {
7171
ControlLock lock{control};
7272

73-
_subStates.wideUpdate(control, active);
73+
SubStates::wideUpdate(control, active);
7474
}else {
7575
FFSM2_IF_PLANS(const Status subStatus =)
76-
_subStates.wideUpdate(control, active);
76+
SubStates::wideUpdate(control, active);
7777

7878
#if FFSM2_PLANS_AVAILABLE()
7979
if (subStatus && control._planData.planExists)
80-
control.updatePlan(_headState, subStatus);
80+
control.updatePlan((HeadState&) *this, subStatus);
8181
#endif
8282
}
8383
}
@@ -96,17 +96,17 @@ C_<TA, TH, TS...>::deepReact(FullControl& control,
9696

9797
FFSM2_ASSERT(control._registry.requested == INVALID_SHORT);
9898

99-
if (_headState.deepReact(control, event)) {
99+
if (HeadState::deepReact(control, event)) {
100100
ControlLock lock{control};
101101

102-
_subStates.wideReact(control, event, active);
102+
SubStates::wideReact(control, event, active);
103103
}else {
104104
FFSM2_IF_PLANS(const Status subStatus =)
105-
_subStates.wideReact(control, event, active);
105+
SubStates::wideReact(control, event, active);
106106

107107
#if FFSM2_PLANS_AVAILABLE()
108108
if (subStatus && control._planData.planExists)
109-
control.updatePlan(_headState, subStatus);
109+
control.updatePlan((HeadState&) *this, subStatus);
110110
#endif
111111
}
112112
}
@@ -122,7 +122,7 @@ C_<TA, TH, TS...>::deepForwardExitGuard(GuardControl& control) noexcept {
122122
const Short active = control._registry.active;
123123
FFSM2_ASSERT(active != INVALID_SHORT);
124124

125-
return_subStates.wideExitGuard(control, active);
125+
returnSubStates::wideExitGuard(control, active);
126126
}
127127

128128
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -136,8 +136,8 @@ C_<TA, TH, TS...>::deepExitGuard(GuardControl& control) noexcept {
136136

137137
FFSM2_ASSERT(control._registry.requested != INVALID_SHORT);
138138

139-
return_headState.deepExitGuard(control) ||
140-
_subStates.wideExitGuard(control, active);
139+
returnHeadState::deepExitGuard(control) ||
140+
SubStates::wideExitGuard(control, active);
141141
}
142142

143143
//------------------------------------------------------------------------------
@@ -149,8 +149,8 @@ C_<TA, TH, TS...>::deepExit(PlanControl& control) noexcept {
149149
Short& active = control._registry.active;
150150
FFSM2_ASSERT(active != INVALID_SHORT);
151151

152-
_subStates.wideExit(control, active);
153-
_headState.deepExit(control);
152+
SubStates::wideExit(control, active);
153+
HeadState::deepExit(control);
154154

155155
active = INVALID_SHORT;
156156

@@ -175,17 +175,17 @@ C_<TA, TH, TS...>::deepChangeToRequested(PlanControl& control) noexcept {
175175
FFSM2_ASSERT(requested != INVALID_SHORT);
176176

177177
if (requested != active) {
178-
_subStates.wideExit (control, active);
178+
SubStates::wideExit (control, active);
179179

180180
active = requested;
181181
requested = INVALID_SHORT;
182182

183-
_subStates.wideEnter (control, active);
183+
SubStates::wideEnter (control, active);
184184
}else {
185185
requested = INVALID_SHORT;
186186

187187
// reconstruction done in S_::reenter()
188-
_subStates.wideReenter(control, active);
188+
SubStates::wideReenter(control, active);
189189
}
190190
}
191191

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp