Ticket #3220: bug.cpp

File bug.cpp, 1.2 KB (added by anonymous, 13 years ago)

code example

Line 
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
13using namespace std;
14
15namespace sc = boost::statechart;
16namespace mpl = boost::mpl;
17
18namespace BUG {
19
20struct evSay : sc::event<evSay>{ };
21
22struct top;
23struct c1;
24struct c2;
25struct c3;
26
27
28struct sm : public sc::state_machine<sm,top> { };
29
30struct 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
42struct c1 : sc::simple_state <c1, top::orthogonal<0> > { };
43
44struct c2 : sc::simple_state <c2, top::orthogonal<1> > { };
45
46struct 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
54int main()
55{
56 BUG::sm* fsm = new BUG::sm();
57 fsm->initiate();
58 delete fsm;
59 return 0;
60}