---------------------------------------------------------------------------- State Machine Declaration
| 15 | // State Machine Declaration |
| 16 | // |
| 17 | struct 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 | |
| 50 | struct On : Switch { |
| 51 | void react(Toggle const &) override { transit<Off>(); }; |
nothing calls this directly
no outgoing calls
no test coverage detected