Thanks a lot, it worked ! Le 12/07/2013 20:54, boost-users-request@lists.boost.org a écrit :
Send Boost-users mailing list submissions to boost-users@lists.boost.org
To subscribe or unsubscribe via the World Wide Web, visit http://lists.boost.org/mailman/listinfo.cgi/boost-users or, via email, send a message with subject or body 'help' to boost-users-request@lists.boost.org
You can reach the person managing the list at boost-users-owner@lists.boost.org
When replying, please edit your Subject line so it is more specific than "Re: Contents of Boost-users digest..."
Today's Topics:
1. [msm] access to root fsm (Alexander Mingalev) 2. Re: issues compiling Boost 1.54 thread on AIX5.2 (Vicente J. Botet Escriba) 3. [boost format] Not getting expected errors (Rob Conde) 4. Re: [graph] in-depth parsing and modifications of the graph (Jeremiah Willcock)
----------------------------------------------------------------------
Message: 1 Date: Fri, 12 Jul 2013 20:29:36 +0400 From: Alexander Mingalev
To: boost-users@lists.boost.org Subject: [Boost-users] [msm] access to root fsm Message-ID: <51E02EF0.4010202@gmail.com> Content-Type: text/plain; charset="iso-8859-1"; Format="flowed" I have main fsm with two sub-levels. The problem is, the sub-fsms need data which is held in root fsm, like:
struct SomeAction { template
void operator()(EVT&, FSM& fsm, SourceState&, TargetState&) const { // ... } }; Instance of fsm here might be root fsm as well as sub-fsm. I see two possible solutions:
1. use sm_ptr policy and store parent pointer in each sub-fsm In this case access might look like this:
fsm.parent_->data; (access from 1-level fsm) fsm.parent_->parent_->data; (access from 2-level fsm)
doesn't look so nice, besides, documentation states that using sm_ptr is deprecated.
2. recursively traverse all states, detect fsm's and store root pointer
typedef RootFSM::stt stt; typedef boost::msm::back::generate_state_set<stt>::type all_states;
boost::mpl::for_each
mpl::placeholders::_1 > (find_sub_fsm<stt>()); template <typename stt> struct find_sub_fsm { template <class StateType> void operator()(boost::msm::wrap<StateType>& state) const { // ??? // state.root_ = &g_root; // do the recurs } };
How to detect that StateType is sub-fsm?
3. Maybe, there is a easier way to communicate between sub-fsm's?