Pass data to states, in boost state chart
Hi All, Is there any way I can pass data to state event handler? Any pointers really appreciated. Thanks in advance Justin -- View this message in context: http://boost.2283326.n4.nabble.com/Pass-data-to-states-in-boost-state-chart-... Sent from the Boost - Users mailing list archive at Nabble.com.
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-... Sent from the Boost - Users mailing list archive at Nabble.com.
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
Thanks alot..! -- View this message in context: http://boost.2283326.n4.nabble.com/Pass-data-to-states-in-boost-state-chart-... Sent from the Boost - Users mailing list archive at Nabble.com.
participants (2)
-
Igor R
-
jusva2010