1 | #include <boost/intrusive_ptr.hpp>
|
---|
2 |
|
---|
3 | #include <boost/mpl/list.hpp>
|
---|
4 |
|
---|
5 | #include <boost/statechart/custom_reaction.hpp>
|
---|
6 | #include <boost/statechart/event.hpp>
|
---|
7 | #include <boost/statechart/simple_state.hpp>
|
---|
8 | #include <boost/statechart/state.hpp>
|
---|
9 | #include <boost/statechart/state_machine.hpp>
|
---|
10 |
|
---|
11 | #include <iostream>
|
---|
12 |
|
---|
13 | using namespace std;
|
---|
14 |
|
---|
15 | namespace sc = boost::statechart;
|
---|
16 | namespace mpl = boost::mpl;
|
---|
17 |
|
---|
18 | namespace BUG {
|
---|
19 |
|
---|
20 | struct evSay : sc::event<evSay>{ };
|
---|
21 |
|
---|
22 | struct top;
|
---|
23 | struct c1;
|
---|
24 | struct c2;
|
---|
25 | struct c3;
|
---|
26 |
|
---|
27 |
|
---|
28 | struct sm : public sc::state_machine<sm,top> { };
|
---|
29 |
|
---|
30 | struct top : sc::simple_state<top,sm,mpl::list<c1,c2,c3> >
|
---|
31 | {
|
---|
32 | typedef sc::simple_state<top,sm,mpl::list<c1,c2,c3> > my_type;
|
---|
33 | typedef sc::custom_reaction<evSay> reactions;
|
---|
34 |
|
---|
35 | sc::result react(const evSay &)
|
---|
36 | {
|
---|
37 | cout<<"BUGGY"<<endl;
|
---|
38 | return forward_event();
|
---|
39 | }
|
---|
40 | };
|
---|
41 |
|
---|
42 | struct c1 : sc::simple_state <c1, top::orthogonal<0> > { };
|
---|
43 |
|
---|
44 | struct c2 : sc::simple_state <c2, top::orthogonal<1> > { };
|
---|
45 |
|
---|
46 | struct c3 : sc::state <c3, top::orthogonal<2> > {
|
---|
47 | c3( my_context ctx) : my_base(ctx) {
|
---|
48 | post_event( boost::intrusive_ptr< evSay > (
|
---|
49 | new evSay() ) );
|
---|
50 | }
|
---|
51 | };
|
---|
52 | }
|
---|
53 |
|
---|
54 | int main()
|
---|
55 | {
|
---|
56 | BUG::sm* fsm = new BUG::sm();
|
---|
57 | fsm->initiate();
|
---|
58 | delete fsm;
|
---|
59 | return 0;
|
---|
60 | }
|
---|