-
Notifications
You must be signed in to change notification settings - Fork 3
/
simple.cpp
43 lines (37 loc) · 839 Bytes
/
simple.cpp
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
#include "msfsm.hpp"
#include <iostream>
using namespace msfsm;
using namespace std;
class Simple : public Fsm<Simple> {
public:
Simple() {
transition(off);
}
using Fsm::transition; // Make transition public
class Off : public State {
friend Fsm;
using State::State;
void entry() {
cout << "Entering off" << endl;
}
void exit() override {
cout << "Exiting off" << endl;
}
} off {this};
class On : public State {
friend Fsm;
using State::State;
void entry() {
cout << "Entering on" << endl;
}
void exit() override {
cout << "Exiting on" << endl;
}
} on {this};
};
int main(int argc, char *argv[])
{
Simple s;
s.transition(s.on);
return 0;
}