From: Alexander Nasonov (alnsn_at_[hidden])
Date: 2006-12-31 14:43:37
Sorry for the late reply. I was hoping to get some spare time last week
but the last hours of this year is the earliest time. I'll go drink
a bottle of champaine when I send this letter :-)))
Andrey Semashev wrote:
> In your example the Data structure holds variables specific to Paused
> and Running states
> (let's assume the Operational state is only used as
> a simple base class, not a final state).
This is correct, base classes are never states unless they are returned
from on_process function.
> But instead of being hidden
> inside of them it becomes the whole machine's member. Had I ten states
> with their specific data, the my_fsm class would get too crowded.
I agree that if a user does it way, this may get messy.
> Besides, nothing prevents you to access or modify this data from, say,
> "Running on_process(id<1>, Initial, integral_c<event,Start>) const;"
> handler which has nothing to do with neither Operational nor Running
> or Paused states.
I think it makes sense to support State&, reference_wrapper<State> and
shared_ptr<State>. For example,
// The framework should recognize a reference and act upon.
id<1>, Initial, integral_c<event,Start>) const
This approach has two advantages:
1. You control a construction of m_RunningInstance (Not sure that it's
always a best choice than automatic state management)
2. You have a better control during processing, e.g. you may return an
object from a pool of objects rather than using only one state object.
> From my point of view a state should be a part of the state machine
> since it may contain some specifiÑ data. It may not be a lightweight
> compound and it may want to keep its internal state through the whole
> machine's lifetime, which may be long enough and even cyclic.
I would rather say it depends. It may be lightweight but in general
yes, you're right.
My model is more static and lets you for example draw a machine without
running it. In my opinion, this feature is absolutely necessary and
state transition table shouln't be optional (it's so easy to forgot one
transition among hunderds when it's optional).
Happy New Year!
Ð¡ ÐÐ¾Ð²ÑÐ¼ Ð³Ð¾Ð´Ð¾Ð¼!
-- Alexander Nasonov http://nasonov.blogspot.com We need to find God, and he cannot be found in noise and restlessness. God is the friend of silence. See how nature -- trees, flowers, grass -- grows in silence; see the stars, the moon and the sun, how they move in silence. We need silence to be able to touch souls. -- Mother Teresa -- This quote is generated by: /usr/pkg/bin/curl -L http://tinyurl.com/veusy \ | sed -e 's/^document\.write(.//' -e 's/.);$/ --/' \ -e 's/<[^>]*>//g' -e 's/^More quotes from //' \ | fmt | tee ~/.signature-quote
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk