Boost logo

Boost Users :

Subject: [Boost-users] Boost statechart, how can i transit to previous state using deep_history or shallow history
From: juls (jvlahou_at_[hidden])
Date: 2016-04-12 06:06:57

I have a difficulty in understanding the boost statechart history
I have the following state machine.

struct InButtonPressed : sc::event<InButtonPressed> {};
struct OutButtonPressed : sc::event<OutButtonPressed> {};
struct InButtonPressed : sc::event<InButtonPressed> {};
struct InputProceed: sc::event<InputProceed> {};
struct OutputProceed: sc::event<OutputProceed> {};
struct CancelEvent: sc::event<CancelEvent> {};
struct Proceed: sc::event<Proceed> {};
struct Revert: sc::event<InputProceed> {};

struct RH_StateMachine : bsc::state_machine< RH_StateMachine, Idle > {};

struct Idle : bsc::state< Idle, RH_StateMachine> {
    Idle(my_context ctx) : my_base(ctx){
        std::cout << "[+] Idle" << std::endl;
    ~Idle(){std::cout << "[-] leaving Idle state... \n";}
    typedef boost::mpl::list< bsc::transition< InButtonPressed, Input>,
        bsc::transition< OutButtonPressed, Output>

struct Input : bsc::state< Input, RH_StateMachine> {
    Input(my_context ctx) : my_base(ctx){
        std::cout << "[+] Input" << std::endl;
    ~Input(){std::cout << "[-] leaving Input state... \n";}
      typedef boost::bsc::transition< CancelEvent, Cancel>

struct Output : bsc::state< Output, RH_StateMachine> {
    Output(my_context ctx) : my_base(ctx){
        std::cout << "[+] Output" << std::endl;
    ~Output(){std::cout << "[-] leaving Output state... \n";}
      typedef boost::bsc::transition< CancelEvent, Cancel>

struct Cancel::bsc::state<Cancel, RH_StateMAchine>{
      Cancel(my_context ctx) : my_base(ctx){
        std::cout << "[+] Cancel" << std::endl;
    ~Cancel(){std::cout << "[-] leaving Cancel state... \n";}
      typedef boost::mpl::list< bsc::transition< Proceed,
        bsc::transition< Revert, *"PREVIOUS_STATE"*>

How do i implement transitioning to previous state using deep_history or
shallow history, when i can transit to a state from many different states?
In the above state machine i want to transit from Cancel state to the
previous state when the revert event is triggered, but i have already
transited in Cancel state from either Input or Output state...
Thank you in advance.

View this message in context:
Sent from the Boost - Users mailing list archive at

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at