File tree Expand file tree Collapse file tree
include/cpp_event_framework Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33namespace example ::interface
44{
5- Fsm::Transition Fsm::State1Handler ( ImplPtr /* impl */ , Event event)
5+ static Fsm::Transition State1Handler ( Fsm::ImplPtr /* impl */ , Fsm:: Event event)
66{
77 switch (event)
88 {
99 case EEvent::kGo2 :
10- return TransitionTo (kState2 );
10+ return Fsm:: TransitionTo (Fsm:: kState2 );
1111 default :
12- return NoTransition ();
12+ return Fsm:: NoTransition ();
1313 }
1414}
1515
16- Fsm::Transition Fsm::State2Handler ( ImplPtr impl, Event event)
16+ static Fsm::Transition State2Handler ( Fsm::ImplPtr impl, Fsm:: Event event)
1717{
1818 switch (event)
1919 {
2020 case EEvent::kGo1 :
2121 if (impl->SomeGuardFunction (event))
2222 {
23- return TransitionTo (kState1 , &Impl::State2ToState1TransitionAction);
23+ return Fsm:: TransitionTo (Fsm:: kState1 , &Fsm:: Impl::State2ToState1TransitionAction);
2424 }
25- return NoTransition ();
25+ return Fsm:: NoTransition ();
2626 default :
27- return UnhandledEvent ();
27+ return Fsm:: UnhandledEvent ();
2828 }
2929}
3030
Original file line number Diff line number Diff line change @@ -11,10 +11,6 @@ public:
1111 static const State kState1 ;
1212 static const State kState2 ;
1313
14- // Handlers
15- static Transition State1Handler (ImplPtr impl, Event event);
16- static Transition State2Handler (ImplPtr impl, Event event);
17-
1814 inline void Start ()
1915 {
2016 FsmBase::Start (&kState1 );
Original file line number Diff line number Diff line change 22
33namespace example ::pimpl
44{
5- Fsm::Transition Fsm::State1Handler ( ImplPtr /* impl */ , Event event)
5+ static Fsm::Transition State1Handler ( Fsm::ImplPtr /* impl */ , Fsm:: Event event)
66{
77 switch (event)
88 {
99 case EEvent::kGo2 :
10- return TransitionTo (kState2 );
10+ return Fsm:: TransitionTo (Fsm:: kState2 );
1111 default :
12- return NoTransition ();
12+ return Fsm:: NoTransition ();
1313 }
1414}
1515
16- Fsm::Transition Fsm::State2Handler ( ImplPtr impl, Event event)
16+ static Fsm::Transition State2Handler ( Fsm::ImplPtr impl, Fsm:: Event event)
1717{
1818 switch (event)
1919 {
2020 case EEvent::kGo1 :
2121 if (impl->SomeGuardFunction (event))
2222 {
23- return TransitionTo (kState1 , &Impl::State2ToState1TransitionAction);
23+ return Fsm:: TransitionTo (Fsm:: kState1 , &Fsm:: Impl::State2ToState1TransitionAction);
2424 }
25- return NoTransition ();
25+ return Fsm:: NoTransition ();
2626 default :
27- return UnhandledEvent ();
27+ return Fsm:: UnhandledEvent ();
2828 }
2929}
3030
Original file line number Diff line number Diff line change @@ -11,10 +11,6 @@ public:
1111 static const State kState1 ;
1212 static const State kState2 ;
1313
14- // Handlers
15- static Transition State1Handler (ImplPtr impl, Event event);
16- static Transition State2Handler (ImplPtr impl, Event event);
17-
1814 inline void Start ()
1915 {
2016 FsmBase::Start (&kState1 );
Original file line number Diff line number Diff line change @@ -26,18 +26,14 @@ public:
2626
2727 void Run ();
2828
29- private:
30- struct Private ;
31- std::unique_ptr<Private> private_;
32-
33- // Give Fsm access to private entry/exit/transition actions
34- // (This is not needed if actions are public functions)
35- friend class Fsm ;
36-
3729 void State1Entry ();
3830
3931 void State2ToState1TransitionAction (FsmBase::Event event);
4032
4133 bool SomeGuardFunction (FsmBase::Event event);
34+
35+ private:
36+ struct Private ;
37+ std::unique_ptr<Private> private_;
4238};
4339} // namespace example::pimpl
Original file line number Diff line number Diff line change @@ -49,29 +49,29 @@ bool FsmImpl::SomeGuardFunction(FsmBase::Event /*event*/)
4949
5050// FSM code
5151
52- Fsm::Transition Fsm::State1Handler ( ImplPtr /* impl */ , Event event)
52+ static Fsm::Transition State1Handler ( Fsm::ImplPtr /* impl */ , Fsm:: Event event)
5353{
5454 switch (event)
5555 {
5656 case EEvent::kGo2 :
57- return TransitionTo (kState2 );
57+ return Fsm:: TransitionTo (Fsm:: kState2 );
5858 default :
59- return NoTransition ();
59+ return Fsm:: NoTransition ();
6060 }
6161}
6262
63- Fsm::Transition Fsm::State2Handler ( ImplPtr impl, Event event)
63+ static Fsm::Transition State2Handler ( Fsm::ImplPtr impl, Fsm:: Event event)
6464{
6565 switch (event)
6666 {
6767 case EEvent::kGo1 :
6868 if (impl->SomeGuardFunction (event))
6969 {
70- return TransitionTo (kState1 , &Impl::State2ToState1TransitionAction);
70+ return Fsm:: TransitionTo (Fsm:: kState1 , &Fsm:: Impl::State2ToState1TransitionAction);
7171 }
72- return NoTransition ();
72+ return Fsm:: NoTransition ();
7373 default :
74- return UnhandledEvent ();
74+ return Fsm:: UnhandledEvent ();
7575 }
7676}
7777
Original file line number Diff line number Diff line change @@ -20,10 +20,6 @@ public:
2020 static const State kState1 ;
2121 static const State kState2 ;
2222
23- // Handlers
24- static Transition State1Handler (ImplPtr impl, Event event);
25- static Transition State2Handler (ImplPtr impl, Event event);
26-
2723 inline void Start ()
2824 {
2925 FsmBase::Start (&kState1 );
@@ -38,17 +34,13 @@ public:
3834
3935 void Run ();
4036
41- private:
42- Fsm fsm_;
43-
44- // Give Fsm access to private entry/exit/transition actions
45- // (This is not needed if actions are public functions)
46- friend class Fsm ;
47-
4837 void State1Entry ();
4938
5039 void State2ToState1TransitionAction (FsmBase::Event event);
5140
5241 bool SomeGuardFunction (FsmBase::Event event);
42+
43+ private:
44+ Fsm fsm_;
5345};
5446} // namespace example::plain
Original file line number Diff line number Diff line change 1- #include < iostream>
2-
31#include " Fsm.hxx"
42
53namespace example ::signals
64{
7- Fsm::Transition Fsm::State1Handler ( ImplPtr /* impl */ , Event event)
5+ static Fsm::Transition State1Handler ( Fsm::ImplPtr /* impl */ , Fsm:: Event event)
86{
97 switch (event->Id ())
108 {
119 case Go2::kId :
12- return TransitionTo (kState2 );
10+ return Fsm:: TransitionTo (Fsm:: kState2 );
1311 default :
14- return NoTransition ();
12+ return Fsm:: NoTransition ();
1513 }
1614}
1715
18- Fsm::Transition Fsm::State2Handler ( ImplPtr impl, Event event)
16+ static Fsm::Transition State2Handler ( Fsm::ImplPtr impl, Fsm:: Event event)
1917{
2018 switch (event->Id ())
2119 {
2220 case Go1::kId :
2321 if (impl->SomeGuardFunction (event))
2422 {
25- return TransitionTo (kState1 , &Impl::State2ToState1TransitionAction);
23+ return Fsm:: TransitionTo (Fsm:: kState1 , &Fsm:: Impl::State2ToState1TransitionAction);
2624 }
27- return NoTransition ();
25+ return Fsm:: NoTransition ();
2826 default :
29- return UnhandledEvent ();
27+ return Fsm:: UnhandledEvent ();
3028 }
3129}
3230
Original file line number Diff line number Diff line change @@ -11,10 +11,6 @@ public:
1111 static const State kState1 ;
1212 static const State kState2 ;
1313
14- // Handlers
15- static Transition State1Handler (ImplPtr impl, Event event);
16- static Transition State2Handler (ImplPtr impl, Event event);
17-
1814 inline void Start ()
1915 {
2016 FsmBase::Start (&kState1 );
Original file line number Diff line number Diff line change @@ -335,7 +335,7 @@ public:
335335 * @brief Statename, optional, useful for logging
336336 *
337337 */
338- const char * name_ = " Unnamed " ;
338+ const char * name_ = nullptr ;
339339 };
340340
341341 /* *
You can’t perform that action at this time.
0 commit comments