Sophie

Sophie

distrib > Fedora > 14 > i386 > by-pkgid > 623999701586b0ea103ff2ccad7954a6 > files > 7852

boost-doc-1.44.0-1.fc14.noarch.rpm

<html><head>
      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
   <title>Frontend / Backend interface</title><link rel="stylesheet" href="boostbook.css" type="text/css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.75.2"><link rel="home" href="index.html" title="Meta State Machine (MSM) V2.10"><link rel="up" href="ch06.html" title="Chapter&nbsp;6.&nbsp;Internals"><link rel="prev" href="ch06.html" title="Chapter&nbsp;6.&nbsp;Internals"><link rel="next" href="ch06s03.html" title="Generated state ids"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Frontend / Backend
                    interface</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch06.html">Prev</a>&nbsp;</td><th width="60%" align="center">Chapter&nbsp;6.&nbsp;Internals</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="ch06s03.html">Next</a></td></tr></table><hr></div><div class="sect1" title="Frontend / Backend interface"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e4002"></a><span class="command"><strong><a name="internals-front-back-interface"></a></strong></span>Frontend / Backend
                    interface</h2></div></div></div><p>The design of MSM tries to make front-ends and back-ends (later) to be as
                    interchangeable as possible. Of course, no back-end will ever implement every
                    feature defined by any possible front-end and inversely, but the goal is to make
                    it as easy as possible to extend the current state of the library.</p><p>To achieve this, MSM divides the functionality between both sides: the
                    front-end is a sort of user interface and is descriptive, the back-end
                    implements the state machine engine.</p><p>MSM being based on a transition table, a concrete state machine (or a given
                    front-end) must provide a transition_table. This transition table must be made
                    of rows. And each row must tell what kind of transition it is and implement the
                    calls to the actions and guards. A state machine must also define its regions
                    (marked by initial states) And that is about the only constraints for
                    front-ends. How the rows are described is implementer's choice. </p><p>Every row must provide:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>A <code class="code">Source</code> typedef indicating, well, the type of the source
                            state.</p></li><li class="listitem"><p>A <code class="code">Target</code> typedef indicating, well, the type of the target
                            state.</p></li><li class="listitem"><p>A <code class="code">Evt</code> typedef indicating the type of the event triggering
                            the transition.</p></li><li class="listitem"><p>A <code class="code">row_type_tag</code> typedef indicating the type of the
                            transition.</p></li><li class="listitem"><p>Rows having a type requiring transition actions must provide a static
                            function <code class="code">action_call</code> with the following signature: <code class="code">
                                template &lt;class Fsm,class SourceState,class TargetState,class
                                AllStates&gt; </code></p><p><code class="code">static void action_call (Fsm&amp; fsm, Event const&amp; evt,
                                SourceState&amp;, TargetState&amp;, AllStates&amp;) </code></p><p>The function gets as parameters the (back-end) state machine, the
                            event, source and target states and a container (in the current
                            back-end, a fusion::set) of all the states defined in the state machine.
                            For example, as the back-end has the front-end as basic class,
                                <code class="code">action_call</code> is simply defined as
                                <code class="code">(fsm.*action)(evt)</code>.</p></li><li class="listitem"><p>Rows having a type requiring a guard must provide a static function
                                <code class="code">guard_call</code> with the following signature:<code class="code"> </code></p><p><code class="code">template &lt;class Fsm,class SourceState,class TargetState,class
                                AllStates&gt;</code></p><p><code class="code">static bool guard_call (Fsm&amp;, Event const&amp;,
                                SourceState&amp;, TargetState&amp;, AllStates&amp;)</code></p></li><li class="listitem"><p>The possible transition (row) types are:</p><div class="itemizedlist"><ul class="itemizedlist" type="circle"><li class="listitem"><p>a_row_tag: a transition with actions and no guard</p></li><li class="listitem"><p>g_row_type: a transition with a guard and no
                                        actions</p></li><li class="listitem"><p>_row_tag: a transition without actions or guard</p></li><li class="listitem"><p>row_tag: a transition with guard and actions</p></li><li class="listitem"><p>a_irow_tag: an internal transition (defined inside the
                                            <code class="code">transition_table</code>) with actions</p></li><li class="listitem"><p>g_irow_tag: an internal transition (defined inside the
                                            <code class="code">transition_table</code>) with guard</p></li><li class="listitem"><p>irow_tag: an internal transition (defined inside the
                                            <code class="code">transition_table</code>) with actions and
                                        guards</p></li><li class="listitem"><p>_irow_tag: an internal transition (defined inside the
                                            <code class="code">transition_table</code>) without action or guard.
                                        Due to higher priority for internal transitions, this is
                                        equivalent to a "ignore event"</p></li><li class="listitem"><p>sm_a_i_row_tag: an internal transition (defined inside the
                                            <code class="code">internal_transition_table</code>) with
                                        actions</p></li><li class="listitem"><p>sm_g_i_row_tag: an internal transition (defined inside the
                                            <code class="code">internal_transition_table</code>) with
                                        guard</p></li><li class="listitem"><p>sm_i_row_tag: an internal transition (defined inside the
                                            <code class="code">internal_transition_table</code>) with actions and
                                        guards</p></li><li class="listitem"><p>sm__i_row_tag: an internal transition (defined inside the
                                            <code class="code">internal_transition_table</code>) without action
                                        or guard. Due to higher priority for internal transitions,
                                        this is quivalent to a "ignore event"</p></li></ul></div></li></ul></div><p>Furthermore, a front-end must provide the definition of states and state
                    machines. State machine definitions must provide (the implementer is free to
                    provide it or let it be done by every concrete state machine. Different MSM
                    front-ends took one or the other approach):</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p><code class="code">initial_state</code>: This typedef can be a single state or
                                a mpl container and provides the initial states defining one or
                                several orthogonal regions.</p></li><li class="listitem"><p><code class="code">transition_table</code>: This typedef is a MPL sequence of
                                transition rows.</p></li><li class="listitem"><p><code class="code">configuration</code>: this typedef is a MPL sequence of
                                known types triggering special behavior in the back-end, for example
                                if a concrete fsm requires a message queue or exception
                                catching.</p></li></ul></div><p>States and state machines must both provide a (possibly empty) definition of:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p><code class="code">flag_list</code>: the flags being active when this state or
                                state machine become the current state of the fsm.</p></li><li class="listitem"><p><code class="code">deferred_events</code>: events being automatically deferred
                                when the state is the current state of the fsm.</p></li><li class="listitem"><p><code class="code">internal_transition_table</code>: the internal transitions
                                of this state.</p></li><li class="listitem"><p><code class="code">on_entry</code> and <code class="code">on_exit</code> methods.</p></li></ul></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch06.html">Prev</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="ch06.html">Up</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="ch06s03.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter&nbsp;6.&nbsp;Internals&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp; Generated state ids </td></tr></table></div></body></html>