On 05.06.2013 1:06, Christophe Henry wrote:
Hi,
this should now work (rev 84642 in trunk). Could you give it a try?
It's too late for 1.54 so it will make it into 1.55.
I tested it against trunk rev 84986 with vs2012u2.
It works perfectly!
Looking forward to see it in 1.55
test code:
#include <iostream>
#include
#include
#include
#include
namespace msm = boost::msm;
namespace mpl = boost::mpl;
using msm::front::none;
using msm::front::Row;
#define ENTRY_EXIT_INFO() \
template \
void on_entry(const Event&, FSM&) { \
std::cout << "entering: " << typeid(*this).name() << std::endl; \
} \
template \
void on_exit(const Event&, FSM&) { \
std::cout << "leaving: " << typeid(*this).name() << std::endl; \
}
struct init {};
struct interrupt {};
struct proceed {};
struct finish {};
struct fsm_ : public msm::front::state_machine_def
{
struct Empty : public msm::front::state<>
{
ENTRY_EXIT_INFO();
};
struct Proceed : public msm::front::state<>
{
ENTRY_EXIT_INFO();
};
struct Interrupted : public
msm::front::interrupt_state >
{
ENTRY_EXIT_INFO();
};
struct Finished : public msm::front::terminate_state<>
{
ENTRY_EXIT_INFO();
};
typedef mpl::vector<Empty> initial_state;
struct transition_table : mpl::vector<
// Start Event Next Action Guard
//
+-------------+-------------+------------+---------------------+----------------------+
Row < Empty , init , Proceed , none , none
>,
Row < Proceed , interrupt , Interrupted , none , none
>,
Row < Interrupted , proceed , Proceed , none , none
>,
Row < Interrupted , finish , Finished , none , none
>
> {};
enum States
{
STATE_Empty,
STATE_Proceed,
STATE_Interupted,
STATE_Finished
};
};
typedef msm::back::state_machine fsm_t;
int tmain()
{
fsm_t fsm;
fsm.start();
fsm.process_event(init());
assert(fsm.current_state()[0] == fsm_t::STATE_Proceed);
fsm.process_event(interrupt());
assert(fsm.current_state()[0] == fsm_t::STATE_Interupted);
fsm.process_event(proceed());
assert(fsm.current_state()[0] == fsm_t::STATE_Proceed);
fsm.process_event(interrupt());
assert(fsm.current_state()[0] == fsm_t::STATE_Interupted);
fsm.process_event(finish());
assert(fsm.current_state()[0] == fsm_t::STATE_Finished);
return 0;
}