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
functionality.
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>
>reactions;
};

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>
>reactions;
};

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>
>reactions;
};

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,
CanceledConfirmed>,
        bsc::transition< Revert, *"PREVIOUS_STATE"*>
>reactions;
};

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: http://boost.2283326.n4.nabble.com/Boost-statechart-how-can-i-transit-to-previous-state-using-deep-history-or-shallow-history-tp4685239.html
Sent from the Boost - Users mailing list archive at Nabble.com.

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net