Boost logo

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