#ifndef PLAYING_MODE_HPP #define PLAYING_MODE_HPP #include #include #include #include #include using namespace std; namespace msm = boost::msm; namespace mpl = boost::mpl; struct EndPlay {}; struct PlayingMode_ : public msm::front::state_machine_def { struct Playing : public msm::front::state<> { template void on_entry(Event const&,FSM& ) { std::cout << "starting: PlayingMode::Playing" << std::endl; } template void on_exit(Event const&,FSM& ) {std::cout << "finishing: PlayingMode::Playing" << std::endl;} }; struct PlayingExit : public msm::front::exit_pseudo_state { template void on_entry(Event const&,FSM& ) {std::cout << "starting: PlayingMode::PlayingExit" << std::endl;} template void on_exit(Event const&,FSM& ) {std::cout << "finishing: PlayingMode::PlayingExit" << std::endl;} }; // initial states / orthogonal zones typedef mpl::vector1 initial_state; typedef PlayingMode_ fsm; // makes transition table cleaner // Transition table for player struct transition_table : mpl::vector< // Start Event Next Action Guard // +--------------------+---------------------+--------------------+----------- ---------------+----------------------+ msm::front::Row < Playing , EndPlay , PlayingExit > //2nd version // msm::front::Row < Playing , msm::front::none , PlayingExit > // +--------------------+---------------------+---------------------+---------- ----------------+----------------------+ > {}; }; typedef msm::back::state_machine PlayingMode; #endif // PLAYING_MODE_HPP