Boost logo

Boost Users :

Subject: Re: [Boost-users] Pass data to states, in boost state chart
From: jusva2010 (justinjose12002_at_[hidden])
Date: 2011-05-02 22:55:26


Thanks alot for your reply..

Do you have any sample code for doing that?

Currently i am trying like this...I am not sure it is the correct way to do
that.

1. Declared a local varable in State machine

struct StateMachine:sc::state_machine<StateMachine, Initial>
{

  int getData();
  void setData(int data);
  private int data;
}

2. Set the value

  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

Thanks in advance
justin

--
View this message in context: http://boost.2283326.n4.nabble.com/Pass-data-to-states-in-boost-state-chart-tp3482860p3491585.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