
Hi,
I am having a statemachine with a submachine. In the internal submachine I need to check if there is a flag active in the outer statemachine. Currently I solve this with a const pointer to the outermost FSM passed to the submachine's constructor: backEnd.set_states(msm::back::states_ << StOk(msm::back::states_ << StSlave(&backEnd))); StSlave is the internal submachine in which I need to check whether a flag in StOk is active or not.
Then I check the flag activity status e.g in a guard of StSlave like this: struct GrdBladeUp { template
bool operator()(EVT const& event, FSM& fsm, SourceState&, TargetState&) { if(fsm.getOutermostFSM()->template is_flag_active<FlagBladeUp>()) { return true; } return false; } }; Is there an easier way to get somehow the parent fsm or the outermost fsm of a submachine?
Thanks, Gabor
Hi Gabor, this feature has been requested a few times and I have it on my list, but I didn't implement it (yet). Your solution is ok, though it creates a cyclic dependency, which is not so nice. Alternatively you could pass the submachine a boost::function, which breaks the cycle but gets not fun if you start having too many. This is clearly something which msm will have at some point. Regards, Christophe