|
Boost Users : |
Subject: Re: [Boost-users] MSM <-> UML Conversion
From: Klaim - Joël Lamotte (mjklaim_at_[hidden])
Date: 2011-10-19 11:03:05
Hi,
On Wed, Oct 19, 2011 at 13:50, asif saeed <asif.lse2_at_[hidden]> wrote:
> That does make think if Boost MSM (or StateChart?) offers a faster
> solution.
>
>
I'm not a specialist nor very experimented with the library but the
following information might help:
When you instantiate an MSM state machine, all the states are created at the
same time, like member objects. I don't know if its the case or if they are
dynamically allocated but they are all built from the start. On transition,
on_exit and on_entry members of states will be called. It means you can even
keep values in states for longer than their activation. Theorically, you can
even make your whole state machine copyiable (I might be wrong though).
There is just a compiler bug with MSVC that makes it impossible to put in a
std::vector, as I tried to do in an experiment, but other than that it's
what you would expect from simple types. The transitions from all the state
machine is defined in one unique point, the transition table, making easy to
see what can happen in one read.
Statechart will work very differently and certainly really less efficiently
for you. Statechart will instantiate a state machine with one initial state
but not more at first. On each transition, the states from which you come
from will be destroyed and the states where you go will be instantiated "on
the fly", making constructor and destructor the only points where you know
that you enter and exit states. Also, parent states of sub states are kept
alive if a transitions happen between substates, but will be destroyed once
you go to a state outside the parent state -- it feels natural, knowing the
instantiation logic.
Each statechart state type will provide a set of possible transitions,
making easy to know where you can go from one state, but harder to see the
"big picture".
If I'm wrong somewhere in these descriptions, please allow me to know.
Hope it helps.
Joël Lamotte
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