| 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 |
|
|---|
| 5 | namespace msm = boost::msm;
|
|---|
| 6 | namespace mpl = boost::mpl;
|
|---|
| 7 | using namespace msm::front;
|
|---|
| 8 |
|
|---|
| 9 | struct E {};
|
|---|
| 10 |
|
|---|
| 11 | struct 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 |
|
|---|
| 22 | struct 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 |
|
|---|
| 31 | struct 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 |
|
|---|
| 43 | typedef msm::back::state_machine<Machine_> Machine;
|
|---|
| 44 |
|
|---|
| 45 | int main()
|
|---|
| 46 | {
|
|---|
| 47 | Machine m;
|
|---|
| 48 | m.start();
|
|---|
| 49 |
|
|---|
| 50 | return 0;
|
|---|
| 51 | }
|
|---|