Boost logo

Boost Users :

Subject: [Boost-users] [statechart] Passing parameters to state objects
From: Robert Dailey (rcdailey_at_[hidden])
Date: 2009-09-28 14:20:57


Hello,
I was thinking of using Boost.Statechart as a state machine to manage widget
states in my wxWidgets application. Depending on what menu options the user
picks in my program, certain buttons on the main window will be enabled or
disabled. I figured this would be a good opportunity to use Boost's state
machine system. I would create states that would enable or disable certain
buttons depending on what events I publish. For example, when the user
chooses the "Edit Name" menu item, then buttons for editing a name would be
enabled. This means I'd publish a EditNameEnabled event, or something, and
then the EditNameMode state would become active, and its constructor would
enable certain buttons.

Of course, this means I'll need to be able to pass construction parameters
to certain fsm state objects, and in the Statechart tutorial they only use
default constructors. I'm not sure how I'd pass button object pointers to
these state classes so they can work with them. I have two questions:

First, does Boost.Statechart seem like the right tool for this job? If yes,
then how can I pass parameters to state object constructors? Would I pass
the parameters to the Event's constructor, and then somehow access that
event instance from the state's constructor?

Thanks in advance.

---------
Robert Dailey



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