boost msm class? -
i newbi boost msm , boost in general. somehow encapsulate the:
- event structures
- statemahine structure containing transition table structure , state structures
within class.
how can that?
// events struct event1 {}; // front-end: define fsm structure struct my_machine_ : public msm::front::state_machine_def<my_machine_> { // list of fsm states struct state1 : public msm::front::state<> { // every (optional) entry/exit methods event passed. template <class event,class fsm> void on_entry(event const&,fsm& ) {std::cout << "entering: state1" << std::endl;} template <class event,class fsm> void on_exit(event const&,fsm& ) {std::cout << "leaving: state1" << std::endl;} }; struct state2 : public msm::front::state<> { template <class event,class fsm> void on_entry(event const& ,fsm&) {std::cout << "entering: state3" << std::endl;} template <class event,class fsm> void on_exit(event const&,fsm& ) {std::cout << "leaving: state3" << std::endl;} }; // initial state of player sm. must defined typedef state1 initial_state; typedef my_machine_ p; // makes transition table cleaner // transition table struct transition_table : mpl::vector< // start event next action guard // +---------+-------------+---------+---------------------+----------------------+ row < state1 , event1 , state2 >, row < state2 , event1 , state1 > > {}; };
to implement member of nested use:
// header file struct foo { struct nested { void mem(); }; }; // cpp file void foo::nested::mem() { // implementation goes here }
Comments
Post a Comment