Ticket #13132: 1.cpp

File 1.cpp, 1.2 KB (added by Janusz Piwowarski <jpiw@…>, 5 years ago)
Line 
1#include <boost/msm/back/state_machine.hpp>
2#include <boost/msm/front/state_machine_def.hpp>
3#include <boost/msm/front/functor_row.hpp>
4
5namespace msm = boost::msm;
6namespace mpl = boost::mpl;
7using namespace msm::front;
8
9struct E {};
10
11struct A : public state<>
12{
13 bool started = false;
14 template <class Event, class Fsm>
15 void on_entry(Event const&, Fsm& m)
16 {
17 m.process_event(E());
18 started = true;
19 }
20};
21
22struct check_started
23{
24 template <class Fsm, class Evt, class SourceState, class TargetState>
25 void operator()(Evt const&, Fsm&, SourceState& s, TargetState&)
26 {
27 assert(s.started);
28 }
29};
30
31struct Machine_ : public state_machine_def<Machine_>
32{
33 struct transition_table : mpl::vector<
34 // Start Event Target Action Guard
35 // +--------+---------+--------+---------------------------+------+
36 Row< A , E , none , check_started , none >
37 // +--------+---------+--------+---------------------------+------+
38 > {};
39
40 typedef A initial_state;
41};
42
43typedef msm::back::state_machine<Machine_> Machine;
44
45int main()
46{
47 Machine m;
48 m.start();
49
50 return 0;
51}