-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
40 lines (31 loc) · 870 Bytes
/
main.cpp
File metadata and controls
40 lines (31 loc) · 870 Bytes
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
#include <iostream>
#include <memory>
#include <string>
#include "state_machine.h"
using namespace std;
class StatefulObject: public StateMachine
{
public:
StatefulObject()
{
AddTransition(start, make_pair(idle, running), []{return true;});
AddTransition(stop, make_pair(running, idle), []{return true;});
AddTransition(cancel, make_pair(idle, cancelled), []{return true;});
AddTransition(reset, make_pair(cancelled, idle));
Init(idle);
cout << GetState() << endl;
DoTransition(start);
cout << GetState() << endl;
DoTransition(stop);
cout << GetState() << endl;
DoTransition(cancel);
cout << GetState() << endl;
DoTransition(reset);
cout << GetState() << endl;
}
};
int main(int argc, char* argv[])
{
StatefulObject rs;
return 0;
}