#include #include #include #include #include namespace msm = boost::msm; namespace msmf = boost::msm::front; namespace mpl = boost::mpl; namespace { // ----- Events struct Event1 {}; // ----- State machine struct OuterSm_:msmf::state_machine_def { struct StateSub_:msmf::state_machine_def { template void on_entry(Event const&, Fsm&) const { std::cout << "StateSub_::on_entry()" << std::endl; } template void on_exit(Event const&, Fsm&) const { std::cout << "StateSub_::on_exit()" << std::endl; } struct SubState1:msmf::state<> { template void on_entry(Event const&, Fsm&) const { std::cout << "SubState1::on_entry()" << std::endl; } template void on_exit(Event const&, Fsm&) const { std::cout << "SubState1::on_exit()" << std::endl; } }; struct Exit1:msmf::exit_pseudo_state {}; // Set initial state typedef SubState1 initial_state; // Transition table struct transition_table:mpl::vector< // Start Event Next Action Guard msmf::Row < SubState1, Event1, Exit1, msmf::none, msmf::none > > {}; }; typedef msm::back::state_machine StateSub; struct End: msmf::terminate_state<> {}; // Set initial state typedef StateSub initial_state; // Transition table struct transition_table:mpl::vector< // Start Event Next Action Guard msmf::Row < StateSub::exit_pt , msmf::none, End, msmf::none, msmf::none > > {}; }; // Pick a back-end typedef msm::back::state_machine Osm; void test() { Osm osm; osm.start(); std::cout << "> Send Event1()" << std::endl; osm.process_event(Event1()); } } int main() { test(); return 0; }