-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatemachine-4.2.cpp
50 lines (36 loc) · 1.31 KB
/
statemachine-4.2.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
44
45
46
47
48
49
50
#include <iostream>
#include <boost/statechart/event.hpp>
#include <boost/statechart/state_machine.hpp>
#include <boost/statechart/simple_state.hpp>
#include <boost/statechart/transition.hpp>
#include <boost/statechart/custom_reaction.hpp>
namespace sc = boost::statechart;
namespace mpl = boost::mpl;
using namespace std;
// Outer States
struct firstState;
struct secondState;
// Inner States of firstState
struct firstState_Inner_1;
struct firstState_Inner_2;
// Inner State Events
struct event_Inner_To_Second : sc::event<event_Inner_To_Second> {};
struct statemachine : sc::state_machine<statemachine, firstState>{};
struct firstState : sc::simple_state<firstState, statemachine, firstState_Inner_1> {
};
struct firstState_Inner_1 : sc::simple_state<firstState_Inner_1, firstState> {
firstState_Inner_1() { cout << "In State => firstState_Inner_1" << endl; }
typedef sc::transition<event_Inner_To_Second, secondState> reactions;
};
struct firstState_Inner_2 : sc::simple_state<firstState_Inner_2, firstState> {
firstState_Inner_2() { cout << "In State => firstState_Inner_2" << endl; }
};
struct secondState : sc::simple_state<secondState, statemachine> {
secondState() { cout << "In State => secondState" << endl; }
};
int main() {
statemachine sm;
sm.initiate();
sm.process_event(event_Inner_To_Second());
return 0;
}