Boost logo

Boost :

Subject: Re: [boost] [msm]exit pseudo state and event
From: Christophe Henry (christophe.j.henry_at_[hidden])
Date: 2011-07-06 17:09:37


>> I think I'll need your example to understand this question.
>> Generally, my opinion is that I want the weakest dependency I can get
>> away
>> with. And a dependency to a template method of an event seems to me a
>> weaker
>> one than a dependency to a submachine class. Both ways because the
>> submachine would also have to make some assumptions about the main
>> machine's
>> behaviour.
>
> In the case of event parameter, I completely agree with you.
> But I'm not sure how to propagate the sub-machine's action result
> to main-machine without adding the interface to sub-machine.
>
> I have two ideas.
> 1. Using the internal transition. (See 13_PropagateActionResult.cpp
> Event2)
> Can I call the member function "process_event" inside the action
> functor??
> (See Line 69)

Yes. I didn't try your example out but it looks good.

> More generally, does the msm provide interfaces that send events to
> their own state machine?

Sure. That's one of the main reasons to pass the fsm as parameter to the
action.

> 2. Add the mutable variable to event classes, and modify the variable in
> action functor.
> I think it is ugly.

I agree :)

> If there are no good ideas to do that, your approach solves only
> event parameter. I think it's too partial.
>
> I hope 1 is OK.
> Or do you have any better ideas?

What you are doing should work without problems.
As a side note, I like the Guard1 / Not_<Guard1> construct. It's the best
way to ensure that guards are mutually exclusive.

Regards,
Christophe


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk