|
Boost Users : |
Subject: Re: [Boost-users] Pass data to states, in boost state chart
From: Igor R (boost.lists_at_[hidden])
Date: 2011-05-03 04:01:48
> Â SateMachine machine;
> Â machine.setData(100);
> Â machine.initiate();
> Â machine.setData(200);
> Â machine.process_evet(event());
>
> 3. access that value from state event handler
>
> Â sc::result Initial::react(const event())
> Â {
> Â Â cout << "Data:" << context< StateMachine>().getData() << endl;
> Â }
>
> Please advise if there is any other better solution
If all you need is to pass the data to the reaction, you can
encapsulate it in the event:
struct your_event : sc::event<your_event>
{
data_type data_;
};
//....
your_event e;
e.data_ = data;
machine.process_event(e);
//...
sc::result react(const your_event &e)
{
cout << e.data_;
}
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