MCPcopy Create free account
hub / github.com/digint/tinyfsm / Switch

Class Switch

examples/api/debugging_switch.cpp:17–48  ·  view source on GitHub ↗

---------------------------------------------------------------------------- State Machine Declaration

Source from the content-addressed store, hash-verified

15// State Machine Declaration
16//
17struct Switch
18: tinyfsm::Fsm<Switch>
19{
20 static void reset(void);
21
22 // NOTE: on reset: "tinyfsm::StateList<Off, On>::reset()", copy
23 // constructor is used by default, so "this" points to neither
24 // "Off" nor "On" (see operator=() below).
25 Switch() : counter(0) {
26 std::cout << "* Switch()" << std::endl
27 << " this = " << this << std::endl;
28 }
29
30 ~Switch() {
31 std::cout << "* ~Switch()" << std::endl
32 << " this = " << this << std::endl;
33 }
34
35 Switch & operator=(const Switch & other) {
36 std::cout << "* operator=()" << std::endl
37 << " this = " << this << std::endl
38 << " other = " << &other << std::endl;
39 counter = other.counter;
40 return *this;
41 }
42
43 virtual void react(Toggle const &) { };
44 void entry(void);
45 void exit(void);
46
47 int counter;
48};
49
50struct On : Switch {
51 void react(Toggle const &) override { transit<Off>(); };

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected