Boost logo

Boost :

Subject: Re: [boost] [msm] Passing constructor arguments to submachine
From: Christophe Henry (christophe.j.henry_at_[hidden])
Date: 2010-06-01 14:08:20


Hi Michael,

> As already explained in another thread, it is possible to pass constructor
> arguments to msm state machines (to the front end).
>
> Is it also possible to pass constructor arguments to submachines of a msm
> state machine?

Unfortunately, not yet. There was a proposal made during the review to
allow states (including submachines) to be cloned from an existing
one, but it is not implemented yet.

> Or is there an other way in order to configure the inner submachine by
> calling some member methods from the outer state machine or therelike?

You can call get_state<my_submachine&>() on the outer fsm (at best in
the entry behavior). For example:

struct Playing_ : public msm::front::state_machine_def<Playing_>
{
       template <class Event,class Fsm>
        void on_entry(Event const&,Fsm& fsm)
      {
          fsm.get_state<my_submachine&>() .foo();
      }
...
};

HTH,
Christophe


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