definitions.html 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Language" content="en-us">
  5. <meta name="GENERATOR" content="Microsoft FrontPage 6.0">
  6. <meta name="ProgId" content="FrontPage.Editor.Document">
  7. <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
  8. <link rel="stylesheet" type="text/css" href="../../../boost.css">
  9. <title>The Boost Statechart Library - Definitions</title>
  10. </head>
  11. <body link="#0000FF" vlink="#800080">
  12. <table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
  13. "header">
  14. <tr>
  15. <td valign="top" width="300">
  16. <h3><a href="../../../index.htm"><img alt="C++ Boost" src=
  17. "../../../boost.png" border="0" width="277" height="86"></a></h3>
  18. </td>
  19. <td valign="top">
  20. <h1 align="center">The Boost Statechart Library</h1>
  21. <h2 align="center">Definitions</h2>
  22. </td>
  23. </tr>
  24. </table>
  25. <hr>
  26. <h2>Introduction</h2>
  27. <p>The Boost.Statechart documentation uses a lot of terminology specific to
  28. state machines. Most of it is equal to the one used in the UML
  29. specifications. This document contains only definitions for terminology not
  30. used by the <a href="http://www.omg.org/cgi-bin/doc?formal/03-03-01">UML
  31. standard</a>. A short tour around UML terminology can be found <a href=
  32. "http://www.sts.tu-harburg.de/teaching/ws-99.00/OOA+D/StateDiagrams.pdf">here</a>.</p>
  33. <h2>Definitions</h2>
  34. <dl class="page-index">
  35. <dt><a href="#Context">Context</a></dt>
  36. <dt><a href="#InnermostCommonContext">Innermost common context</a></dt>
  37. <dt><a href="#InnermostState">Innermost state</a></dt>
  38. <dt><a href="#InStateReaction">In-state reaction</a></dt>
  39. <dt><a href="#OutermostState">Outermost state</a></dt>
  40. <dt><a href="#PolymorphicEvents">Polymorphic events</a></dt>
  41. <dt><a href="#Reaction">Reaction</a></dt>
  42. <dt><a href="#UnstableState">Unstable state</a></dt>
  43. <dt><a href="#UnstableStateMachine">Unstable state machine</a></dt>
  44. </dl>
  45. <h3><a name="Context" id="Context">Context</a></h3>
  46. <p>The contexts of a state define its location in the state hierarchy. A
  47. state's <b>direct</b> context is defined by what is passed as the
  48. <code>Context</code> template parameter of the <code><a href=
  49. "reference.html#ClassTemplatesimple_state">simple_state</a></code> and
  50. <code><a href="reference.html#ClassTemplatestate">state</a></code> class
  51. templates. This can either be the state machine (which makes the state an
  52. <a href="#OutermostState">outermost state</a>) or its direct outer state. A
  53. state's <b>indirect</b> contexts follow from the direct context of its
  54. direct context and the direct context of the direct context of its direct
  55. context and so on. Examples:</p>
  56. <p><img alt="OutermostUnstableState" src="OutermostUnstableState.gif"
  57. border="0" width="467" height="572"></p>
  58. <ul>
  59. <li>A's <b>direct</b> context is the state machine (not visible in this
  60. picture). A does not have any indirect contexts</li>
  61. <li>B's <b>direct</b> context is A. B's <b>indirect</b> context is the
  62. state machine (not visible in this picture)</li>
  63. <li>C's <b>direct</b> context is B. C's <b>indirect</b> contexts are B, A
  64. and the state machine (not visible in this picture)</li>
  65. <li>D's <b>direct</b> context is A. D's <b>indirect</b> context is the
  66. state machine (not visible in this picture)</li>
  67. </ul>
  68. <h3><a name="InnermostCommonContext" id="InnermostCommonContext">Innermost
  69. common context</a></h3>
  70. <p>The innermost common context of two states is the first direct or
  71. indirect context that both states have in common. Also known as Least
  72. Common Ancestor (UML).</p>
  73. <h3><a name="InnermostState" id="InnermostState">Innermost state</a></h3>
  74. <p>An innermost state is a state that does not itself have inner states.
  75. Also known as leaf state or simple state (UML). Note that <code><a href=
  76. "reference.html#ClassTemplatesimple_state">boost::statechart::simple_state&lt;&gt;</a></code>
  77. is <b>not</b> a model of the UML simple state.</p>
  78. <h3><a name="InStateReaction" id="InStateReaction">In-state
  79. reaction</a></h3>
  80. <p>An in-state reaction is a <a href="#Reaction">reaction</a> that neither
  81. exits nor enters any states. Also known as inner transition or internal
  82. transition (UML).</p>
  83. <h3><a name="OutermostState" id="OutermostState">Outermost state</a></h3>
  84. <p>An outermost state is a state that does not itself have outer states.
  85. Note that an outermost state is different from the UML top state. A state
  86. machine can have an arbitrary number of the former but only exactly one of
  87. the latter. Boost.Statechart only supports outermost states.</p>
  88. <h3><a name="PolymorphicEvents" id="PolymorphicEvents">Polymorphic
  89. events</a></h3>
  90. <p>An FSM library supports polymorphic events if events can inherit from
  91. each other without restrictions <b>and</b> if it allows the definition of
  92. reactions for leafs and nodes of the resulting event inheritance
  93. tree.</p>
  94. <p>Example (using a hypothetical FSM library, as Boost.Statechart does not
  95. support polymorphic events):</p>
  96. <pre>
  97. struct EvButtonPressed : Event // node
  98. {
  99. /* common button pressed properties */
  100. };
  101. struct EvPlayButtonPressed : EvButtonPressed {}; // leaf
  102. struct EvStopButtonPressed : EvButtonPressed {}; // leaf
  103. struct EvForwardButtonPressed : EvButtonPressed {}; // leaf
  104. </pre>
  105. <p>If a state machine needs to react whenever <b>any</b> button (including
  106. the ones that may be added in the future) is pressed, a reaction for
  107. <code>EvButtonPressed</code> can be defined.</p>
  108. <h3><a name="Reaction" id="Reaction">Reaction</a></h3>
  109. <p>A reaction consists of all the side effects caused by the processing of
  110. one event. Reactions can be categorized as follows:</p>
  111. <ol>
  112. <li>In-state reaction</li>
  113. <li>Event deferral</li>
  114. <li>Transition</li>
  115. <li>Termination, also known as transition to the final state (UML)</li>
  116. </ol>
  117. <p>Note that it is possible to mix a reaction of type 1 with one of the
  118. other types (the in-state reaction is always executed first) but it is not
  119. possible to mix a reaction of type 2-4 with anything else but type 1.</p>
  120. <p>A reaction is always associated with exactly one state type and exactly
  121. one event type.</p>
  122. <h3><a name="UnstableState" id="UnstableState">Unstable state</a></h3>
  123. <p>A state is unstable from the moment when it has been entered until after
  124. its last <b>direct</b> inner state has been entered. A state is also
  125. unstable from the moment just before its first <b>direct</b> inner state is
  126. exited until right before the state itself is exited.</p>
  127. <h3><a name="UnstableStateMachine" id="UnstableStateMachine">Unstable state
  128. machine</a></h3>
  129. <p>A state machine is unstable if at least one of its currently active
  130. states is unstable. This is the case during the following three
  131. operations:</p>
  132. <ul>
  133. <li>Initiation: From the moment after the first state has been entered
  134. until after the last state of the initial state configuration has been
  135. entered</li>
  136. <li>Transition: From the moment just before the first state of the
  137. current state configuration is exited until after the last state of the
  138. destination state configuration has been entered</li>
  139. <li>Termination: From the moment just before the first state is exited
  140. until right before the last terminated state is exited. A successfully
  141. executed termination (no exception was thrown) never leaves any states
  142. unstable. For example, consider the active state A with two orthogonal
  143. regions in which the inner states B and C are each active. Terminating
  144. either B or C does not make A unstable. Neither does terminating both, as
  145. that inevitably also terminates A</li>
  146. </ul>
  147. <p>Under normal circumstances a state machine has Run-To-Completion
  148. semantics, that is, it is always stable before the machine returns to the
  149. client or before the next event is dequeued. So, a state machine is usually
  150. only unstable when it is busy processing an event and becomes stable again
  151. right before it has finished processing the event. However, this can not be
  152. guaranteed when entry, exit or transition actions fail. Such a failure is
  153. reported by an event, which must be processed while the state machine is
  154. unstable. However, exception event processing rules ensure that a state
  155. machine is never unstable when it returns to the client (see <code><a href=
  156. "reference.html#process_event">state_machine&lt;&gt;::process_event()</a></code>
  157. for details).</p>
  158. <hr>
  159. <p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src=
  160. "../../../doc/images/valid-html401.png" alt="Valid HTML 4.01 Transitional"
  161. height="31" width="88"></a></p>
  162. <p>Revised
  163. <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->29 December, 2006<!--webbot bot="Timestamp" endspan i-checksum="38526" --></p>
  164. <p><i>Copyright &copy; 2003-<!--webbot bot="Timestamp" s-type="EDITED" s-format="%Y" startspan -->2006<!--webbot bot="Timestamp" endspan i-checksum="770" -->
  165. <a href="contact.html">Andreas Huber D&ouml;nni</a></i></p>
  166. <p><i>Distributed under the Boost Software License, Version 1.0. (See
  167. accompanying file <a href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or
  168. copy at <a href=
  169. "http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>)</i></p>
  170. </body>
  171. </html>