reference.html 126 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594
  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 http-equiv="Content-Type" content="text/html; charset=us-ascii">
  6. <meta name="GENERATOR" content="Microsoft FrontPage 12.0">
  7. <meta name="ProgId" content="FrontPage.Editor.Document">
  8. <link rel="stylesheet" type="text/css" href="../../../boost.css">
  9. <title>The Boost Statechart Library - Reference</title>
  10. <style type="text/css">
  11. .style1
  12. {
  13. width: 45%;
  14. }
  15. </style>
  16. </head>
  17. <body link="#0000FF" vlink="#800080">
  18. <table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
  19. "header">
  20. <tr>
  21. <td valign="top" width="300">
  22. <h3><a href="../../../index.htm"><img alt="C++ Boost" src=
  23. "../../../boost.png" border="0" width="277" height="86"></a></h3>
  24. </td>
  25. <td valign="top">
  26. <h1 align="center">The Boost Statechart Library</h1>
  27. <h2 align="center">Reference</h2>
  28. </td>
  29. </tr>
  30. </table>
  31. <hr>
  32. <h2>Contents</h2>
  33. <dl class="page-index">
  34. <dt><a href="#Concepts">Concepts</a></dt>
  35. <dd><a href="#Scheduler">Scheduler</a></dd>
  36. <dd><a href="#FifoWorker">FifoWorker</a></dd>
  37. <dd><a href="#ExceptionTranslator">ExceptionTranslator</a></dd>
  38. <dd><a href="#StateBase">StateBase</a></dd>
  39. <dd><a href="#SimpleState">SimpleState</a></dd>
  40. <dd><a href="#State">State</a></dd>
  41. <dd><a href="#Event">Event</a></dd>
  42. <dt><a href="#state_machine.hpp">state_machine.hpp</a></dt>
  43. <dd><a href="#ClassTemplatestate_machine">Class template
  44. <code>state_machine</code></a></dd>
  45. <dt><a href=
  46. "#asynchronous_state_machine.hpp">asynchronous_state_machine.hpp</a></dt>
  47. <dd><a href="#ClassTemplateasynchronous_state_machine">Class template
  48. <code>asynchronous_state_machine</code></a></dd>
  49. <dt><a href="#event_processor.hpp">event_processor.hpp</a></dt>
  50. <dd><a href="#ClassTemplateevent_processor">Class template
  51. <code>event_processor</code></a></dd>
  52. <dt><a href="#fifo_scheduler.hpp">fifo_scheduler.hpp</a></dt>
  53. <dd><a href="#ClassTemplatefifo_scheduler">Class template
  54. <code>fifo_scheduler</code></a></dd>
  55. <dt><a href="#exception_translator.hpp">exception_translator.hpp</a></dt>
  56. <dd><a href="#ClassTemplateexception_translator">Class template
  57. <code>exception_translator</code></a></dd>
  58. <dt><a href=
  59. "#null_exception_translator.hpp">null_exception_translator.hpp</a></dt>
  60. <dd><a href="#Classnull_exception_translator">Class
  61. <code>null_exception_translator</code></a></dd>
  62. <dt>&nbsp;</dt>
  63. <dt><a href="#simple_state.hpp">simple_state.hpp</a></dt>
  64. <dd><a href="#Enumhistory_mode">Enum <code>history_mode</code></a></dd>
  65. <dd><a href="#ClassTemplatesimple_state">Class template
  66. <code>simple_state</code></a></dd>
  67. <dt><a href="#state.hpp">state.hpp</a></dt>
  68. <dd><a href="#ClassTemplatestate">Class template
  69. <code>state</code></a></dd>
  70. <dt><a href="#shallow_history.hpp">shallow_history.hpp</a></dt>
  71. <dd><a href="#ClassTemplateshallow_history">Class template
  72. <code>shallow_history</code></a></dd>
  73. <dt><a href="#deep_history.hpp">deep_history.hpp</a></dt>
  74. <dd><a href="#ClassTemplatedeep_history">Class template
  75. <code>deep_history</code></a></dd>
  76. <dt>&nbsp;</dt>
  77. <dt><a href="#event_base.hpp">event_base.hpp</a></dt>
  78. <dd><a href="#Classevent_base">Class <code>event_base</code></a></dd>
  79. <dt><a href="#event.hpp">event.hpp</a></dt>
  80. <dd><a href="#ClassTemplateevent">Class template
  81. <code>event</code></a></dd>
  82. <dt>&nbsp;</dt>
  83. <dt><a href="#transition.hpp">transition.hpp</a></dt>
  84. <dd><a href="#ClassTemplatetransition">Class template
  85. <code>transition</code></a></dd>
  86. <dt><a href="#in_state_reaction.hpp">in_state_reaction.hpp</a></dt>
  87. <dd><a href="#ClassTemplatein_state_reaction">Class template
  88. in_state_reaction</a></dd>
  89. <dt><a href="#termination.hpp">termination.hpp</a></dt>
  90. <dd><a href="#ClassTemplatetermination">Class template
  91. <code>termination</code></a></dd>
  92. <dt><a href="#deferral.hpp">deferral.hpp</a></dt>
  93. <dd><a href="#ClassTemplatedeferral">Class template
  94. <code>deferral</code></a></dd>
  95. <dt><a href="#custom_reaction.hpp">custom_reaction.hpp</a></dt>
  96. <dd><a href="#ClassTemplatecustom_reaction">Class template
  97. <code>custom_reaction</code></a></dd>
  98. <dt><a href="#result.hpp">result.hpp</a></dt>
  99. <dd><a href="#Classresult">Class <code>result</code></a></dd>
  100. </dl>
  101. <hr>
  102. <h1><a name="Concepts" id="Concepts">Concepts</a></h1>
  103. <h2><a name="Scheduler" id="Scheduler">Scheduler</a> concept</h2>
  104. <p>A Scheduler type defines the following:</p>
  105. <ul>
  106. <li>What is passed to the constructors of <code><a href=
  107. "#ClassTemplateevent_processor">event_processor&lt;&gt;</a></code>
  108. subtypes and how the lifetime of such objects is managed</li>
  109. <li>Whether or not multiple <code>event_processor&lt;&gt;</code> subtype
  110. objects can share the same queue and scheduler thread</li>
  111. <li>How events are added to the schedulers' queue</li>
  112. <li>Whether and how to wait for new events when the schedulers' queue
  113. runs empty</li>
  114. <li>Whether and what type of locking is used to ensure thread-safety</li>
  115. <li>Whether it is possible to queue events for no longer existing
  116. <code>event_processor&lt;&gt;</code> subtype objects and what happens
  117. when such an event is processed</li>
  118. <li>What happens when one of the serviced
  119. <code>event_processor&lt;&gt;</code> subtype objects propagates an
  120. exception</li>
  121. </ul>
  122. <p>For a Scheduler type <code>S</code> and an object <code>cpc</code> of
  123. type <code>const S::processor_context</code> the following expressions must
  124. be well-formed and have the indicated results:</p>
  125. <table border="3" cellpadding="2" width="100%" summary="Scheduler concept">
  126. <tr>
  127. <td><b>Expression</b></td>
  128. <td><b>Type</b></td>
  129. <td><b>Result</b></td>
  130. </tr>
  131. <tr>
  132. <td><code>cpc.my_scheduler()</code></td>
  133. <td><code>S &amp;</code></td>
  134. <td>A reference to the scheduler</td>
  135. </tr>
  136. <tr>
  137. <td><code>cpc.my_handle()</code></td>
  138. <td><code>S::processor_handle</code></td>
  139. <td>The handle identifying the
  140. <code>event_processor&lt;&gt;</code> subtype object</td>
  141. </tr>
  142. </table>
  143. <p>To protect against abuse, all members of
  144. <code>S::processor_context</code> should be declared private. As a result,
  145. <code>event_processor&lt;&gt;</code> must be a friend of
  146. <code>S::processor_context</code>.</p>
  147. <h2><a name="FifoWorker" id="FifoWorker">FifoWorker</a> concept</h2>
  148. <p>A FifoWorker type defines the following:</p>
  149. <ul>
  150. <li>Whether and how to wait for new work items when the internal work
  151. queue runs empty</li>
  152. <li>Whether and what type of locking is used to ensure thread-safety</li>
  153. </ul>
  154. <p>For a FifoWorker type <code>F</code>, an object <code>f</code> of that
  155. type, a <code>const</code> object <code>cf</code> of that type, a
  156. parameterless function object <code>w</code> of arbitrary type and an
  157. <code>unsigned long</code> value <code>n</code> the following
  158. expressions/statements must be well-formed and have the indicated
  159. results:</p>
  160. <table border="3" cellpadding="2" width="100%" summary=
  161. "FifoWorker concept">
  162. <tr>
  163. <td><b>Expression/Statement</b></td>
  164. <td><b>Type</b></td>
  165. <td><b>Effects/Result</b></td>
  166. </tr>
  167. <tr>
  168. <td><code>F::work_item</code></td>
  169. <td><code>boost::function0&lt; void &gt;</code></td>
  170. <td>&nbsp;</td>
  171. </tr>
  172. <tr>
  173. <td><code>F()</code> or <code>F( false )</code></td>
  174. <td><code>F</code></td>
  175. <td>Constructs a <b>non-blocking</b> (see below) object of
  176. the FifoWorker type. In single-threaded builds the second expression is
  177. not well-formed</td>
  178. </tr>
  179. <tr>
  180. <td><code>F( true )</code></td>
  181. <td><code>F</code></td>
  182. <td>Constructs a <b>blocking</b> (see below) object of the
  183. FifoWorker type. Not well-formed in single-threaded builds</td>
  184. </tr>
  185. <tr>
  186. <td><code>f.queue_work_item( w );</code></td>
  187. <td>&nbsp;</td>
  188. <td>Constructs and queues an object of type
  189. <code>F::work_item</code>, passing <code>w</code> as the only
  190. argument</td>
  191. </tr>
  192. <tr>
  193. <td><code>f.terminate();</code></td>
  194. <td>&nbsp;</td>
  195. <td>Creates and queues an object of type
  196. <code>F::work_item</code> that, when later executed in
  197. <code>operator()()</code>, leads to a modification of internal state so
  198. that <code>terminated()</code> henceforth returns
  199. <code>true</code></td>
  200. </tr>
  201. <tr>
  202. <td><code>cf.terminated();</code></td>
  203. <td><code>bool</code></td>
  204. <td><code>true</code> if <code>terminate()</code> has been
  205. called and the resulting work item has been executed in
  206. <code>operator()()</code>. Returns <code>false</code> otherwise<br>
  207. <br>
  208. <b>Must only be called from the thread that also calls
  209. <code>operator()()</code></b></td>
  210. </tr>
  211. <tr>
  212. <td><code>f( n );</code></td>
  213. <td><code>unsigned long</code></td>
  214. <td>
  215. Enters a loop that, with each cycle, dequeues and calls
  216. <code>operator()()</code> on the oldest work item in the queue.
  217. <p>The loop is left and the number of executed work items returned if
  218. one or more of the following conditions are met:</p>
  219. <ul>
  220. <li><code>f.terminated() == true</code></li>
  221. <li>The application is single-threaded and the internal queue is
  222. empty</li>
  223. <li>The application is multi-threaded and the internal queue is
  224. empty and the worker was created as non-blocking</li>
  225. <li><code>n != 0</code> and the number of work items that have been
  226. processed since <code>operator()()</code> was called equals
  227. <code>n</code></li>
  228. </ul>
  229. <p>If the queue is empty and none of the above conditions are met
  230. then the thread calling <code>operator()()</code> is put into a wait
  231. state until <code>f.queue_work_item()</code> is called from another
  232. thread.<br>
  233. <br>
  234. <b>Must only be called from exactly one thread</b></p>
  235. </td>
  236. </tr>
  237. <tr>
  238. <td><code>f();</code></td>
  239. <td><code>unsigned long</code></td>
  240. <td>Has exactly the same semantics as <code>f( n );</code>
  241. with <code>n == 0</code> (see above)</td>
  242. </tr>
  243. </table>
  244. <h2><a name="ExceptionTranslator" id=
  245. "ExceptionTranslator">ExceptionTranslator</a> concept</h2>
  246. <p>An ExceptionTranslator type defines how C++ exceptions occurring during
  247. state machine operation are translated to exception events.</p>
  248. <p>For an ExceptionTranslator object <code>et</code>, a parameterless
  249. function object <code>a</code> of arbitrary type returning <code><a href=
  250. "#Classresult">result</a></code> and a function object <code>eh</code> of
  251. arbitrary type taking a <code>const <a href=
  252. "#Classevent_base">event_base</a> &amp;</code> parameter and returning
  253. <code><a href="#Classresult">result</a></code> the following expression
  254. must be well-formed and have the indicated results:</p>
  255. <table border="3" cellpadding="2" width="100%" summary=
  256. "ExceptionTranslator concept">
  257. <tr>
  258. <td><b>Expression</b></td>
  259. <td><b>Type</b></td>
  260. <td><b>Effects/Result</b></td>
  261. </tr>
  262. <tr>
  263. <td><code>et(&nbsp;a,&nbsp;eh&nbsp;);</code></td>
  264. <td><code>result</code></td>
  265. <td>
  266. <ol>
  267. <li>Attempts to execute <code>return a();</code></li>
  268. <li>If <code>a()</code> propagates an exception, the exception is
  269. caught</li>
  270. <li>Inside the catch block calls <code>eh</code>, passing a
  271. suitable stack-allocated model of the <a href="#Event">Event</a>
  272. concept</li>
  273. <li>Returns the result returned by <code>eh</code></li>
  274. </ol>
  275. </td>
  276. </tr>
  277. </table>
  278. <h2><a name="StateBase" id="StateBase">StateBase</a> concept</h2>
  279. <p>A StateBase type is the common base of all states of a given state
  280. machine type. <code>state_machine&lt;&gt;::state_base_type</code> is a
  281. model of the StateBase concept.</p>
  282. <p>For a StateBase type <code>S</code> and a <code>const</code> object
  283. <code>cs</code> of that type the following expressions must be well-formed
  284. and have the indicated results:</p>
  285. <table border="3" cellpadding="2" width="100%" summary="StateBase concept">
  286. <tr>
  287. <td><b>Expression</b></td>
  288. <td><b>Type</b></td>
  289. <td><b>Result</b></td>
  290. </tr>
  291. <tr>
  292. <td><code>cs.outer_state_ptr()</code></td>
  293. <td><code>const S *</code></td>
  294. <td><code>0</code> if <code>cs</code> is an <a href=
  295. "definitions.html#OutermostState">outermost state</a>, a pointer to the
  296. direct outer state of <code>cs</code> otherwise</td>
  297. </tr>
  298. <tr>
  299. <td><code>cs.dynamic_type()</code></td>
  300. <td><code>S::id_type</code></td>
  301. <td>A value unambiguously identifying the most-derived type
  302. of <code>cs</code>. <code>S::id_type</code> values are comparable with
  303. <code>operator==()</code> and <code>operator!=()</code>. An unspecified
  304. collating order can be established with <code>std::less&lt; S::id_type
  305. &gt;</code>. In contrast to <code>typeid( cs )</code>, this function is
  306. available even on platforms that do not support C++ RTTI (or have been
  307. configured to not support it)</td>
  308. </tr>
  309. <tr>
  310. <td><code>cs.custom_dynamic_type_ptr&lt;<br>
  311. &nbsp; Type &gt;()</code></td>
  312. <td><code>const Type *</code></td>
  313. <td>A pointer to the custom type identifier or
  314. <code>0</code>. If <code>!= 0</code>, <code>Type</code> must match the
  315. type of the previously set pointer. This function is only available if
  316. <a href=
  317. "configuration.html#ApplicationDefinedMacros">BOOST_STATECHART_USE_NATIVE_RTTI</a>
  318. is not defined</td>
  319. </tr>
  320. </table>
  321. <h2><a name="SimpleState" id="SimpleState">SimpleState</a> concept</h2>
  322. <p>A SimpleState type defines one state of a particular state machine.</p>
  323. <p>For a SimpleState type <code>S</code> and a pointer <code>pS</code>
  324. pointing to an object of type <code>S</code> allocated with
  325. <code>new</code> the following expressions/statements must be well-formed
  326. and have the indicated effects/results:</p>
  327. <table border="3" cellpadding="2" width="100%" summary=
  328. "SimpleState concept">
  329. <tr>
  330. <td><b>Expression/Statement</b></td>
  331. <td><b>Type</b></td>
  332. <td><b>Effects/Result/Notes</b></td>
  333. </tr>
  334. <tr>
  335. <td><code><a href=
  336. "#ClassTemplatesimple_state">simple_state</a>&lt;<br>
  337. &nbsp;&nbsp;S,&nbsp;C,&nbsp;I,&nbsp;h&nbsp;&gt;&nbsp;*&nbsp;pB&nbsp;=<br>
  338. &nbsp;&nbsp;&nbsp;&nbsp;pS;</code></td>
  339. <td>&nbsp;</td>
  340. <td><code>simple_state&lt; S, C, I, h &gt;</code> must be
  341. an unambiguous public base of <code>S</code>. See <code><a href=
  342. "#ClassTemplatesimple_state">simple_state&lt;&gt;</a></code>
  343. documentation for the requirements and semantics of <code>C</code>,
  344. <code>I</code> and <code>h</code></td>
  345. </tr>
  346. <tr>
  347. <td><code>new S()</code></td>
  348. <td><code>S *</code></td>
  349. <td>Enters the state <code>S</code>. Certain functions must
  350. not be called from <code>S::S()</code>, see <a href=
  351. "#ClassTemplatesimple_state"><code>simple_state&lt;&gt;</code></a>
  352. documentation for more information</td>
  353. </tr>
  354. <tr>
  355. <td><code>pS-&gt;exit();</code></td>
  356. <td>&nbsp;</td>
  357. <td>Exits the state <code>S</code> (first stage). The
  358. definition of an <code>exit</code> member function within models of the
  359. SimpleState concept is optional since <code>simple_state&lt;&gt;</code>
  360. already defines the following public member: <code>void exit()
  361. {}</code>. <code>exit()</code> is not called when a state is exited
  362. while an exception is pending, see <code><a href=
  363. "#simple_state::terminate">simple_state&lt;&gt;::terminate()</a></code>
  364. for more information</td>
  365. </tr>
  366. <tr>
  367. <td><code>delete pS;</code></td>
  368. <td>&nbsp;</td>
  369. <td>Exits the state <code>S</code> (second stage)</td>
  370. </tr>
  371. <tr>
  372. <td><code>S::reactions</code></td>
  373. <td>An <code>mpl::list&lt;&gt;</code> that is either empty
  374. or contains instantiations of the <code><a href=
  375. "#ClassTemplatecustom_reaction">custom_reaction</a></code>,
  376. <code><a href=
  377. "#ClassTemplatein_state_reaction">in_state_reaction</a></code>,
  378. <code><a href="#ClassTemplatedeferral">deferral</a></code>,
  379. <code><a href="#ClassTemplatetermination">termination</a></code> or
  380. <code><a href="#ClassTemplatetransition">transition</a></code> class
  381. templates. If there is only a single reaction then it can also be
  382. <code>typedef</code>ed directly, without wrapping it into an
  383. <code>mpl::list&lt;&gt;</code></td>
  384. <td>The declaration of a <code>reactions</code> member
  385. <code>typedef</code> within models of the SimpleState concept is
  386. optional since <code>simple_state&lt;&gt;</code> already defines the
  387. following public member: <code>typedef mpl::list&lt;&gt;
  388. reactions;</code></td>
  389. </tr>
  390. </table>
  391. <h2><a name="State" id="State">State</a> concept</h2>
  392. <p>A State is a <b>refinement</b> of <a href="#SimpleState">SimpleState</a>
  393. (that is, except for the default constructor a State type must also satisfy
  394. SimpleState requirements). For a State type <code>S</code>, a pointer
  395. <code>pS</code> of type <code>S *</code> pointing to an object of type
  396. <code>S</code> allocated with <code>new</code>, and an object
  397. <code>mc</code> of type <code>state&lt; S, C, I, h
  398. &gt;</code><code>::my_context</code> the following expressions/statements
  399. must be well-formed:</p>
  400. <table border="3" cellpadding="2" width="100%" summary="State concept">
  401. <tr>
  402. <td><b>Expression/Statement</b></td>
  403. <td><b>Type</b></td>
  404. <td><b>Effects/Result/Notes</b></td>
  405. </tr>
  406. <tr>
  407. <td><code><a href="#ClassTemplatestate">state</a>&lt;&nbsp;S,&nbsp;C,&nbsp;I,&nbsp;h&nbsp;&gt;&nbsp;*<br>
  408. &nbsp;&nbsp;pB = pS;</code></td>
  409. <td>&nbsp;</td>
  410. <td><code>state&lt; S, C, I, h &gt;</code> must be an
  411. unambiguous public base of <code>S</code>. See <code><a href=
  412. "#ClassTemplatestate">state&lt;&gt;</a></code> documentation for the
  413. requirements and semantics of <code>C</code>, <code>I</code> and
  414. <code>h</code></td>
  415. </tr>
  416. <tr>
  417. <td><code>new S( mc )</code></td>
  418. <td><code>S *</code></td>
  419. <td>Enters the state <code>S</code>. No restrictions exist
  420. regarding the functions that can be called from <code>S::S()</code> (in
  421. contrast to the constructors of models of the SimpleState concept).
  422. <code>mc</code> must be forwarded to <code>state&lt; S, C, I, h
  423. &gt;::state()</code></td>
  424. </tr>
  425. </table>
  426. <h2><a name="Event" id="Event">Event</a> concept</h2>
  427. <p>A Event type defines an event for which state machines can define
  428. reactions.</p>
  429. <p>For a Event type <code>E</code> and a pointer <code>pCE</code> of type
  430. <code>const E *</code> pointing to an object of type <code>E</code>
  431. allocated with <code>new</code> the following expressions/statements must
  432. be well-formed and have the indicated effects/results:</p>
  433. <table border="3" cellpadding="2" width="100%" summary="Event concept">
  434. <tr>
  435. <td><b>Expression/Statement</b></td>
  436. <td><b>Type</b></td>
  437. <td><b>Effects/Result/Notes</b></td>
  438. </tr>
  439. <tr>
  440. <td><code>const <a href="#ClassTemplateevent">event</a>&lt;
  441. E &gt; * pCB = pCE;</code></td>
  442. <td>&nbsp;</td>
  443. <td><code>event&lt; E &gt;</code> must be an unambiguous
  444. public base of <code>E</code></td>
  445. </tr>
  446. <tr>
  447. <td><code>new E( *pCE )</code></td>
  448. <td><code>E *</code></td>
  449. <td>Makes a copy of <code>pE</code></td>
  450. </tr>
  451. </table>
  452. <h1>Header &lt;boost/statechart/<a name="state_machine.hpp" id=
  453. "state_machine.hpp">state_machine.hpp</a>&gt;</h1>
  454. <h2><a name="ClassTemplatestate_machine" id=
  455. "ClassTemplatestate_machine">Class template
  456. <code>state_machine</code></a></h2>
  457. <p>This is the base class template of all synchronous state machines.</p>
  458. <h3>Class template <code>state_machine</code> parameters</h3>
  459. <table border="3" cellpadding="2" width="100%" summary=
  460. "state_machine parameters">
  461. <tr>
  462. <td><b>Template parameter</b></td>
  463. <td><b>Requirements</b></td>
  464. <td><b>Semantics</b></td>
  465. <td><b>Default</b></td>
  466. </tr>
  467. <tr>
  468. <td><code>MostDerived</code></td>
  469. <td>The most-derived subtype of this class template</td>
  470. <td>&nbsp;</td>
  471. <td>&nbsp;</td>
  472. </tr>
  473. <tr>
  474. <td><code>InitialState</code></td>
  475. <td>A model of the <a href="#SimpleState">SimpleState</a>
  476. or <a href="#State">State</a> concepts. The <code>Context</code>
  477. argument passed to the <code><a href=
  478. "#ClassTemplatesimple_state">simple_state&lt;&gt;</a></code> or
  479. <code><a href="#ClassTemplatestate">state&lt;&gt;</a></code> base
  480. of&nbsp; <code>InitialState</code> must be <code>MostDerived</code>.
  481. That is, <code>InitialState</code> must be an <a href=
  482. "definitions.html#OutermostState">outermost state</a> of this state
  483. machine</td>
  484. <td>The state that is entered when
  485. <code>state_machine&lt;&gt;<br>
  486. ::initiate()</code> is called</td>
  487. <td>&nbsp;</td>
  488. </tr>
  489. <tr>
  490. <td><code>Allocator</code></td>
  491. <td>A model of the standard Allocator concept</td>
  492. <td><code>Allocator::rebind&lt;&gt;::other</code> is used
  493. to allocate and deallocate all <code>simple_state</code> subtype
  494. objects and internal objects of dynamic storage duration</td>
  495. <td><code>std::allocator&lt; void &gt;</code></td>
  496. </tr>
  497. <tr>
  498. <td><code>ExceptionTranslator</code></td>
  499. <td>A model of the ExceptionTranslator concept</td>
  500. <td>see <a href=
  501. "#ExceptionTranslator">ExceptionTranslator</a> concept</td>
  502. <td><code>null_exception_translator</code></td>
  503. </tr>
  504. </table>
  505. <h3>Class template <code>state_machine</code> synopsis</h3>
  506. <pre>
  507. namespace boost
  508. {
  509. namespace statechart
  510. {
  511. template&lt;
  512. class MostDerived,
  513. class InitialState,
  514. class Allocator = std::allocator&lt; void &gt;,
  515. class ExceptionTranslator = null_exception_translator &gt;
  516. class state_machine : noncopyable
  517. {
  518. public:
  519. typedef MostDerived outermost_context_type;
  520. void <a href="#initiate">initiate</a>();
  521. void <a href="#terminate">terminate</a>();
  522. bool <a href="#terminated">terminated</a>() const;
  523. void <a href="#process_event">process_event</a>( const <a href=
  524. "#Classevent_base">event_base</a> &amp; );
  525. template&lt; class Target &gt;
  526. Target <a href="#state_cast">state_cast</a>() const;
  527. template&lt; class Target &gt;
  528. Target <a href="#state_downcast">state_downcast</a>() const;
  529. // a model of the <a href="#StateBase">StateBase</a> concept
  530. typedef <i>implementation-defined</i> state_base_type;
  531. // a model of the standard Forward Iterator concept
  532. typedef <i>implementation-defined</i> state_iterator;
  533. state_iterator <a href="#state_begin">state_begin</a>() const;
  534. state_iterator <a href="#state_end">state_end</a>() const;
  535. void <a href="#unconsumed_event">unconsumed_event</a>( const <a href=
  536. "#Classevent_base">event_base</a> &amp; ) {}
  537. protected:
  538. <a href="#state_machine">state_machine</a>();
  539. <a href="#state_machinedtor">~state_machine</a>();
  540. void <a href="#post_event2">post_event</a>(
  541. const intrusive_ptr&lt; const <a href=
  542. "#Classevent_base">event_base</a> &gt; &amp; );
  543. void <a href="#post_event3">post_event</a>( const <a href=
  544. "#Classevent_base">event_base</a> &amp; );
  545. const event_base * <a href="#triggering_event1">triggering_event</a>() const;
  546. };
  547. }
  548. }
  549. </pre>
  550. <h3>Class template <code>state_machine</code> constructor and
  551. destructor</h3>
  552. <pre>
  553. <a name="state_machine" id="state_machine">state_machine</a>();
  554. </pre>
  555. <p><b>Effects</b>: Constructs a non-running state machine</p>
  556. <pre>
  557. <a name="state_machinedtor" id="state_machinedtor">~state_machine</a>();
  558. </pre>
  559. <p><b>Effects</b>: Destructs the currently active outermost state and all
  560. its direct and indirect inner states. Innermost states are destructed
  561. first. Other states are destructed as soon as all their direct and indirect
  562. inner states have been destructed. The inner states of each state are
  563. destructed according to the number of their orthogonal region. The state in
  564. the orthogonal region with the highest number is always destructed first,
  565. then the state in the region with the second-highest number and so on<br>
  566. <b>Note</b>: Does not attempt to call any <code>exit</code> member
  567. functions</p>
  568. <h3>Class template <code>state_machine</code> modifier functions</h3>
  569. <pre>
  570. void <a name="initiate" id="initiate">initiate</a>();
  571. </pre>
  572. <p><b>Effects</b>:</p>
  573. <ol>
  574. <li>Calls <code>terminate()</code></li>
  575. <li>Constructs a function object <code>action</code> with a
  576. parameter-less <code>operator()()</code> returning <code><a href=
  577. "#Classresult">result</a></code> that
  578. <ol type="a">
  579. <li>enters (constructs) the state specified with the
  580. <code>InitialState</code> template parameter</li>
  581. <li>enters the tree formed by the direct and indirect inner initial
  582. states of <code>InitialState</code> depth first. The inner states of
  583. each state are entered according to the number of their orthogonal
  584. region. The state in orthogonal region 0 is always entered first,
  585. then the state in region 1 and so on</li>
  586. </ol>
  587. </li>
  588. <li>Constructs a function object <code>exceptionEventHandler</code> with
  589. an <code>operator()()</code> returning <code>result</code> and accepting
  590. an exception event parameter that processes the passed exception event,
  591. with the following differences to the processing of normal events:
  592. <ul type="disc">
  593. <li>From the moment when the exception has been thrown until right
  594. after the execution of the exception event reaction, states that need
  595. to be exited are only destructed but no <code>exit</code> member
  596. functions are called</li>
  597. <li><a href="definitions.html#Reaction">Reaction</a> search always
  598. starts with the outermost <a href=
  599. "definitions.html#UnstableState">unstable state</a></li>
  600. <li>As for normal events, reaction search moves outward when the
  601. current state cannot handle the event. However, if there is no outer
  602. state (an <a href="definitions.html#OutermostState">outermost
  603. state</a> has been reached) the reaction search is considered
  604. unsuccessful. That is, exception events will never be dispatched to
  605. orthogonal regions other than the one that caused the exception
  606. event</li>
  607. <li>Should an exception be thrown during exception event reaction
  608. search or reaction execution then the exception is propagated out of
  609. the <code>exceptionEventHandler</code> function object (that is,
  610. <code>ExceptionTranslator</code> is <b>not</b> used to translate
  611. exceptions thrown while processing an exception event)</li>
  612. <li>If no reaction could be found for the exception event or if the
  613. state machine is not stable after processing the exception event, the
  614. original exception is rethrown. Otherwise, a <code><a href=
  615. "#Classresult">result</a></code> object is returned equal to the one
  616. returned by <code>simple_state&lt;&gt;::discard_event()</code></li>
  617. </ul>
  618. </li>
  619. <li>Passes <code>action</code> and <code>exceptionEventHandler</code> to
  620. <code>ExceptionTranslator::operator()()</code>. If
  621. <code>ExceptionTranslator::operator()()</code> throws an exception, the
  622. exception is propagated to the caller. If the caller catches the
  623. exception, the currently active outermost state and all its direct and
  624. indirect inner states are destructed. Innermost states are destructed
  625. first. Other states are destructed as soon as all their direct and
  626. indirect inner states have been destructed. The inner states of each
  627. state are destructed according to the number of their orthogonal region.
  628. The state in the orthogonal region with the highest number is always
  629. destructed first, then the state in the region with the second-highest
  630. number and so on. Continues with step 5 otherwise (the return value is
  631. discarded)</li>
  632. <li>Processes all posted events (see <code>process_event()</code>).
  633. Returns to the caller if there are no more posted events</li>
  634. </ol>
  635. <p><b>Throws</b>: Any exceptions propagated from
  636. <code>ExceptionTranslator::operator()()</code>. Exceptions never originate
  637. in the library itself but only in code supplied through template
  638. parameters:</p>
  639. <ul>
  640. <li><code>Allocator::rebind&lt;&gt;::other::allocate()</code></li>
  641. <li>state constructors</li>
  642. <li><code>react</code> member functions</li>
  643. <li><code>exit</code> member functions</li>
  644. <li>transition-actions</li>
  645. </ul>
  646. <pre>
  647. void <a name="terminate" id="terminate">terminate</a>();
  648. </pre>
  649. <p><b>Effects</b>:</p>
  650. <ol>
  651. <li>Constructs a function object <code>action</code> with a
  652. parameter-less <code>operator()()</code> returning <code><a href=
  653. "#Classresult">result</a></code> that <a href=
  654. "#simple_state::terminate">terminates</a> the currently active outermost
  655. state, discards all remaining events and clears all history
  656. information</li>
  657. <li>Constructs a function object <code>exceptionEventHandler</code> with
  658. an <code>operator()()</code> returning <code><a href=
  659. "#Classresult">result</a></code> and accepting an exception event
  660. parameter that processes the passed exception event, with the following
  661. differences to the processing of normal events:
  662. <ul type="disc">
  663. <li>From the moment when the exception has been thrown until right
  664. after the execution of the exception event reaction, states that need
  665. to be exited are only destructed but no <code>exit</code> member
  666. functions are called</li>
  667. <li><a href="definitions.html#Reaction">Reaction</a> search always
  668. starts with the outermost <a href=
  669. "definitions.html#UnstableState">unstable state</a></li>
  670. <li>As for normal events, reaction search moves outward when the
  671. current state cannot handle the event. However, if there is no outer
  672. state (an <a href="definitions.html#OutermostState">outermost
  673. state</a> has been reached) the reaction search is considered
  674. unsuccessful. That is, exception events will never be dispatched to
  675. orthogonal regions other than the one that caused the exception
  676. event</li>
  677. <li>Should an exception be thrown during exception event reaction
  678. search or reaction execution then the exception is propagated out of
  679. the <code>exceptionEventHandler</code> function object (that is,
  680. <code>ExceptionTranslator</code> is <b>not</b> used to translate
  681. exceptions thrown while processing an exception event)</li>
  682. <li>If no reaction could be found for the exception event or if the
  683. state machine is not stable after processing the exception event, the
  684. original exception is rethrown. Otherwise, a <code><a href=
  685. "#Classresult">result</a></code> object is returned equal to the one
  686. returned by <code>simple_state&lt;&gt;::discard_event()</code></li>
  687. </ul>
  688. </li>
  689. <li>Passes <code>action</code> and <code>exceptionEventHandler</code> to
  690. <code>ExceptionTranslator::operator()()</code>. If
  691. <code>ExceptionTranslator::operator()()</code> throws an exception, the
  692. exception is propagated to the caller. If the caller catches the
  693. exception, the currently active outermost state and all its direct and
  694. indirect inner states are destructed. Innermost states are destructed
  695. first. Other states are destructed as soon as all their direct and
  696. indirect inner states have been destructed. The inner states of each
  697. state are destructed according to the number of their orthogonal region.
  698. The state in the orthogonal region with the highest number is always
  699. destructed first, then the state in the region with the second-highest
  700. number and so on. Otherwise, returns to the caller</li>
  701. </ol>
  702. <p><b>Throws</b>: Any exceptions propagated from
  703. <code>ExceptionTranslator::operator()</code>. Exceptions never originate in
  704. the library itself but only in code supplied through template
  705. parameters:</p>
  706. <ul>
  707. <li><code>Allocator::rebind&lt;&gt;::other::allocate()</code></li>
  708. <li>state constructors</li>
  709. <li><code>react</code> member functions</li>
  710. <li><code>exit</code> member functions</li>
  711. <li>transition-actions</li>
  712. </ul>
  713. <pre>
  714. void <a name="process_event" id=
  715. "process_event">process_event</a>( const <a href=
  716. "#Classevent_base">event_base</a> &amp; );
  717. </pre>
  718. <p><b>Effects</b>:</p>
  719. <ol>
  720. <li>Selects the passed event as the current event (henceforth referred to
  721. as <code>currentEvent</code>)</li>
  722. <li>Starts a new <a href="definitions.html#Reaction">reaction</a>
  723. search</li>
  724. <li>Selects an arbitrary but in this reaction search not yet visited
  725. state from all the currently active <a href=
  726. "definitions.html#InnermostState">innermost states</a>. If no such state
  727. exists then continues with step 10</li>
  728. <li>Constructs a function object <code>action</code> with a
  729. parameter-less <code>operator()()</code> returning <code><a href=
  730. "#Classresult">result</a></code> that does the following:
  731. <ol type="a">
  732. <li>Searches a reaction suitable for <code>currentEvent</code>,
  733. starting with the current innermost state and moving outward until a
  734. state defining a reaction for the event is found. Returns
  735. <code>simple_state&lt;&gt;::forward_event()</code> if no reaction has
  736. been found</li>
  737. <li>Executes the found reaction. If the reaction result is equal to
  738. the return value of
  739. <code>simple_state&lt;&gt;::forward_event()</code> then resumes the
  740. reaction search (step a). Returns the reaction result otherwise</li>
  741. </ol>
  742. </li>
  743. <li>Constructs a function object <code>exceptionEventHandler</code>
  744. returning <code><a href="#Classresult">result</a></code> and accepting an
  745. exception event parameter that processes the passed exception event, with
  746. the following differences to the processing of normal events:
  747. <ul type="disc">
  748. <li>From the moment when the exception has been thrown until right
  749. after the execution of the exception event reaction, states that need
  750. to be exited are only destructed but no <code>exit</code> member
  751. functions are called</li>
  752. <li>If the state machine is stable when the exception event is
  753. processed then exception event reaction search starts with the
  754. innermost state that was last visited during the last normal event
  755. reaction search (the exception event was generated as a result of
  756. this normal reaction search)</li>
  757. <li>If the state machine is <a href=
  758. "definitions.html#UnstableStateMachine">unstable</a> when the
  759. exception event is processed then exception event reaction search
  760. starts with the outermost <a href=
  761. "definitions.html#UnstableState">unstable state</a></li>
  762. <li>As for normal events, reaction search moves outward when the
  763. current state cannot handle the event. However, if there is no outer
  764. state (an <a href="definitions.html#OutermostState">outermost
  765. state</a> has been reached) the reaction search is considered
  766. unsuccessful. That is, exception events will never be dispatched to
  767. orthogonal regions other than the one that caused the exception
  768. event</li>
  769. <li>Should an exception be thrown during exception event reaction
  770. search or reaction execution then the exception is propagated out of
  771. the <code>exceptionEventHandler</code> function object (that is,
  772. <code>ExceptionTranslator</code> is <b>not</b> used to translate
  773. exceptions thrown while processing an exception event)</li>
  774. <li>If no reaction could be found for the exception event or if the
  775. state machine is not stable after processing the exception event, the
  776. original exception is rethrown. Otherwise, a <code><a href=
  777. "#Classresult">result</a></code> object is returned equal to the one
  778. returned by <code>simple_state&lt;&gt;::discard_event()</code></li>
  779. </ul>
  780. </li>
  781. <li>Passes <code>action</code> and <code>exceptionEventHandler</code> to
  782. <code>ExceptionTranslator::operator()()</code>. If
  783. <code>ExceptionTranslator::operator()()</code> throws an exception, the
  784. exception is propagated to the caller. If the caller catches the
  785. exception, the currently active outermost state and all its direct and
  786. indirect inner states are destructed. Innermost states are destructed
  787. first. Other states are destructed as soon as all their direct and
  788. indirect inner states have been destructed. The inner states of each
  789. state are destructed according to the number of their orthogonal region.
  790. The state in the orthogonal region with the highest number is always
  791. destructed first, then the state in the region with the second-highest
  792. number and so on. Otherwise continues with step 7</li>
  793. <li>If the return value of <code>ExceptionTranslator::operator()()</code>
  794. is equal to the one of <code>simple_state&lt;&gt;::forward_event()</code>
  795. then continues with step 3</li>
  796. <li>If the return value of <code>ExceptionTranslator::operator()()</code>
  797. is equal to the one of <code>simple_state&lt;&gt;::defer_event()</code>
  798. then the return value of <code>currentEvent.<a href=
  799. "#intrusive_from_this">intrusive_from_this</a>()</code> is stored in the
  800. deferred events queue. Continues with step 11</li>
  801. <li>If the return value of <code>ExceptionTranslator::operator()()</code>
  802. is equal to the one of <code>simple_state&lt;&gt;::discard_event()</code>
  803. then continues with step 11</li>
  804. <li>Calls <code>static_cast&lt; MostDerived * &gt;( this
  805. )-&gt;unconsumed_event( currentEvent )</code>. If
  806. <code>unconsumed_event()</code> throws an exception, the exception is
  807. propagated to the caller. Such an exception never leads to the
  808. destruction of any states (in contrast to exceptions propagated from
  809. <code>ExceptionTranslator::operator()()</code>)</li>
  810. <li>If the posted events queue is non-empty then dequeues the first
  811. event, selects it as <code>currentEvent</code> and continues with step 2.
  812. Returns to the caller otherwise</li>
  813. </ol>
  814. <p><b>Throws</b>: Any exceptions propagated from
  815. <code>MostDerived::unconsumed_event()</code> or
  816. <code>ExceptionTranslator::operator()</code>. Exceptions never originate in
  817. the library itself but only in code supplied through template
  818. parameters:</p>
  819. <ul>
  820. <li><code>Allocator::rebind&lt;&gt;::other::allocate()</code></li>
  821. <li>state constructors</li>
  822. <li><code>react</code> member functions</li>
  823. <li><code>exit</code> member functions</li>
  824. <li>transition-actions</li>
  825. <li><code>MostDerived::unconsumed_event()</code></li>
  826. </ul>
  827. <pre>
  828. void <a name="post_event2" id="post_event2">post_event</a>(
  829. const intrusive_ptr&lt; const <a href=
  830. "#Classevent_base">event_base</a> &gt; &amp; );
  831. </pre>
  832. <p><b>Effects</b>: Pushes the passed event into the posted events queue<br>
  833. <b>Throws</b>: Any exceptions propagated from
  834. <code>Allocator::allocate()</code></p>
  835. <pre>
  836. void <a name="post_event3" id="post_event3">post_event</a>( const <a href=
  837. "#Classevent_base">event_base</a> &amp; evt );
  838. </pre>
  839. <p><b>Effects</b>: <code>post_event( evt.intrusive_from_this()
  840. );</code><br>
  841. <b>Throws</b>: Any exceptions propagated from
  842. <code>Allocator::allocate()</code></p>
  843. <pre>
  844. void <a name="unconsumed_event" id=
  845. "unconsumed_event">unconsumed_event</a>( const <a href=
  846. "#Classevent_base">event_base</a> &amp; evt );
  847. </pre>
  848. <p><b>Effects</b>: None<br>
  849. <b>Note</b>: This function (or, if present, the equally named derived class
  850. member function) is called by <a href="#process_event">process_event</a>()
  851. whenever a dispatched event did not trigger a reaction, see <a href=
  852. "#process_event">process_event</a>() effects, point 10 for more
  853. information.</p>
  854. <h3>Class template <code>state_machine</code> observer functions</h3>
  855. <pre>
  856. bool <a name="terminated" id="terminated">terminated</a>() const;
  857. </pre>
  858. <p><b>Returns</b>: <code>true</code>, if the machine is terminated. Returns
  859. <code>false</code> otherwise<br>
  860. <b>Note</b>: Is equivalent to <code>state_begin() == state_end()</code></p>
  861. <pre>
  862. template&lt; class Target &gt;
  863. Target <a name="state_cast" id="state_cast">state_cast</a>() const;
  864. </pre>
  865. <p><b>Returns</b>: Depending on the form of <code>Target</code> either a
  866. reference or a pointer to <code>const</code> if at least one of the
  867. currently active states can successfully be <code>dynamic_cast</code> to
  868. <code>Target</code>. Returns <code>0</code> for pointer targets and throws
  869. <code>std::bad_cast</code> for reference targets otherwise.
  870. <code>Target</code> can take either of the following forms: <code>const
  871. Class *</code> or <code>const Class &amp;</code><br>
  872. <b>Throws</b>: <code>std::bad_cast</code> if <code>Target</code> is a
  873. reference type and none of the active states can be
  874. <code>dynamic_cast</code> to Target<br>
  875. <b>Note</b>: The search sequence is the same as for <code><a href=
  876. "#process_event">process_event</a>()</code></p>
  877. <pre>
  878. template&lt; class Target &gt;
  879. Target <a name="state_downcast" id=
  880. "state_downcast">state_downcast</a>() const;
  881. </pre>
  882. <p><b>Requires</b>: For reference targets the compiler must support partial
  883. specialization of class templates, otherwise a compile-time error will
  884. result. The type denoted by <code>Target</code> must be a model of the
  885. <a href="#SimpleState">SimpleState</a> or <a href="#State">State</a>
  886. concepts<br>
  887. <b>Returns</b>: Depending on the form of <code>Target</code> either a
  888. reference or a pointer to <code>const</code> if <code>Target</code> is
  889. equal to the most-derived type of a currently active state. Returns
  890. <code>0</code> for pointer targets and throws <code>std::bad_cast</code>
  891. for reference targets otherwise. <code>Target</code> can take either of the
  892. following forms: <code>const Class *</code> or <code>const Class
  893. &amp;</code><br>
  894. <b>Throws</b>: <code>std::bad_cast</code> if <code>Target</code> is a
  895. reference type and none of the active states has a most derived type equal
  896. to <code>Target</code><br>
  897. <b>Note</b>: The search sequence is the same as for <code><a href=
  898. "#process_event">process_event</a>()</code></p>
  899. <pre>
  900. state_iterator <a name="state_begin" id=
  901. "state_begin">state_begin</a>() const;
  902. </pre>
  903. <pre>
  904. state_iterator <a name="state_end" id="state_end">state_end</a>() const;
  905. </pre>
  906. <p><b>Return</b>: Iterator objects, the range [<code>state_begin()</code>,
  907. <code>state_end()</code>) refers to all currently active <a href=
  908. "definitions.html#InnermostState">innermost states</a>. For an object
  909. <code>i</code> of type <code>state_iterator</code>, <code>*i</code> returns
  910. a <code>const state_base_type &amp;</code> and
  911. <code>i.operator-&gt;()</code> returns a <code>const state_base_type
  912. *</code><br>
  913. <b>Note</b>: The position of a given innermost state in the range is
  914. arbitrary. It may change with each call to a modifier function. Moreover,
  915. all iterators are invalidated whenever a modifier function is called</p>
  916. <pre>
  917. const event_base * <a name="triggering_event1" id="triggering_event1">triggering_event</a>();
  918. </pre>
  919. <p><b>Returns</b>: A pointer to the event that triggered the reaction that is currently
  920. being executed. Returns <code>0</code> if no reaction is being executed or if the current
  921. reaction was triggered by either <code><a href="#initiate">initiate</a>()</code> or
  922. <code><a href="#terminate">terminate</a>()</code>
  923. </p>
  924. <h1>Header &lt;boost/statechart/<br>
  925. <a name="asynchronous_state_machine.hpp" id=
  926. "asynchronous_state_machine.hpp">asynchronous_state_machine.hpp</a>&gt;</h1>
  927. <h2><a name="ClassTemplateasynchronous_state_machine" id=
  928. "ClassTemplateasynchronous_state_machine">Class template
  929. <code>asynchronous_state_machine</code></a></h2>
  930. <p>This is the base class template of all asynchronous state machines.</p>
  931. <h3>Class template <code>asynchronous_state_machine</code> parameters</h3>
  932. <table border="3" cellpadding="2" width="100%" summary=
  933. "asynchronous_state_machine parameters">
  934. <tr>
  935. <td><b>Template parameter</b></td>
  936. <td><b>Requirements</b></td>
  937. <td><b>Semantics</b></td>
  938. <td><b>Default</b></td>
  939. </tr>
  940. <tr>
  941. <td><code>MostDerived</code></td>
  942. <td>The most-derived subtype of this class template</td>
  943. <td>&nbsp;</td>
  944. <td>&nbsp;</td>
  945. </tr>
  946. <tr>
  947. <td><code>InitialState</code></td>
  948. <td>A model of the <a href="#SimpleState">SimpleState</a>
  949. or <a href="#State">State</a> concepts. The <code>Context</code>
  950. argument passed to the <code><a href=
  951. "#ClassTemplatesimple_state">simple_state&lt;&gt;</a></code> or
  952. <code><a href="#ClassTemplatestate">state&lt;&gt;</a></code> base of
  953. <code>InitialState</code> must be <code>MostDerived</code>. That is,
  954. <code>InitialState</code> must be an <a href=
  955. "definitions.html#OutermostState">outermost state</a> of this state
  956. machine</td>
  957. <td>The state that is entered when the state machine is
  958. initiated through the <code>Scheduler</code> object</td>
  959. <td>&nbsp;</td>
  960. </tr>
  961. <tr>
  962. <td><code>Scheduler</code></td>
  963. <td>A model of the Scheduler concept</td>
  964. <td>see <a href="#Scheduler">Scheduler</a> concept</td>
  965. <td><code>fifo_scheduler&lt;&gt;</code></td>
  966. </tr>
  967. <tr>
  968. <td><code>Allocator</code></td>
  969. <td>A model of the standard Allocator concept</td>
  970. <td>&nbsp;</td>
  971. <td><code>std::allocator&lt; void &gt;</code></td>
  972. </tr>
  973. <tr>
  974. <td><code>ExceptionTranslator</code></td>
  975. <td>A model of the ExceptionTranslator concept</td>
  976. <td>see <a href=
  977. "#ExceptionTranslator">ExceptionTranslator</a> concept</td>
  978. <td><code>null_exception_translator</code></td>
  979. </tr>
  980. </table>
  981. <h3>Class template <code>asynchronous_state_machine</code> synopsis</h3>
  982. <pre>
  983. namespace boost
  984. {
  985. namespace statechart
  986. {
  987. template&lt;
  988. class MostDerived,
  989. class InitialState,
  990. class Scheduler = fifo_scheduler&lt;&gt;,
  991. class Allocator = std::allocator&lt; void &gt;,
  992. class ExceptionTranslator = null_exception_translator &gt;
  993. class asynchronous_state_machine :
  994. public state_machine&lt;
  995. MostDerived, InitialState, Allocator, ExceptionTranslator &gt;,
  996. public event_processor&lt; Scheduler &gt;
  997. {
  998. protected:
  999. typedef asynchronous_state_machine my_base;
  1000. asynchronous_state_machine(
  1001. typename event_processor&lt; Scheduler &gt;::my_context ctx );
  1002. ~asynchronous_state_machine();
  1003. };
  1004. }
  1005. }
  1006. </pre>
  1007. <h3>Class template <code>asynchronous_state_machine</code> constructor and
  1008. destructor</h3>
  1009. <pre>
  1010. asynchronous_state_machine(
  1011. typename event_processor&lt; Scheduler &gt;::my_context ctx );
  1012. </pre>
  1013. <p><b>Effects</b>: Constructs a non-running asynchronous state machine<br>
  1014. <b>Note</b>: Users cannot create
  1015. <code>asynchronous_state_machine&lt;&gt;</code> subtype objects directly.
  1016. This can only be done through an object of the <code>Scheduler</code>
  1017. class</p>
  1018. <pre>
  1019. ~asynchronous_state_machine();
  1020. </pre>
  1021. <p><b>Effects</b>: Destructs the state machine<br>
  1022. <b>Note</b>: Users cannot destruct
  1023. <code>asynchronous_state_machine&lt;&gt;</code> subtype objects directly.
  1024. This can only be done through an object of the <code>Scheduler</code>
  1025. class</p>
  1026. <h1>Header &lt;boost/statechart/<a name="event_processor.hpp" id=
  1027. "event_processor.hpp">event_processor.hpp</a>&gt;</h1>
  1028. <h2><a name="ClassTemplateevent_processor" id=
  1029. "ClassTemplateevent_processor">Class template
  1030. <code>event_processor</code></a></h2>
  1031. <p>This is the base class template of all types that process events.
  1032. <code>asynchronous_state_machine&lt;&gt;</code> is just one possible event
  1033. processor implementation.</p>
  1034. <h3>Class template <code>event_processor</code> parameters</h3>
  1035. <table border="3" cellpadding="2" width="100%" summary=
  1036. "event_processor parameters">
  1037. <tr>
  1038. <td><b>Template parameter</b></td>
  1039. <td><b>Requirements</b></td>
  1040. <td><b>Semantics</b></td>
  1041. </tr>
  1042. <tr>
  1043. <td><code>Scheduler</code></td>
  1044. <td>A model of the Scheduler concept</td>
  1045. <td>see <a href="#Scheduler">Scheduler</a> concept</td>
  1046. </tr>
  1047. </table>
  1048. <h3>Class template <code>event_processor</code> synopsis</h3>
  1049. <pre>
  1050. namespace boost
  1051. {
  1052. namespace statechart
  1053. {
  1054. template&lt; class Scheduler &gt;
  1055. class event_processor
  1056. {
  1057. public:
  1058. virtual <a href="#event_processordtor">~event_processor</a>();
  1059. Scheduler &amp; <a href="#my_scheduler">my_scheduler</a>() const;
  1060. typedef typename Scheduler::processor_handle
  1061. processor_handle;
  1062. processor_handle <a href="#my_handle">my_handle</a>() const;
  1063. void <a href="#event_processor::initiate">initiate</a>();
  1064. void <a href=
  1065. "#event_processor::process_event">process_event</a>( const event_base &amp; evt );
  1066. void <a href="#event_processor::terminate">terminate</a>();
  1067. protected:
  1068. typedef const typename Scheduler::processor_context &amp;
  1069. my_context;
  1070. <a href="#event_processor">event_processor</a>( my_context ctx );
  1071. private:
  1072. virtual void initiate_impl() = 0;
  1073. virtual void process_event_impl(
  1074. const event_base &amp; evt ) = 0;
  1075. virtual void terminate_impl() = 0;
  1076. };
  1077. }
  1078. }
  1079. </pre>
  1080. <h3>Class template <code>event_processor</code> constructor and
  1081. destructor</h3>
  1082. <pre>
  1083. <a name="event_processor" id=
  1084. "event_processor">event_processor</a>( my_context ctx );
  1085. </pre>
  1086. <p><b>Effects</b>: Constructs an event processor object and stores copies
  1087. of the reference returned by <code>myContext.my_scheduler()</code> and the
  1088. object returned by <code>myContext.my_handle()</code><br>
  1089. <b>Note</b>: Users cannot create <code>event_processor&lt;&gt;</code>
  1090. subtype objects directly. This can only be done through an object of the
  1091. <code>Scheduler</code> class</p>
  1092. <pre>
  1093. virtual <a name="event_processordtor" id=
  1094. "event_processordtor">~event_processor</a>();
  1095. </pre>
  1096. <p><b>Effects</b>: Destructs an event processor object<br>
  1097. <b>Note</b>: Users cannot destruct <code>event_processor&lt;&gt;</code>
  1098. subtype objects directly. This can only be done through an object of the
  1099. <code>Scheduler</code> class</p>
  1100. <h3>Class template <code>event_processor</code> modifier functions</h3>
  1101. <pre>
  1102. void <a name="event_processor::initiate" id=
  1103. "event_processor::initiate">initiate</a>();
  1104. </pre>
  1105. <p><b>Effects</b>: <code>initiate_impl();<br></code><b>Throws</b>: Any
  1106. exceptions propagated from the implementation of
  1107. <code>initiate_impl()</code></p>
  1108. <pre>
  1109. void <a name="event_processor::process_event" id=
  1110. "event_processor::process_event">process_event</a>( const event_base &amp; evt );
  1111. </pre>
  1112. <p><b>Effects</b>: <code>process_event_impl( evt
  1113. );<br></code><b>Throws</b>: Any exceptions propagated from the
  1114. implementation of <code>process_event_impl()</code></p>
  1115. <pre>
  1116. void <a name="event_processor::terminate" id=
  1117. "event_processor::terminate">terminate</a>();
  1118. </pre>
  1119. <p><b>Effects</b>: <code>terminate_impl();<br></code><b>Throws</b>: Any
  1120. exceptions propagated from the implementation of
  1121. <code>terminate_impl()</code></p>
  1122. <h3>Class template <code>event_processor</code> observer functions</h3>
  1123. <pre>
  1124. Scheduler &amp; <a name="my_scheduler" id=
  1125. "my_scheduler">my_scheduler</a>() const;
  1126. </pre>
  1127. <p><b>Returns</b>: The <code>Scheduler</code> reference obtained in the
  1128. constructor</p>
  1129. <pre>
  1130. processor_handle <a name="my_handle" id="my_handle">my_handle</a>() const;
  1131. </pre>
  1132. <p><b>Returns</b>: The <code>processor_handle</code> object obtained in the
  1133. constructor</p>
  1134. <h1>Header &lt;boost/statechart/<a name="fifo_scheduler.hpp" id=
  1135. "fifo_scheduler.hpp">fifo_scheduler.hpp</a>&gt;</h1>
  1136. <h2><a name="ClassTemplatefifo_scheduler" id=
  1137. "ClassTemplatefifo_scheduler">Class template
  1138. <code>fifo_scheduler</code></a></h2>
  1139. <p>This class template is a model of the <a href="#Scheduler">Scheduler</a>
  1140. concept.</p>
  1141. <h3>Class template <code>fifo_scheduler</code> parameters</h3>
  1142. <table border="3" cellpadding="2" width="100%" summary=
  1143. "fifo_scheduler parameters">
  1144. <tr>
  1145. <td><b>Template parameter</b></td>
  1146. <td><b>Requirements</b></td>
  1147. <td><b>Semantics</b></td>
  1148. <td><b>Default</b></td>
  1149. </tr>
  1150. <tr>
  1151. <td><code>FifoWorker</code></td>
  1152. <td>A model of the FifoWorker concept</td>
  1153. <td>see <a href="#FifoWorker">FifoWorker</a> concept</td>
  1154. <td><code>fifo_worker&lt;&gt;</code></td>
  1155. </tr>
  1156. <tr>
  1157. <td><code>Allocator</code></td>
  1158. <td>A model of the standard Allocator concept</td>
  1159. <td>&nbsp;</td>
  1160. <td><code>std::allocator&lt;&nbsp;void&nbsp;&gt;</code></td>
  1161. </tr>
  1162. </table>
  1163. <h3>Class template <code>fifo_scheduler</code> synopsis</h3>
  1164. <pre>
  1165. namespace boost
  1166. {
  1167. namespace statechart
  1168. {
  1169. template&lt;
  1170. class FifoWorker = fifo_worker&lt;&gt;,
  1171. class Allocator = std::allocator&lt; void &gt; &gt;
  1172. class fifo_scheduler : noncopyable
  1173. {
  1174. public:
  1175. <a href=
  1176. "#fifo_scheduler::fifo_scheduler">fifo_scheduler</a>( bool waitOnEmptyQueue = false );
  1177. typedef <i>implementation-defined</i> processor_handle;
  1178. class processor_context : noncopyable
  1179. {
  1180. processor_context(
  1181. fifo_scheduler &amp; scheduler,
  1182. const processor_handle &amp; theHandle );
  1183. fifo_scheduler &amp; my_scheduler() const;
  1184. const processor_handle &amp; my_handle() const;
  1185. friend class fifo_scheduler;
  1186. friend class event_processor&lt; fifo_scheduler &gt;;
  1187. };
  1188. template&lt; class Processor &gt;
  1189. processor_handle <a href="#create_processor">create_processor</a>();
  1190. template&lt; class Processor, typename Param1 &gt;
  1191. processor_handle <a href=
  1192. "#create_processor1">create_processor</a>( Param1 param1 );
  1193. // More create_processor overloads
  1194. void <a href=
  1195. "#destroy_processor">destroy_processor</a>( processor_handle processor );
  1196. void <a href=
  1197. "#initiate_processor">initiate_processor</a>( processor_handle processor );
  1198. void <a href=
  1199. "#terminate_processor">terminate_processor</a>( processor_handle processor );
  1200. typedef intrusive_ptr&lt; const event_base &gt; event_ptr_type;
  1201. void <a href="#queue_event">queue_event</a>(
  1202. const processor_handle &amp; processor,
  1203. const event_ptr_type &amp; pEvent );
  1204. typedef typename FifoWorker::work_item work_item;
  1205. void <a href=
  1206. "#queue_work_item">queue_work_item</a>( const work_item &amp; item );
  1207. void <a href="#fifo_scheduler::terminate">terminate</a>();
  1208. bool <a href="#fifo_scheduler::terminated">terminated</a>() const;
  1209. unsigned long <a href="#operatorfuncall">operator()</a>(
  1210. unsigned long maxEventCount = 0 );
  1211. };
  1212. }
  1213. }
  1214. </pre>
  1215. <h3>Class template <code>fifo_scheduler</code> constructor</h3>
  1216. <pre>
  1217. <a name="fifo_scheduler::fifo_scheduler" id=
  1218. "fifo_scheduler::fifo_scheduler">fifo_scheduler</a>( bool waitOnEmptyQueue = false );
  1219. </pre>
  1220. <p><b>Effects</b>: Constructs a <code>fifo_scheduler&lt;&gt;</code> object.
  1221. In multi-threaded builds, <code>waitOnEmptyQueue</code> is forwarded to the
  1222. constructor of a data member of type <code>FifoWorker</code>. In
  1223. single-threaded builds, the <code>FifoWorker</code> data member is
  1224. default-constructed<br>
  1225. <b>Note</b>: In single-threaded builds the
  1226. <code>fifo_scheduler&lt;&gt;</code> constructor does not accept any
  1227. parameters and <code>operator()()</code> thus always returns to the caller
  1228. when the event queue is empty</p>
  1229. <h3>Class template <code>fifo_scheduler</code> modifier functions</h3>
  1230. <pre>
  1231. template&lt; class Processor &gt;
  1232. processor_handle <a name="create_processor" id=
  1233. "create_processor">create_processor</a>();
  1234. </pre>
  1235. <p><b>Requires</b>: The <code>Processor</code> type must be a direct or
  1236. indirect subtype of the <a href=
  1237. "#ClassTemplateevent_processor"><code>event_processor</code></a> class
  1238. template<br>
  1239. <b>Effects</b>: Creates and passes to
  1240. <code>FifoWorker::queue_work_item()</code> an object of type
  1241. <code>FifoWorker::work_item</code> that, when later executed in
  1242. <code>FifoWorker::operator()()</code>, leads to a call to the constructor
  1243. of <code>Processor</code>, passing an appropriate
  1244. <code>processor_context</code> object as the only argument<br>
  1245. <b>Returns</b>: A <code>processor_handle</code> object that henceforth
  1246. identifies the created event processor object<br>
  1247. <b>Throws</b>: Any exceptions propagated from
  1248. <code>FifoWorker::work_item()</code> and
  1249. <code>FifoWorker::queue_work_item()</code><br>
  1250. <b>Caution</b>: The current implementation of this function makes an
  1251. (indirect) call to global <code>operator new()</code>. Unless global
  1252. <code>operator new()</code> is replaced, care must be taken when to call
  1253. this function in applications with hard real-time requirements</p>
  1254. <pre>
  1255. template&lt; class Processor, typename Param1 &gt;
  1256. processor_handle <a name="create_processor1" id=
  1257. "create_processor1">create_processor( Param1 param1 )</a>;
  1258. </pre>
  1259. <p><b>Requires</b>: The <code>Processor</code> type must be a direct or
  1260. indirect subtype of the <a href=
  1261. "#ClassTemplateevent_processor"><code>event_processor</code></a> class
  1262. template<br>
  1263. <b>Effects</b>: Creates and passes to
  1264. <code>FifoWorker::queue_work_item()</code> an object of type
  1265. <code>FifoWorker::work_item</code> that, when later executed in
  1266. <code>FifoWorker::operator()()</code>, leads to a call to the constructor
  1267. of <code>Processor</code>, passing an appropriate
  1268. <code>processor_context</code> object and <code>param1</code> as
  1269. arguments<br>
  1270. <b>Returns</b>: A <code>processor_handle</code> object that henceforth
  1271. identifies the created event processor object<br>
  1272. <b>Throws</b>: Any exceptions propagated from
  1273. <code>FifoWorker::work_item()</code> and
  1274. <code>FifoWorker::queue_work_item()</code><b><br>
  1275. Note</b>: <code>boost::ref()</code> and <code>boost::cref()</code> can be
  1276. used to pass arguments by reference rather than by copy.
  1277. <code>fifo_scheduler&lt;&gt;</code> has 5 additional
  1278. <code>create_processor&lt;&gt;</code> overloads, allowing to pass up to 6
  1279. custom arguments to the constructors of event processors<br>
  1280. <b>Caution</b>: The current implementation of this and all other overloads
  1281. make (indirect) calls to global <code>operator new()</code>. Unless global
  1282. <code>operator new()</code> is replaced, care must be taken when to call
  1283. these overloads in applications with hard real-time requirements</p>
  1284. <pre>
  1285. void <a name="destroy_processor" id=
  1286. "destroy_processor">destroy_processor</a>( processor_handle processor );
  1287. </pre>
  1288. <p><b>Requires</b>: <code>processor</code> was obtained from a call to one
  1289. of the <code>create_processor&lt;&gt;()</code> overloads on the same
  1290. <code>fifo_scheduler&lt;&gt;</code> object<br>
  1291. <b>Effects</b>: Creates and passes to
  1292. <code>FifoWorker::queue_work_item()</code> an object of type
  1293. <code>FifoWorker::work_item</code> that, when later executed in
  1294. <code>FifoWorker::operator()()</code>, leads to a call to the destructor of
  1295. the event processor object associated with <code>processor</code>. The
  1296. object is silently discarded if the event processor object has been
  1297. destructed before<br>
  1298. <b>Throws</b>: Any exceptions propagated from
  1299. <code>FifoWorker::work_item()</code> and
  1300. <code>FifoWorker::queue_work_item()</code><br>
  1301. <b>Caution</b>: The current implementation of this function leads to an
  1302. (indirect) call to global <code>operator delete()</code> (the call is made
  1303. when the last <code>processor_handle</code> object associated with the
  1304. event processor object is destructed). Unless global <code>operator
  1305. delete()</code> is replaced, care must be taken when to call this function
  1306. in applications with hard real-time requirements</p>
  1307. <pre>
  1308. void <a name="initiate_processor" id=
  1309. "initiate_processor">initiate_processor</a>( processor_handle processor );
  1310. </pre>
  1311. <p><b>Requires</b>: <code>processor</code> was obtained from a call to one
  1312. of the <code>create_processor()</code> overloads on the same
  1313. <code>fifo_scheduler&lt;&gt;</code> object<br>
  1314. <b>Effects</b>: Creates and passes to
  1315. <code>FifoWorker::queue_work_item()</code> an object of type
  1316. <code>FifoWorker::work_item</code> that, when later executed in
  1317. <code>FifoWorker::operator()()</code>, leads to a call to <code><a href=
  1318. "#event_processor::initiate">initiate</a>()</code> on the event processor
  1319. object associated with <code>processor</code>. The object is silently
  1320. discarded if the event processor object has been destructed before<br>
  1321. <b>Throws</b>: Any exceptions propagated from
  1322. <code>FifoWorker::work_item()</code> and
  1323. <code>FifoWorker::queue_work_item()</code></p>
  1324. <pre>
  1325. void <a name="terminate_processor" id=
  1326. "terminate_processor">terminate_processor</a>( processor_handle processor );
  1327. </pre>
  1328. <p><b>Requires</b>: <code>processor</code> was obtained from a call to one
  1329. of the <code>create_processor&lt;&gt;()</code> overloads on the same
  1330. <code>fifo_scheduler&lt;&gt;</code> object<br>
  1331. <b>Effects</b>: Creates and passes to
  1332. <code>FifoWorker::queue_work_item()</code> an object of type
  1333. <code>FifoWorker::work_item</code> that, when later executed in
  1334. <code>FifoWorker::operator()()</code>, leads to a call to <code><a href=
  1335. "#event_processor::terminate">terminate</a>()</code> on the event processor
  1336. object associated with <code>processor</code>. The object is silently
  1337. discarded if the event processor object has been destructed before<br>
  1338. <b>Throws</b>: Any exceptions propagated from
  1339. <code>FifoWorker::work_item()</code> and
  1340. <code>FifoWorker::queue_work_item()</code></p>
  1341. <pre>
  1342. void <a name="queue_event" id="queue_event">queue_event</a>(
  1343. const processor_handle &amp; processor,
  1344. const event_ptr_type &amp; pEvent );
  1345. </pre>
  1346. <p><b>Requires</b>: <code>pEvent.get() != 0</code> and
  1347. <code>processor</code> was obtained from a call to one of the
  1348. <code>create_processor&lt;&gt;()</code> overloads on the same
  1349. <code>fifo_scheduler&lt;&gt;</code> object<br>
  1350. <b>Effects</b>: Creates and passes to
  1351. <code>FifoWorker::queue_work_item()</code> an object of type
  1352. <code>FifoWorker::work_item</code> that, when later executed in
  1353. <code>FifoWorker::operator()()</code>, leads to a call to <code><a href=
  1354. "#event_processor::process_event">process_event</a>( *pEvent )</code> on
  1355. the event processor object associated with <code>processor</code>. The
  1356. object is silently discarded if the event processor object has been
  1357. destructed before<br>
  1358. <b>Throws</b>: Any exceptions propagated from
  1359. <code>FifoWorker::work_item()</code> and
  1360. <code>FifoWorker::queue_work_item()</code></p>
  1361. <pre>
  1362. void <a name="queue_work_item" id=
  1363. "queue_work_item">queue_work_item</a>( const work_item &amp; item );
  1364. </pre>
  1365. <p><b>Effects</b>: <code>FifoWorker::queue_work_item( item );</code><br>
  1366. <b>Throws</b>: Any exceptions propagated from the above call</p>
  1367. <pre>
  1368. void <a name="fifo_scheduler::terminate" id=
  1369. "fifo_scheduler::terminate">terminate</a>();
  1370. </pre>
  1371. <p><b>Effects</b>: <code>FifoWorker::terminate()</code><br>
  1372. <b>Throws</b>: Any exceptions propagated from the above call</p>
  1373. <pre>
  1374. unsigned long <a name="operatorfuncall" id=
  1375. "operatorfuncall">operator()</a>( unsigned long maxEventCount = 0 );
  1376. </pre>
  1377. <p><b>Requires</b>: Must only be called from exactly one thread<b><br>
  1378. Effects</b>: <code>FifoWorker::operator()( maxEventCount )</code><br>
  1379. <b>Returns</b>: The return value of the above call<br>
  1380. <b>Throws</b>: Any exceptions propagated from the above call</p>
  1381. <h3>Class template <code>fifo_scheduler</code> observer functions</h3>
  1382. <pre>
  1383. bool <a name="fifo_scheduler::terminated" id=
  1384. "fifo_scheduler::terminated">terminated</a>() const;
  1385. </pre>
  1386. <p><b>Requires</b>: Must only be called from the thread that also calls
  1387. <code>operator()()</code><br>
  1388. <b>Returns</b>: <code>FifoWorker::terminated();</code></p>
  1389. <h1>Header &lt;boost/statechart/<a name="exception_translator.hpp" id=
  1390. "exception_translator.hpp">exception_translator.hpp</a>&gt;</h1>
  1391. <h2><a name="ClassTemplateexception_translator" id=
  1392. "ClassTemplateexception_translator">Class template
  1393. <code>exception_translator</code></a></h2>
  1394. <p>This class template is a model of the <a href=
  1395. "#ExceptionTranslator">ExceptionTranslator</a> concept.</p>
  1396. <h3>Class template <code>exception_translator</code> parameters</h3>
  1397. <table border="3" cellpadding="2" width="100%" summary=
  1398. "exception_translator parameters">
  1399. <tr>
  1400. <td><b>Template parameter</b></td>
  1401. <td><b>Requirements</b></td>
  1402. <td><b>Semantics</b></td>
  1403. <td><b>Default</b></td>
  1404. </tr>
  1405. <tr>
  1406. <td><code>ExceptionEvent</code></td>
  1407. <td>A model of the <a href="#Event">Event</a> concept</td>
  1408. <td>The type of event that is dispatched when an exception
  1409. is propagated into the framework</td>
  1410. <td><code>exception_thrown</code></td>
  1411. </tr>
  1412. </table>
  1413. <h3>Class template <code>exception_translator</code> synopsis &amp;
  1414. semantics</h3>
  1415. <pre>
  1416. namespace boost
  1417. {
  1418. namespace statechart
  1419. {
  1420. class exception_thrown : public event&lt; exception_thrown &gt; {};
  1421. template&lt; class ExceptionEvent = exception_thrown &gt;
  1422. class exception_translator
  1423. {
  1424. public:
  1425. template&lt; class Action, class ExceptionEventHandler &gt;
  1426. result operator()(
  1427. Action action,
  1428. ExceptionEventHandler eventHandler )
  1429. {
  1430. try
  1431. {
  1432. return action();
  1433. }
  1434. catch( ... )
  1435. {
  1436. return eventHandler( ExceptionEvent() );
  1437. }
  1438. }
  1439. };
  1440. }
  1441. }
  1442. </pre>
  1443. <h1>Header &lt;boost/statechart/<br>
  1444. <a name="null_exception_translator.hpp" id=
  1445. "null_exception_translator.hpp">null_exception_translator.hpp</a>&gt;</h1>
  1446. <h2><a name="Classnull_exception_translator" id=
  1447. "Classnull_exception_translator">Class
  1448. <code>null_exception_translator</code></a></h2>
  1449. <p>This class is a model of the <a href=
  1450. "#ExceptionTranslator">ExceptionTranslator</a> concept.</p>
  1451. <h3>Class <code>null_exception_translator</code> synopsis &amp;
  1452. semantics</h3>
  1453. <pre>
  1454. namespace boost
  1455. {
  1456. namespace statechart
  1457. {
  1458. class null_exception_translator
  1459. {
  1460. public:
  1461. template&lt; class Action, class ExceptionEventHandler &gt;
  1462. result operator()(
  1463. Action action, ExceptionEventHandler )
  1464. {
  1465. return action();
  1466. }
  1467. };
  1468. }
  1469. }
  1470. </pre>
  1471. <h1>Header &lt;boost/statechart/<a name="simple_state.hpp" id=
  1472. "simple_state.hpp">simple_state.hpp</a>&gt;</h1>
  1473. <h2><a name="Enumhistory_mode" id="Enumhistory_mode">Enum
  1474. <code>history_mode</code></a></h2>
  1475. <p>Defines the history type of a state.</p>
  1476. <pre>
  1477. namespace boost
  1478. {
  1479. namespace statechart
  1480. {
  1481. enum history_mode
  1482. {
  1483. has_no_history,
  1484. has_shallow_history,
  1485. has_deep_history,
  1486. has_full_history // shallow &amp; deep
  1487. };
  1488. }
  1489. }
  1490. </pre>
  1491. <h2><a name="ClassTemplatesimple_state" id=
  1492. "ClassTemplatesimple_state">Class template
  1493. <code>simple_state</code></a></h2>
  1494. <p>This is the base class template for all models of the <a href=
  1495. "#SimpleState">SimpleState</a> concept. Such models must not call any of
  1496. the following <code>simple_state&lt;&gt;</code> member functions from their
  1497. constructors:</p>
  1498. <pre>
  1499. void <b>post_event</b>(
  1500. const intrusive_ptr&lt; const event_base &gt; &amp; );
  1501. void <b>post_event</b>( const event_base &amp; );
  1502. template&lt;
  1503. class HistoryContext,
  1504. <i>implementation-defined-unsigned-integer-type
  1505. </i> orthogonalPosition &gt;
  1506. void <b>clear_shallow_history</b>();
  1507. template&lt;
  1508. class HistoryContext,
  1509. <i>implementation-defined-unsigned-integer-type
  1510. </i> orthogonalPosition &gt;
  1511. void <b>clear_deep_history</b>();
  1512. outermost_context_type &amp; <b>outermost_context</b>();
  1513. const outermost_context_type &amp; <b>outermost_context</b>() const;
  1514. template&lt; class OtherContext &gt;
  1515. OtherContext &amp; <b>context</b>();
  1516. template&lt; class OtherContext &gt;
  1517. const OtherContext &amp; <b>context</b>() const;
  1518. template&lt; class Target &gt;
  1519. Target <b>state_cast</b>() const;
  1520. template&lt; class Target &gt;
  1521. Target <b>state_downcast</b>() const;
  1522. state_iterator <b>state_begin</b>() const;
  1523. state_iterator <b>state_end</b>() const;
  1524. const event_base * <b>triggering_event</b>() const;
  1525. </pre>
  1526. <p>States that need to call any of these member functions from their
  1527. constructors must derive from the <code><a href=
  1528. "#ClassTemplatestate">state</a></code> class template.</p>
  1529. <h3>Class template <code>simple_state</code> parameters</h3>
  1530. <table border="3" cellpadding="2" width="100%" summary=
  1531. "simple_state parameters">
  1532. <tr>
  1533. <td><b>Template parameter</b></td>
  1534. <td><b>Requirements</b></td>
  1535. <td><b>Semantics</b></td>
  1536. <td><b>Default</b></td>
  1537. </tr>
  1538. <tr>
  1539. <td><code>MostDerived</code></td>
  1540. <td>The most-derived subtype of this class template</td>
  1541. <td>&nbsp;</td>
  1542. <td>&nbsp;</td>
  1543. </tr>
  1544. <tr>
  1545. <td><code>Context</code></td>
  1546. <td>A most-derived direct or indirect subtype of the
  1547. <code><a href="#ClassTemplatestate_machine">state_machine</a></code> or
  1548. <code><a href=
  1549. "#ClassTemplateasynchronous_state_machine">asynchronous_state_machine</a></code>
  1550. class templates or a model of the <a href=
  1551. "#SimpleState">SimpleState</a> or <a href="#State">State</a> concepts
  1552. or an instantiation of the <code><a href=
  1553. "#ClassTemplatesimple_state">simple_state&lt;&gt;::orthogonal</a></code>
  1554. class template. Must be a complete type</td>
  1555. <td>Defines the states' position in the state
  1556. hierarchy</td>
  1557. <td>&nbsp;</td>
  1558. </tr>
  1559. <tr>
  1560. <td><code>InnerInitial</code></td>
  1561. <td>An <code>mpl::list&lt;&gt;</code> containing models of
  1562. the <a href="#SimpleState">SimpleState</a> or <a href=
  1563. "#State">State</a> concepts or instantiations of the <code><a href=
  1564. "#ClassTemplateshallow_history">shallow_history</a></code> or
  1565. <code><a href="#ClassTemplatedeep_history">deep_history</a></code>
  1566. class templates. If there is only a single inner initial state that is
  1567. not a template instantiation then it can also be passed directly,
  1568. without wrapping it into an <code>mpl::list&lt;&gt;</code>. The
  1569. <code>Context</code> argument passed to the <code><a href=
  1570. "#ClassTemplatesimple_state">simple_state&lt;&gt;</a></code> or
  1571. <code><a href="#ClassTemplatestate">state&lt;&gt;</a></code> base
  1572. of&nbsp;each state in the list must correspond to the orthogonal region
  1573. it belongs to. That is, the first state in the list must pass
  1574. <code>MostDerived::orthogonal&lt; 0 &gt;</code>, the second
  1575. <code>MostDerived::orthogonal&lt; 1 &gt;</code> and so forth.
  1576. <code>MostDerived::orthogonal&lt; 0 &gt;</code> and
  1577. <code>MostDerived</code> are synonymous</td>
  1578. <td>Defines the inner initial state for each orthogonal
  1579. region. By default, a state does not have inner states</td>
  1580. <td><i><code>unspecified</code></i></td>
  1581. </tr>
  1582. <tr>
  1583. <td><code>historyMode</code></td>
  1584. <td>One of the values defined in the <code><a href=
  1585. "#Enumhistory_mode">history_mode</a></code> enumeration</td>
  1586. <td>Defines whether the state saves shallow, deep or both
  1587. histories upon exit</td>
  1588. <td><code>has_no_history</code></td>
  1589. </tr>
  1590. </table>
  1591. <h3>Class template <code>simple_state</code> synopsis</h3>
  1592. <pre>
  1593. namespace boost
  1594. {
  1595. namespace statechart
  1596. {
  1597. template&lt;
  1598. class MostDerived,
  1599. class Context,
  1600. class InnerInitial = <i>unspecified</i>,
  1601. history_mode historyMode = has_no_history &gt;
  1602. class simple_state : <i>implementation-defined</i>
  1603. {
  1604. public:
  1605. // by default, a state has no reactions
  1606. typedef mpl::list&lt;&gt; reactions;
  1607. // see template parameters
  1608. template&lt; <i>implementation-defined-unsigned-integer-type
  1609. </i> innerOrthogonalPosition &gt;
  1610. struct orthogonal
  1611. {
  1612. // <i>implementation-defined</i>
  1613. };
  1614. typedef typename Context::outermost_context_type
  1615. outermost_context_type;
  1616. outermost_context_type &amp; <a href=
  1617. "#outermost_context">outermost_context</a>();
  1618. const outermost_context_type &amp; <a href=
  1619. "#outermost_contextconst">outermost_context</a>() const;
  1620. template&lt; class OtherContext &gt;
  1621. OtherContext &amp; <a href="#context">context</a>();
  1622. template&lt; class OtherContext &gt;
  1623. const OtherContext &amp; <a href="#contextconst">context</a>() const;
  1624. template&lt; class Target &gt;
  1625. Target <a href="#simple_state::state_cast">state_cast</a>() const;
  1626. template&lt; class Target &gt;
  1627. Target <a href=
  1628. "#simple_state::state_downcast">state_downcast</a>() const;
  1629. // a model of the StateBase concept
  1630. typedef <i>implementation-defined</i> state_base_type;
  1631. // a model of the standard Forward Iterator concept
  1632. typedef <i>implementation-defined</i> state_iterator;
  1633. state_iterator <a href=
  1634. "#simple_state::state_begin">state_begin</a>() const;
  1635. state_iterator <a href=
  1636. "#simple_state::state_end">state_end</a>() const;
  1637. const event_base * <a href="#triggering_event0">triggering_event</a>() const;
  1638. void <a href="#post_event0">post_event</a>(
  1639. const intrusive_ptr&lt; const <a href=
  1640. "#Classevent_base">event_base</a> &gt; &amp; );
  1641. void <a href="#post_event1">post_event</a>( const <a href=
  1642. "#Classevent_base">event_base</a> &amp; );
  1643. <a href="#Classresult">result</a> <a href=
  1644. "#discard_event">discard_event</a>();
  1645. <a href="#Classresult">result</a> <a href=
  1646. "#forward_event">forward_event</a>();
  1647. <a href="#Classresult">result</a> <a href=
  1648. "#defer_event">defer_event</a>();
  1649. template&lt; class DestinationState &gt;
  1650. <a href="#Classresult">result</a> <a href="#transit1">transit</a>();
  1651. template&lt;
  1652. class DestinationState,
  1653. class TransitionContext,
  1654. class Event &gt;
  1655. <a href="#Classresult">result</a> <a href="#transit2">transit</a>(
  1656. void ( TransitionContext::* )( const Event &amp; ),
  1657. const Event &amp; );
  1658. <a href="#Classresult">result</a> <a href=
  1659. "#simple_state::terminate">terminate</a>();
  1660. template&lt;
  1661. class HistoryContext,
  1662. <i>implementation-defined-unsigned-integer-type
  1663. </i> orthogonalPosition &gt;
  1664. void <a href="#clear_shallow_history">clear_shallow_history</a>();
  1665. template&lt;
  1666. class HistoryContext,
  1667. <i>implementation-defined-unsigned-integer-type
  1668. </i> orthogonalPosition &gt;
  1669. void <a href="#clear_deep_history">clear_deep_history</a>();
  1670. static id_type <a href="#static_type">static_type</a>();
  1671. template&lt; class CustomId &gt;
  1672. static const CustomId * <a href=
  1673. "#custom_static_type_ptr">custom_static_type_ptr</a>();
  1674. template&lt; class CustomId &gt;
  1675. static void <a href=
  1676. "#custom_static_type_ptr1">custom_static_type_ptr</a>( const CustomId * );
  1677. // see <a href="#transit1">transit</a>() or <a href=
  1678. "#simple_state::terminate">terminate</a>() effects
  1679. void exit() {}
  1680. protected:
  1681. <a href="#simple_state">simple_state</a>();
  1682. <a href="#simple_statedtor">~simple_state</a>();
  1683. };
  1684. }
  1685. }
  1686. </pre>
  1687. <h3>Class template <code>simple_state</code> constructor and
  1688. destructor</h3>
  1689. <pre>
  1690. <a name="simple_state" id="simple_state">simple_state</a>();
  1691. </pre>
  1692. <p><b>Effects</b>: Constructs a state object</p>
  1693. <pre>
  1694. <a name="simple_statedtor" id="simple_statedtor">~simple_state</a>();
  1695. </pre>
  1696. <p><b>Effects</b>: If the state has deferral reactions of which at least
  1697. one has been triggered during the lifetime of the state then the contents
  1698. of the deferred events queue is moved to the front of the posted events
  1699. queue.</p>
  1700. <h3>Class template <code>simple_state</code> modifier functions</h3>
  1701. <pre>
  1702. void <a name="post_event0" id="post_event0">post_event</a>(
  1703. const intrusive_ptr&lt; const <a href=
  1704. "#Classevent_base">event_base</a> &gt; &amp; pEvt );
  1705. </pre>
  1706. <p><b>Requires</b>: If called from a constructor of a direct or indirect
  1707. subtype then the most-derived type must directly or indirectly derive from
  1708. the <code>state</code> class template<b>.</b> All direct and indirect
  1709. callers must be exception-neutral<b><br>
  1710. Effects</b>: <a href=
  1711. "#outermost_context"><code>outermost_context</code></a><code>().<a href=
  1712. "#post_event2">post_event</a>( pEvt );</code><br>
  1713. <b>Throws</b>: Whatever the above call throws</p>
  1714. <pre>
  1715. void <a name="post_event1" id="post_event1">post_event</a>( const <a href=
  1716. "#Classevent_base">event_base</a> &amp; evt );
  1717. </pre>
  1718. <p><b>Requires</b>: If called from a constructor of a direct or indirect
  1719. subtype then the most-derived type must directly or indirectly derive from
  1720. the <code>state</code> class template<b>.</b> All direct and indirect
  1721. callers must be exception-neutral<b><br>
  1722. Effects</b>: <a href=
  1723. "#outermost_context"><code>outermost_context</code></a><code>().<a href=
  1724. "#post_event3">post_event</a>( evt );</code><br>
  1725. <b>Throws</b>: Whatever the above call throws</p>
  1726. <pre>
  1727. <a href="#Classresult">result</a> <a name="discard_event" id=
  1728. "discard_event">discard_event</a>();
  1729. </pre>
  1730. <p><b>Requires</b>: Must only be called from within <code>react</code>
  1731. member functions, which are called by <code><a href=
  1732. "#ClassTemplatecustom_reaction">custom_reaction&lt;&gt;</a></code>
  1733. instantiations. All direct and indirect callers must be
  1734. exception-neutral<br>
  1735. <b>Effects</b>: Instructs the state machine to discard the current event
  1736. and to continue with the processing of the remaining events (see
  1737. <code><a href=
  1738. "#process_event">state_machine&lt;&gt;::process_event</a>()</code> for
  1739. details)<br>
  1740. <b>Returns</b>: A <code><a href="#Classresult">result</a></code> object.
  1741. The user-supplied <code>react</code> member function must return this
  1742. object to its caller</p>
  1743. <pre>
  1744. <a href="#Classresult">result</a> <a name="forward_event" id=
  1745. "forward_event">forward_event</a>();
  1746. </pre>
  1747. <p><b>Requires</b>: Must only be called from within <code>react</code>
  1748. member functions, which are called by <code><a href=
  1749. "#ClassTemplatecustom_reaction">custom_reaction&lt;&gt;</a></code>
  1750. instantiations. All direct and indirect callers must be
  1751. exception-neutral<br>
  1752. <b>Effects</b>: Instructs the state machine to forward the current event to
  1753. the next state (see <code><a href=
  1754. "#process_event">state_machine&lt;&gt;::process_event</a>()</code> for
  1755. details)<br>
  1756. <b>Returns</b>: A <code><a href="#Classresult">result</a></code> object.
  1757. The user-supplied <code>react</code> member function must return this
  1758. object to its caller</p>
  1759. <pre>
  1760. <a href="#Classresult">result</a> <a name="defer_event" id=
  1761. "defer_event">defer_event</a>();
  1762. </pre>
  1763. <p><b>Requires</b>: Must only be called from within <code>react</code>
  1764. member functions, which are called by <code><a href=
  1765. "#ClassTemplatecustom_reaction">custom_reaction&lt;&gt;</a></code>
  1766. instantiations. All direct and indirect callers must be
  1767. exception-neutral<br>
  1768. <b>Effects</b>: Instructs the state machine to defer the current event and
  1769. to continue with the processing of the remaining events (see <code><a href=
  1770. "#process_event">state_machine&lt;&gt;::process_event</a>()</code> for
  1771. details)<br>
  1772. <b>Returns</b>: A <code><a href="#Classresult">result</a></code> object.
  1773. The user-supplied <code>react</code> member function must return this
  1774. object to its caller<br>
  1775. <b>Throws</b>: Any exceptions propagated from
  1776. <code>Allocator::rebind&lt;&gt;::other::allocate()</code> (the template
  1777. parameter passed to the base class of
  1778. <code>outermost_context_type</code>)</p>
  1779. <pre>
  1780. template&lt; class DestinationState &gt;
  1781. <a href="#Classresult">result</a> <a name="transit1" id=
  1782. "transit1">transit</a>();
  1783. </pre>
  1784. <p><b>Requires</b>: Must only be called from within <code>react</code>
  1785. member functions, which are called by <code><a href=
  1786. "#ClassTemplatecustom_reaction">custom_reaction&lt;&gt;</a></code>
  1787. instantiations. All direct and indirect callers must be
  1788. exception-neutral<br>
  1789. <b>Effects</b>:</p>
  1790. <ol>
  1791. <li>Exits all currently active direct and indirect inner states of the
  1792. innermost common context of this state and <code>DestinationState</code>.
  1793. Innermost states are exited first. Other states are exited as soon as all
  1794. their direct and indirect inner states have been exited. The inner states
  1795. of each state are exited according to the number of their orthogonal
  1796. region. The state in the orthogonal region with the highest number is
  1797. always exited first, then the state in the region with the second-highest
  1798. number and so on.<br>
  1799. The process of exiting a state consists of the following steps:
  1800. <ol>
  1801. <li>If there is an exception pending that has not yet been handled
  1802. successfully then only step 5 is executed</li>
  1803. <li>Calls the <code>exit</code> member function (see <a href=
  1804. "#ClassTemplatesimple_state">synopsis</a>) of the most-derived state
  1805. object. If <code>exit()</code> throws then steps 3 and 4 are not
  1806. executed</li>
  1807. <li>If the state has shallow history then shallow history information
  1808. is saved</li>
  1809. <li>If the state is an innermost state then deep history information
  1810. is saved for all direct and indirect outer states that have deep
  1811. history</li>
  1812. <li>The state object is destructed</li>
  1813. </ol>
  1814. </li>
  1815. <li>Enters (constructs) the state that is both a direct inner state of
  1816. the innermost common context and either the <code>DestinationState</code>
  1817. itself or a direct or indirect outer state of
  1818. <code>DestinationState</code></li>
  1819. <li>Enters (constructs) the tree formed by the direct and indirect inner
  1820. states of the previously entered state down to the
  1821. <code>DestinationState</code> and beyond depth first. The inner states of
  1822. each state are entered according to the number of their orthogonal
  1823. region. The state in orthogonal region 0 is always entered first, then
  1824. the state in region 1 and so on</li>
  1825. <li>Instructs the state machine to discard the current event and to
  1826. continue with the processing of the remaining events (see <code><a href=
  1827. "#process_event">state_machine&lt;&gt;::process_event</a>()</code> for
  1828. details)</li>
  1829. </ol>
  1830. <p><b>Returns</b>: A <code><a href="#Classresult">result</a></code> object.
  1831. The user-supplied <code>react</code> member function must return this
  1832. object to its caller<br>
  1833. <b>Throws</b>: Any exceptions propagated from:</p>
  1834. <ul>
  1835. <li><code>Allocator::rebind&lt;&gt;::other::allocate()</code> (the
  1836. template parameter passed to the base class of
  1837. <code>outermost_context_type</code>)</li>
  1838. <li>state constructors</li>
  1839. <li><code>exit</code> member functions</li>
  1840. </ul>
  1841. <p><b>Caution</b>: Inevitably destructs this state before returning to the
  1842. calling <code>react</code> member function, which must therefore not
  1843. attempt to access anything except stack objects before returning to its
  1844. caller</p>
  1845. <pre>
  1846. template&lt;
  1847. class DestinationState,
  1848. class TransitionContext,
  1849. class Event &gt;
  1850. <a href="#Classresult">result</a> <a name="transit2" id=
  1851. "transit2">transit</a>(
  1852. void ( TransitionContext::* )( const Event &amp; ),
  1853. const Event &amp; );
  1854. </pre>
  1855. <p><b>Requires</b>: Must only be called from within <code>react</code>
  1856. member functions, which are called by <code><a href=
  1857. "#ClassTemplatecustom_reaction">custom_reaction&lt;&gt;</a></code>
  1858. instantiations. All direct and indirect callers must be
  1859. exception-neutral<br>
  1860. <b>Effects</b>:</p>
  1861. <ol>
  1862. <li>Exits all currently active direct and indirect inner states of the
  1863. innermost common context of this state and <code>DestinationState</code>.
  1864. Innermost states are exited first. Other states are exited as soon as all
  1865. their direct and indirect inner states have been exited. The inner states
  1866. of each state are exited according to the number of their orthogonal
  1867. region. The state in the orthogonal region with the highest number is
  1868. always exited first, then the state in the region with the second-highest
  1869. number and so on.<br>
  1870. The process of exiting a state consists of the following steps:
  1871. <ol>
  1872. <li>If there is an exception pending that has not yet been handled
  1873. successfully then only step 5 is executed</li>
  1874. <li>Calls the <code>exit</code> member function (see <a href=
  1875. "#ClassTemplatesimple_state">synopsis</a>) of the most-derived state
  1876. object. If <code>exit()</code> throws then steps 3 and 4 are not
  1877. executed</li>
  1878. <li>If the state has shallow history then shallow history information
  1879. is saved</li>
  1880. <li>If the state is an innermost state then deep history information
  1881. is saved for all direct and indirect outer states that have deep
  1882. history</li>
  1883. <li>The state object is destructed</li>
  1884. </ol>
  1885. </li>
  1886. <li>Executes the passed transition action, forwarding the passed
  1887. event</li>
  1888. <li>Enters (constructs) the state that is both a direct inner state of
  1889. the innermost common context and either the <code>DestinationState</code>
  1890. itself or a direct or indirect outer state of
  1891. <code>DestinationState</code></li>
  1892. <li>Enters (constructs) the tree formed by the direct and indirect inner
  1893. states of the previously entered state down to the
  1894. <code>DestinationState</code> and beyond depth first. The inner states of
  1895. each state are entered according to the number of their orthogonal
  1896. region. The state in orthogonal region 0 is always entered first, then
  1897. the state in region 1 and so on</li>
  1898. <li>Instructs the state machine to discard the current event and to
  1899. continue with the processing of the remaining events (see <code><a href=
  1900. "#process_event">state_machine&lt;&gt;::process_event</a>()</code> for
  1901. details)</li>
  1902. </ol>
  1903. <p><b>Returns</b>: A <code><a href="#Classresult">result</a></code> object.
  1904. The user-supplied <code>react</code> member function must return this
  1905. object to its caller<br>
  1906. <b>Throws</b>: Any exceptions propagated from:</p>
  1907. <ul>
  1908. <li><code>Allocator::rebind&lt;&gt;::other::allocate()</code> (the
  1909. template parameter passed to the base class of
  1910. <code>outermost_context_type</code>)</li>
  1911. <li>state constructors</li>
  1912. <li><code>exit</code> member functions</li>
  1913. <li>the transition action</li>
  1914. </ul>
  1915. <p><b>Caution</b>: Inevitably destructs this state before returning to the
  1916. calling <code>react</code> member function, which must therefore not
  1917. attempt to access anything except stack objects before returning to its
  1918. caller</p>
  1919. <pre>
  1920. <a href="#Classresult">result</a> <a name="simple_state::terminate" id=
  1921. "simple_state::terminate">terminate</a>();
  1922. </pre>
  1923. <p><b>Requires</b>: Must only be called from within <code>react</code>
  1924. member functions, which are called by <code><a href=
  1925. "#ClassTemplatecustom_reaction">custom_reaction&lt;&gt;</a></code>
  1926. instantiations. All direct and indirect callers must be
  1927. exception-neutral<br>
  1928. <b>Effects</b>: Exits this state and all its direct and indirect inner
  1929. states. Innermost states are exited first. Other states are exited as soon
  1930. as all their direct and indirect inner states have been exited. The inner
  1931. states of each state are exited according to the number of their orthogonal
  1932. region. The state in the orthogonal region with the highest number is
  1933. always exited first, then the state in the region with the second-highest
  1934. number and so on.<br>
  1935. The process of exiting a state consists of the following steps:</p>
  1936. <ol>
  1937. <li>If there is an exception pending that has not yet been handled
  1938. successfully then only step 5 is executed</li>
  1939. <li>Calls the <code>exit</code> member function (see <a href=
  1940. "#ClassTemplatesimple_state">synopsis</a>) of the most-derived state
  1941. object. If <code>exit()</code> throws then steps 3 and 4 are not
  1942. executed</li>
  1943. <li>If the state has shallow history then shallow history information is
  1944. saved</li>
  1945. <li>If the state is an innermost state then deep history information is
  1946. saved for all direct and indirect outer states that have deep
  1947. history</li>
  1948. <li>The state object is destructed</li>
  1949. </ol>
  1950. <p>Also instructs the state machine to discard the current event and to
  1951. continue with the processing of the remaining events (see <code><a href=
  1952. "#process_event">state_machine&lt;&gt;::process_event</a>()</code> for
  1953. details)<br>
  1954. <b>Returns</b>: A <code><a href="#Classresult">result</a></code> object.
  1955. The user-supplied <code>react</code> member function must return this
  1956. object to its caller<br>
  1957. <b>Throws</b>: Any exceptions propagated from:</p>
  1958. <ul>
  1959. <li><code>Allocator::rebind&lt;&gt;::other::allocate()</code> (the
  1960. template parameter passed to the base class of
  1961. <code>outermost_context_type</code>, used to allocate space to save
  1962. history)</li>
  1963. <li><code>exit</code> member functions</li>
  1964. </ul>
  1965. <p><b>Note</b>: If this state is the only currently active inner state of
  1966. its direct outer state then the direct outer state is terminated also. The
  1967. same applies recursively for all indirect outer states<br>
  1968. <b>Caution</b>: Inevitably destructs this state before returning to the
  1969. calling <code>react</code> member function, which must therefore not
  1970. attempt to access anything except stack objects before returning to its
  1971. caller</p>
  1972. <pre>
  1973. template&lt;
  1974. class HistoryContext,
  1975. <i>implementation-defined-unsigned-integer-type
  1976. </i> orthogonalPosition &gt;
  1977. void <a name="clear_shallow_history" id=
  1978. "clear_shallow_history">clear_shallow_history</a>();
  1979. </pre>
  1980. <p><b>Requires</b>: If called from a constructor of a direct or indirect
  1981. subtype then the most-derived type must directly or indirectly derive from
  1982. the <code>state</code> class template. The <code>historyMode</code>
  1983. argument passed to the <code><a href=
  1984. "#ClassTemplatesimple_state">simple_state&lt;&gt;</a></code> or
  1985. <code><a href="#ClassTemplatestate">state&lt;&gt;</a></code> base
  1986. of&nbsp;<code>HistoryContext</code> must be equal to
  1987. <code>has_shallow_history</code> or <code>has_full_history</code><br>
  1988. <b>Effects</b>: Clears the shallow history of the orthogonal region
  1989. specified by <code>orthogonalPosition</code> of the state specified by
  1990. <code>HistoryContext</code><br>
  1991. <b>Throws</b>: Any exceptions propagated from
  1992. <code>Allocator::rebind&lt;&gt;::other::allocate()</code> (the template
  1993. parameter passed to the base class of
  1994. <code>outermost_context_type</code>)</p>
  1995. <pre>
  1996. template&lt;
  1997. class HistoryContext,
  1998. <i>implementation-defined-unsigned-integer-type
  1999. </i> orthogonalPosition &gt;
  2000. void <a name="clear_deep_history" id=
  2001. "clear_deep_history">clear_deep_history</a>();
  2002. </pre>
  2003. <p><b>Requires</b>: If called from a constructor of a direct or indirect
  2004. subtype then the most-derived type must directly or indirectly derive from
  2005. the <code>state</code> class template. The <code>historyMode</code>
  2006. argument passed to the <code><a href=
  2007. "#ClassTemplatesimple_state">simple_state&lt;&gt;</a></code> or
  2008. <code><a href="#ClassTemplatestate">state&lt;&gt;</a></code> base
  2009. of&nbsp;<code>HistoryContext</code> must be equal to
  2010. <code>has_deep_history</code> or <code>has_full_history</code><br>
  2011. <b>Effects</b>: Clears the deep history of the orthogonal region specified
  2012. by <code>orthogonalPosition</code> of the state specified by
  2013. <code>HistoryContext</code><br>
  2014. <b>Throws</b>: Any exceptions propagated from
  2015. <code>Allocator::rebind&lt;&gt;::other::allocate()</code> (the template
  2016. parameter passed to the base class of
  2017. <code>outermost_context_type</code>)</p>
  2018. <h3>Class template <code>simple_state</code> observer functions</h3>
  2019. <pre>
  2020. outermost_context_type &amp; <a name="outermost_context" id=
  2021. "outermost_context">outermost_context</a>();
  2022. </pre>
  2023. <p><b>Requires</b>: If called from a constructor of a direct or indirect
  2024. subtype then the most-derived type must directly or indirectly derive from
  2025. the <code>state</code> class template. If called from a destructor of a
  2026. direct or indirect subtype then the <code>state_machine&lt;&gt;</code> subclass
  2027. portion must still exist<br>
  2028. <b>Returns</b>: A reference to the outermost context, which is always the
  2029. state machine this state belongs to<br></p>
  2030. <pre>
  2031. const outermost_context_type &amp; <a name="outermost_contextconst" id=
  2032. "outermost_contextconst">outermost_context() const</a>;
  2033. </pre>
  2034. <p><b>Requires</b>: If called from a constructor of a direct or indirect
  2035. subtype then the most-derived type must directly or indirectly derive from
  2036. the <code>state</code> class template. If called from a destructor of a
  2037. direct or indirect subtype then the <code>state_machine&lt;&gt;</code> subclass
  2038. portion must still exist<br>
  2039. <b>Returns</b>: A reference to the const outermost context, which is always
  2040. the state machine this state belongs to</p>
  2041. <pre>
  2042. template&lt; class OtherContext &gt;
  2043. OtherContext &amp; <a name="context" id="context">context</a>();
  2044. </pre>
  2045. <p><b>Requires</b>: If called from a constructor of a direct or indirect
  2046. subtype then the most-derived type must directly or indirectly derive from
  2047. the <code>state</code> class template. If called from a destructor of a
  2048. direct or indirect subtype with a <code>state_machine&lt;&gt;</code> subtype as
  2049. argument then the <code>state_machine&lt;&gt;</code> subclass portion must still
  2050. exist<br>
  2051. <b>Returns</b>: A reference to a direct or indirect context or any public base
  2052. type of the contexts</p>
  2053. <pre>
  2054. template&lt; class OtherContext &gt;
  2055. const OtherContext &amp; <a name="contextconst" id=
  2056. "contextconst">context() const</a>;
  2057. </pre>
  2058. <p><b>Requires</b>: If called from a constructor of a direct or indirect
  2059. subtype then the most-derived type must directly or indirectly derive from
  2060. the <code>state</code> class template. If called from a destructor of a
  2061. direct or indirect subtype with a <code>state_machine&lt;&gt;</code> subtype as
  2062. argument then the <code>state_machine&lt;&gt;</code> subclass portion must still
  2063. exist<br>
  2064. <b>Returns</b>: A reference to a const direct or indirect context or any public
  2065. base type of the contexts</p>
  2066. <pre>
  2067. template&lt; class Target &gt;
  2068. Target <a name="simple_state::state_cast" id=
  2069. "simple_state::state_cast">state_cast</a>() const;
  2070. </pre>
  2071. <p><b>Requires</b>: If called from a constructor of a direct or indirect
  2072. subtype then the most-derived type must directly or indirectly derive from
  2073. the <code>state</code> class template<b><br>
  2074. Returns</b>: Has exactly the same semantics as <code><a href=
  2075. "#state_cast">state_machine&lt;&gt;::state_cast</a>&lt;&gt;()</code><br>
  2076. <b>Throws</b>: Has exactly the same semantics as <code><a href=
  2077. "#state_cast">state_machine&lt;&gt;::state_cast</a>&lt;&gt;()</code><b><br>
  2078. Note</b>: The result is <b>unspecified</b> if this function is called when
  2079. the machine is <a href=
  2080. "definitions.html#UnstableStateMachine">unstable</a></p>
  2081. <pre>
  2082. template&lt; class Target &gt;
  2083. Target <a name="simple_state::state_downcast" id=
  2084. "simple_state::state_downcast">state_downcast</a>() const;
  2085. </pre>
  2086. <p><b>Requires</b>: If called from a constructor of a direct or indirect
  2087. subtype then the most-derived type must directly or indirectly derive from
  2088. the <code>state</code> class template. Moreover, <code><a href=
  2089. "#state_downcast">state_machine&lt;&gt;::state_downcast</a>&lt;&gt;()</code>
  2090. requirements also apply<br>
  2091. <b>Returns</b>: Has exactly the same semantics as <code><a href=
  2092. "#state_downcast">state_machine&lt;&gt;::state_downcast</a>&lt;&gt;()</code><br>
  2093. <b>Throws</b>: Has exactly the same semantics as <code><a href=
  2094. "#state_downcast">state_machine&lt;&gt;::state_downcast</a>&lt;&gt;()</code><b><br>
  2095. Note</b>: The result is <b>unspecified</b> if this function is called when
  2096. the machine is <a href=
  2097. "definitions.html#UnstableStateMachine">unstable</a></p>
  2098. <pre>
  2099. state_iterator <a name="simple_state::state_begin" id=
  2100. "simple_state::state_begin">state_begin</a>() const;
  2101. </pre>
  2102. <pre>
  2103. state_iterator <a name="simple_state::state_end" id=
  2104. "simple_state::state_end">state_end</a>() const;
  2105. </pre>
  2106. <p><b>Require</b>: If called from a constructor of a direct or indirect
  2107. subtype then the most-derived type must directly or indirectly derive from
  2108. the <code>state</code> class template<b><br>
  2109. Return</b>: Have exactly the same semantics as <code><a href=
  2110. "#state_begin">state_machine&lt;&gt;::state_begin</a>()</code> and
  2111. <code><a href=
  2112. "#state_end">state_machine&lt;&gt;::state_end</a>()</code><br>
  2113. <b>Note</b>: The result is <b>unspecified</b> if these functions are called
  2114. when the machine is <a href=
  2115. "definitions.html#UnstableStateMachine">unstable</a></p>
  2116. <pre>
  2117. const event_base * <a name="triggering_event0" id="triggering_event0">triggering_event</a>();
  2118. </pre>
  2119. <p><b>Returns</b>: Has exactly the same semantics as
  2120. <code><a href="#triggering_event1">state_machine&lt;&gt;::triggering_event</a>()</code></p>
  2121. <h3>Class template <code>simple_state</code> static functions</h3>
  2122. <pre>
  2123. static id_type <a name="static_type" id="static_type">static_type</a>();
  2124. </pre>
  2125. <p><b>Returns</b>: A value unambiguously identifying the type of
  2126. <code>MostDerived</code><br>
  2127. <b>Note</b>: <code>id_type</code> values are comparable with
  2128. <code>operator==()</code> and <code>operator!=()</code>. An unspecified
  2129. collating order can be established with <code>std::less&lt; id_type
  2130. &gt;</code></p>
  2131. <pre>
  2132. template&lt; class CustomId &gt;
  2133. static const CustomId * <a name="custom_static_type_ptr" id=
  2134. "custom_static_type_ptr">custom_static_type_ptr</a>();
  2135. </pre>
  2136. <p><b>Requires</b>: If a custom type identifier has been set then
  2137. <code>CustomId</code> must match the type of the previously set
  2138. pointer<b><br>
  2139. Returns</b>: The pointer to the custom type identifier for
  2140. <code>MostDerived</code> or <code>0</code><br>
  2141. <b>Note</b>: This function is not available if <a href=
  2142. "configuration.html#ApplicationDefinedMacros"><code>BOOST_STATECHART_USE_NATIVE_RTTI</code></a>
  2143. is defined</p>
  2144. <pre>
  2145. template&lt; class CustomId &gt;
  2146. static void <a name="custom_static_type_ptr1" id=
  2147. "custom_static_type_ptr1">custom_static_type_ptr( const CustomId * )</a>;
  2148. </pre>
  2149. <p><b>Effects</b>: Sets the pointer to the custom type identifier for
  2150. <code>MostDerived</code><br>
  2151. <b>Note</b>: This function is not available if <a href=
  2152. "configuration.html#ApplicationDefinedMacros"><code>BOOST_STATECHART_USE_NATIVE_RTTI</code></a>
  2153. is defined</p>
  2154. <h1>Header &lt;boost/statechart/<a name="state.hpp" id=
  2155. "state.hpp">state.hpp</a>&gt;</h1>
  2156. <h2><a name="ClassTemplatestate" id="ClassTemplatestate">Class template
  2157. <code>state</code></a></h2>
  2158. <p>This is the base class template for all models of the <a href=
  2159. "#State">State</a> concept. Such models typically need to call at least one
  2160. of the following <code><a href=
  2161. "#ClassTemplatesimple_state">simple_state&lt;&gt;</a></code> member
  2162. functions from their constructors:</p>
  2163. <pre>
  2164. void <b>post_event</b>(
  2165. const intrusive_ptr&lt; const event_base &gt; &amp; );
  2166. void <b>post_event</b>( const event_base &amp; );
  2167. template&lt;
  2168. class HistoryContext,
  2169. <i>implementation-defined-unsigned-integer-type
  2170. </i> orthogonalPosition &gt;
  2171. void <b>clear_shallow_history</b>();
  2172. template&lt;
  2173. class HistoryContext,
  2174. <i>implementation-defined-unsigned-integer-type
  2175. </i> orthogonalPosition &gt;
  2176. void <b>clear_deep_history</b>();
  2177. outermost_context_type &amp; <b>outermost_context</b>();
  2178. const outermost_context_type &amp; <b>outermost_context</b>() const;
  2179. template&lt; class OtherContext &gt;
  2180. OtherContext &amp; <b>context</b>();
  2181. template&lt; class OtherContext &gt;
  2182. const OtherContext &amp; <b>context</b>() const;
  2183. template&lt; class Target &gt;
  2184. Target <b>state_cast</b>() const;
  2185. template&lt; class Target &gt;
  2186. Target <b>state_downcast</b>() const;
  2187. state_iterator <b>state_begin</b>() const;
  2188. state_iterator <b>state_end</b>() const;
  2189. const event_base * <b>triggering_event</b>() const;
  2190. </pre>
  2191. <p>States that do not need to call any of these member functions from their
  2192. constructors should rather derive from the <code><a href=
  2193. "#ClassTemplatesimple_state">simple_state</a></code> class template, what
  2194. saves the implementation of the forwarding constructor.</p>
  2195. <h3>Class template <code>state</code> synopsis</h3>
  2196. <pre>
  2197. namespace boost
  2198. {
  2199. namespace statechart
  2200. {
  2201. template&lt;
  2202. class MostDerived,
  2203. class Context,
  2204. class InnerInitial = <i>unspecified</i>,
  2205. history_mode historyMode = has_no_history &gt;
  2206. class state : public simple_state&lt;
  2207. MostDerived, Context, InnerInitial, historyMode &gt;
  2208. {
  2209. protected:
  2210. struct my_context
  2211. {
  2212. // <i>implementation-defined</i>
  2213. };
  2214. typedef state my_base;
  2215. state( my_context ctx );
  2216. ~state();
  2217. };
  2218. }
  2219. }
  2220. </pre>
  2221. <p>Direct and indirect subtypes of <code>state&lt;&gt;</code> must provide
  2222. a constructor with the same signature as the <code>state&lt;&gt;</code>
  2223. constructor, forwarding the context parameter.</p>
  2224. <h1>Header &lt;boost/statechart/<a name="shallow_history.hpp" id=
  2225. "shallow_history.hpp">shallow_history.hpp</a>&gt;</h1>
  2226. <h2><a name="ClassTemplateshallow_history" id=
  2227. "ClassTemplateshallow_history">Class template
  2228. <code>shallow_history</code></a></h2>
  2229. <p>This class template is used to specify a shallow history transition
  2230. target or a shallow history inner initial state.</p>
  2231. <h3>Class template <code>shallow_history</code> parameters</h3>
  2232. <table border="3" cellpadding="2" width="100%" summary=
  2233. "shallow_history parameters">
  2234. <tr>
  2235. <td><b>Template parameter</b></td>
  2236. <td><b>Requirements</b></td>
  2237. <td><b>Semantics</b></td>
  2238. </tr>
  2239. <tr>
  2240. <td><code>DefaultState</code></td>
  2241. <td>A model of the <a href="#SimpleState">SimpleState</a>
  2242. or <a href="#State">State</a> concepts. The type passed as
  2243. <code>Context</code> argument to the <code><a href=
  2244. "#ClassTemplatesimple_state">simple_state&lt;&gt;</a></code> or
  2245. <code><a href="#ClassTemplatestate">state&lt;&gt;</a></code> base
  2246. of&nbsp;<code>DefaultState</code> must itself pass
  2247. <code>has_shallow_history</code> or <code>has_full_history</code> as
  2248. <code>historyMode</code> argument to its <code><a href=
  2249. "#ClassTemplatesimple_state">simple_state&lt;&gt;</a></code> or
  2250. <code><a href="#ClassTemplatestate">state&lt;&gt;</a></code> base</td>
  2251. <td>The state that is entered if shallow history is not available</td>
  2252. </tr>
  2253. </table>
  2254. <h3>Class template <code>shallow_history</code> synopsis</h3>
  2255. <pre>
  2256. namespace boost
  2257. {
  2258. namespace statechart
  2259. {
  2260. template&lt; class DefaultState &gt;
  2261. class shallow_history
  2262. {
  2263. // <i>implementation-defined</i>
  2264. };
  2265. }
  2266. }
  2267. </pre>
  2268. <h1>Header &lt;boost/statechart/<a name="deep_history.hpp" id=
  2269. "deep_history.hpp">deep_history.hpp</a>&gt;</h1>
  2270. <h2><a name="ClassTemplatedeep_history" id=
  2271. "ClassTemplatedeep_history">Class template
  2272. <code>deep_history</code></a></h2>
  2273. <p>This class template is used to specify a deep history transition target
  2274. or a deep history inner initial state. The current deep history
  2275. implementation has some <a href=
  2276. "rationale.html#Limitations">limitations</a>.</p>
  2277. <h3>Class template <code>deep_history</code> parameters</h3>
  2278. <table border="3" cellpadding="2" width="100%" summary=
  2279. "deep_history parameters">
  2280. <tr>
  2281. <td><b>Template parameter</b></td>
  2282. <td><b>Requirements</b></td>
  2283. <td><b>Semantics</b></td>
  2284. </tr>
  2285. <tr>
  2286. <td><code>DefaultState</code></td>
  2287. <td>A model of the <a href="#SimpleState">SimpleState</a>
  2288. or <a href="#State">State</a> concepts. The type passed as
  2289. <code>Context</code> argument to the <code><a href=
  2290. "#ClassTemplatesimple_state">simple_state&lt;&gt;</a></code> or
  2291. <code><a href="#ClassTemplatestate">state&lt;&gt;</a></code> base
  2292. of&nbsp;<code>DefaultState</code> must itself pass
  2293. <code>has_deep_history</code> or <code>has_full_history</code> as
  2294. <code>historyMode</code> argument to its <code><a href=
  2295. "#ClassTemplatesimple_state">simple_state&lt;&gt;</a></code> or
  2296. <code><a href="#ClassTemplatestate">state&lt;&gt;</a></code> base</td>
  2297. <td>The state that is entered if deep history is not available</td>
  2298. </tr>
  2299. </table>
  2300. <h3>Class template <code>deep_history</code> synopsis</h3>
  2301. <pre>
  2302. namespace boost
  2303. {
  2304. namespace statechart
  2305. {
  2306. template&lt; class DefaultState &gt;
  2307. class deep_history
  2308. {
  2309. // <i>implementation-defined</i>
  2310. };
  2311. }
  2312. }
  2313. </pre>
  2314. <h1>Header &lt;boost/statechart/<a name="event_base.hpp" id=
  2315. "event_base.hpp">event_base.hpp</a>&gt;</h1>
  2316. <h2><a name="Classevent_base" id="Classevent_base">Class
  2317. <code>event_base</code></a></h2>
  2318. <p>This is the common base of all events.</p>
  2319. <h3>Class <code>event_base</code> synopsis</h3>
  2320. <pre>
  2321. namespace boost
  2322. {
  2323. namespace statechart
  2324. {
  2325. class event_base
  2326. {
  2327. public:
  2328. intrusive_ptr&lt; const event_base &gt;
  2329. <a href="#intrusive_from_this">intrusive_from_this</a>() const;
  2330. typedef <i>implementation-defined</i> id_type;
  2331. id_type <a href="#event_base::dynamic_type">dynamic_type</a>() const;
  2332. template&lt; typename CustomId &gt;
  2333. const CustomId * <a href=
  2334. "#event_base::custom_dynamic_type_ptr">custom_dynamic_type_ptr</a>() const;
  2335. protected:
  2336. <a href="#event_base">event_base</a>( <i>unspecified-parameter </i>);
  2337. virtual <a href="#event_basedtor">~event_base</a>();
  2338. };
  2339. }
  2340. }
  2341. </pre>
  2342. <h3>Class <code>event_base</code> constructor and destructor</h3>
  2343. <pre>
  2344. <a name="event_base" id=
  2345. "event_base">event_base</a>( <i>unspecified-parameter </i>);
  2346. </pre>
  2347. <p><b>Effects</b>: Constructs the common base portion of an event</p>
  2348. <pre>
  2349. virtual <a name="event_basedtor" id="event_basedtor">~event_base</a>();
  2350. </pre>
  2351. <p><b>Effects</b>: Destructs the common base portion of an event</p>
  2352. <h3>Class <code>event_base</code> observer functions</h3>
  2353. <pre>
  2354. intrusive_ptr&lt; const event_base &gt; <a name="intrusive_from_this" id=
  2355. "intrusive_from_this">intrusive_from_this</a>() const;
  2356. </pre>
  2357. <p><b>Returns</b>: Another <code>intrusive_ptr&lt; const event_base
  2358. &gt;</code> referencing <code>this</code> <b>if</b> <code>this</code> is
  2359. already referenced by an <code>intrusive_ptr&lt;&gt;</code>. Otherwise,
  2360. returns an <code>intrusive_ptr&lt; const event_base &gt;</code> referencing
  2361. a newly created copy of the most-derived object</p>
  2362. <pre>
  2363. id_type <a name="event_base::dynamic_type" id=
  2364. "event_base::dynamic_type">dynamic_type</a>() const;
  2365. </pre>
  2366. <p><b>Returns</b>: A value unambiguously identifying the most-derived
  2367. type<br>
  2368. <b>Note</b>: <code>id_type</code> values are comparable with
  2369. <code>operator==()</code> and <code>operator!=()</code>. An unspecified
  2370. collating order can be established with <code>std::less&lt; id_type
  2371. &gt;</code>. In contrast to <code>typeid( cs )</code>, this function is
  2372. available even on platforms that do not support C++ RTTI (or have been
  2373. configured to not support it)</p>
  2374. <pre>
  2375. template&lt; typename CustomId &gt;
  2376. const CustomId * <a name="event_base::custom_dynamic_type_ptr" id=
  2377. "event_base::custom_dynamic_type_ptr">custom_dynamic_type_ptr</a>() const;
  2378. </pre>
  2379. <p><b>Requires</b>: If a custom type identifier has been set then
  2380. <code>CustomId</code> must match the type of the previously set
  2381. pointer<b><br>
  2382. Returns</b>: A pointer to the custom type identifier or <code>0</code><br>
  2383. <b>Note</b>: This function is not available if <a href=
  2384. "configuration.html#ApplicationDefinedMacros"><code>BOOST_STATECHART_USE_NATIVE_RTTI</code></a>
  2385. is defined</p>
  2386. <h1>Header &lt;boost/statechart/<a name="event.hpp" id=
  2387. "event.hpp">event.hpp</a>&gt;</h1>
  2388. <h2><a name="ClassTemplateevent" id="ClassTemplateevent">Class template
  2389. <code>event</code></a></h2>
  2390. <p>This is the base class template of all events.</p>
  2391. <h3>Class template <code>event</code> parameters</h3>
  2392. <table border="3" cellpadding="2" width="100%" summary="event parameters">
  2393. <tr>
  2394. <td><b>Template parameter</b></td>
  2395. <td><b>Requirements</b></td>
  2396. <td><b>Semantics</b></td>
  2397. <td><b>Default</b></td>
  2398. </tr>
  2399. <tr>
  2400. <td><code>MostDerived</code></td>
  2401. <td>The most-derived subtype of this class template</td>
  2402. <td>&nbsp;</td>
  2403. <td>&nbsp;</td>
  2404. </tr>
  2405. <tr>
  2406. <td><code>Allocator</code></td>
  2407. <td>A model of the standard Allocator concept</td>
  2408. <td><code>Allocator::rebind&lt; MostDerived
  2409. &gt;::other</code> is used to allocate and deallocate all event subtype
  2410. objects of dynamic storage duration, see <code><a href=
  2411. "#event::operatornew">operator new</a></code></td>
  2412. <td><code>std::allocator&lt; void &gt;</code></td>
  2413. </tr>
  2414. </table>
  2415. <h3>Class template <code>event</code> synopsis</h3>
  2416. <pre>
  2417. namespace boost
  2418. {
  2419. namespace statechart
  2420. {
  2421. template&lt; class MostDerived, class Allocator = std::allocator&lt; void &gt; &gt;
  2422. class event : <i>implementation-defined</i>
  2423. {
  2424. public:
  2425. static void * <a href=
  2426. "#event::operatornew">operator new</a>( std::size_t size );
  2427. static void * <a href=
  2428. "#event::operatornew2">operator new</a>( std::size_t size, void * p );
  2429. static void <a href=
  2430. "#event::operatordelete">operator delete</a>( void * pEvent );
  2431. static id_type <a href="#event::static_type">static_type</a>();
  2432. template&lt; class CustomId &gt;
  2433. static const CustomId * <a href=
  2434. "#event::custom_static_type_ptr">custom_static_type_ptr</a>();
  2435. template&lt; class CustomId &gt;
  2436. static void <a href=
  2437. "#event::custom_static_type_ptr1">custom_static_type_ptr</a>( const CustomId * );
  2438. protected:
  2439. <a href="#event::event">event</a>();
  2440. virtual <a href="#eventdtor">~event</a>();
  2441. };
  2442. }
  2443. }
  2444. </pre>
  2445. <h3>Class template <code>event</code> constructor and destructor</h3>
  2446. <pre>
  2447. <a name="event::event" id="event::event">event</a>();
  2448. </pre>
  2449. <p><b>Effects</b>: Constructs an event</p>
  2450. <pre>
  2451. virtual <a name="eventdtor" id="eventdtor">~event</a>();
  2452. </pre>
  2453. <p><b>Effects</b>: Destructs an event</p>
  2454. <h3>Class template <code>event</code> static functions</h3>
  2455. <pre>
  2456. static void * <a name="event::operatornew" id=
  2457. "event::operatornew">operator new</a>( std::size_t size );
  2458. </pre>
  2459. <p><b>Effects</b>: <code>Allocator::rebind&lt; MostDerived
  2460. &gt;::other().allocate( 1, static_cast&lt; MostDerived * &gt;( 0 )
  2461. );</code><br>
  2462. <b>Returns</b>: The return value of the above call<br>
  2463. <b>Throws</b>: Whatever the above call throws</p>
  2464. <pre>
  2465. static void * <a name="event::operatornew2" id=
  2466. "event::operatornew2">operator new</a>( std::size_t size, void * p );
  2467. </pre>
  2468. <p><b>Effects</b>: None<br>
  2469. <b>Returns</b>: <code>p</code></p>
  2470. <pre>
  2471. static void <a name="event::operatordelete" id=
  2472. "event::operatordelete">operator delete</a>( void * pEvent );
  2473. </pre>
  2474. <p><b>Effects</b>: <code>Allocator::rebind&lt; MostDerived
  2475. &gt;::other().deallocate( static_cast&lt; MostDerived * &gt;( pEvent ), 1
  2476. );</code></p>
  2477. <pre>
  2478. static id_type <a name="event::static_type" id=
  2479. "event::static_type">static_type</a>();
  2480. </pre>
  2481. <p><b>Returns</b>: A value unambiguously identifying the type of
  2482. <code>MostDerived</code><br>
  2483. <b>Note</b>: <code>id_type</code> values are comparable with
  2484. <code>operator==()</code> and <code>operator!=()</code>. An unspecified
  2485. collating order can be established with <code>std::less&lt; id_type
  2486. &gt;</code></p>
  2487. <pre>
  2488. template&lt; class CustomId &gt;
  2489. static const CustomId * <a name="event::custom_static_type_ptr" id=
  2490. "event::custom_static_type_ptr">custom_static_type_ptr</a>();
  2491. </pre>
  2492. <p><b>Requires</b>: If a custom type identifier has been set then
  2493. <code>CustomId</code> must match the type of the previously set
  2494. pointer<b><br>
  2495. Returns</b>: The pointer to the custom type identifier for
  2496. <code>MostDerived</code> or <code>0</code><br>
  2497. <b>Note</b>: This function is not available if <a href=
  2498. "configuration.html#ApplicationDefinedMacros"><code>BOOST_STATECHART_USE_NATIVE_RTTI</code></a>
  2499. is defined</p>
  2500. <pre>
  2501. template&lt; class CustomId &gt;
  2502. static void <a name="event::custom_static_type_ptr1" id=
  2503. "event::custom_static_type_ptr1">custom_static_type_ptr( const CustomId * )</a>;
  2504. </pre>
  2505. <p><b>Effects</b>: Sets the pointer to the custom type identifier for
  2506. <code>MostDerived</code><br>
  2507. <b>Note</b>: This function is not available if <a href=
  2508. "configuration.html#ApplicationDefinedMacros"><code>BOOST_STATECHART_USE_NATIVE_RTTI</code></a>
  2509. is defined</p>
  2510. <h1>Header &lt;boost/statechart/<a name="transition.hpp" id=
  2511. "transition.hpp">transition.hpp</a>&gt;</h1>
  2512. <h2><a name="ClassTemplatetransition" id="ClassTemplatetransition">Class
  2513. template <code>transition</code></a></h2>
  2514. <p>This class template is used to specify a transition reaction.
  2515. Instantiations of this template can appear in the <code>reactions</code>
  2516. member <code>typedef</code> in models of the <a href=
  2517. "#SimpleState">SimpleState</a> and <a href="#State">State</a> concepts.</p>
  2518. <h3>Class template <code>transition</code> parameters</h3>
  2519. <table border="3" cellpadding="2" width="100%" summary=
  2520. "transition parameters">
  2521. <tr>
  2522. <td><b>Template parameter</b></td>
  2523. <td><b>Requirements</b></td>
  2524. <td><b>Semantics</b></td>
  2525. <td><b>Default</b></td>
  2526. </tr>
  2527. <tr>
  2528. <td><code>Event</code></td>
  2529. <td>A model of the <a href="#Event">Event</a> concept or
  2530. the class <code><a href="#Classevent_base">event_base</a></code></td>
  2531. <td>The event triggering the transition. If <code><a href=
  2532. "#Classevent_base">event_base</a></code> is specified, the transition
  2533. is triggered by all models of the <a href="#Event">Event</a>
  2534. concept</td>
  2535. <td>&nbsp;</td>
  2536. </tr>
  2537. <tr>
  2538. <td><code>Destination</code></td>
  2539. <td>A model of the <a href="#SimpleState">SimpleState</a>
  2540. or <a href="#State">State</a> concepts, any of their public base types or an instantiation of the
  2541. <code><a href=
  2542. "#ClassTemplateshallow_history">shallow_history</a></code> or
  2543. <code><a href="#ClassTemplatedeep_history">deep_history</a></code>
  2544. class templates. The source state (the state for which this transition
  2545. is defined) and <code>Destination</code> must have a common direct or
  2546. indirect context</td>
  2547. <td>The destination state to make a transition to</td>
  2548. <td>&nbsp;</td>
  2549. </tr>
  2550. <tr>
  2551. <td><code>TransitionContext</code></td>
  2552. <td>A common context of the source and
  2553. <code>Destination</code> state</td>
  2554. <td>The state of which the transition action is a
  2555. member</td>
  2556. <td><i><code>unspecified</code></i></td>
  2557. </tr>
  2558. <tr>
  2559. <td><code>pTransitionAction</code></td>
  2560. <td>A pointer to a member function of
  2561. <code>TransitionContext</code>. The member function must accept a
  2562. <code>const Event &amp;</code> parameter and return
  2563. <code>void</code></td>
  2564. <td>The transition action that is executed during the
  2565. transition. By default no transition action is executed</td>
  2566. <td><i><code>unspecified</code></i></td>
  2567. </tr>
  2568. </table>
  2569. <h3>Class template <code>transition</code> synopsis</h3>
  2570. <pre>
  2571. namespace boost
  2572. {
  2573. namespace statechart
  2574. {
  2575. template&lt;
  2576. class Event,
  2577. class Destination,
  2578. class TransitionContext = <i>unspecified</i>,
  2579. void ( TransitionContext::*pTransitionAction )(
  2580. const Event &amp; ) = <i>unspecified</i> &gt;
  2581. class transition
  2582. {
  2583. // <i>implementation-defined</i>
  2584. };
  2585. }
  2586. }
  2587. </pre>
  2588. <h3>Class template <code>transition</code> semantics</h3>
  2589. <p>When executed, one of the following calls to a member function of the
  2590. state for which the reaction was defined is made:</p>
  2591. <ul>
  2592. <li><code><a href="#transit1">transit&lt; Destination &gt;()</a></code>,
  2593. if no transition action was specified</li>
  2594. <li><code><a href="#transit2">transit&lt; Destination &gt;(
  2595. pTransitionAction, <i>currentEvent</i> )</a></code>, if a transition
  2596. action was specified</li>
  2597. </ul>
  2598. <h1>Header &lt;boost/statechart/<a name="in_state_reaction.hpp" id=
  2599. "in_state_reaction.hpp">in_state_reaction.hpp</a>&gt;</h1>
  2600. <h2><a name="ClassTemplatein_state_reaction" id=
  2601. "ClassTemplatein_state_reaction">Class template
  2602. <code>in_state_reaction</code></a></h2>
  2603. <p>This class template is used to specify an in-state reaction.
  2604. Instantiations of this template can appear in the <code>reactions</code>
  2605. member <code>typedef</code> in models of the <a href=
  2606. "#SimpleState">SimpleState</a> and <a href="#State">State</a> concepts.</p>
  2607. <h3>Class template <code>in_state_reaction</code> parameters</h3>
  2608. <table border="3" cellpadding="2" width="100%" summary=
  2609. "in_state_reaction parameters">
  2610. <tr>
  2611. <td><b>Template parameter</b></td>
  2612. <td><b>Requirements</b></td>
  2613. <td><b>Semantics</b></td>
  2614. <td><b>Default</b></td>
  2615. </tr>
  2616. <tr>
  2617. <td><code>Event</code></td>
  2618. <td>A model of the <a href="#Event">Event</a> concept or
  2619. the class <code><a href="#Classevent_base">event_base</a></code></td>
  2620. <td>The event triggering the in-state reaction. If
  2621. <code><a href="#Classevent_base">event_base</a></code> is specified,
  2622. the in-state reaction is triggered by all models of the <a href=
  2623. "#Event">Event</a> concept</td>
  2624. <td>&nbsp;</td>
  2625. </tr>
  2626. <tr>
  2627. <td><code>ReactionContext</code></td>
  2628. <td>Either the state defining the in-state reaction itself, one of its direct or indirect contexts
  2629. or any of their public base types</td>
  2630. <td>The state of which the action is a member</td>
  2631. <td><i><code>unspecified</code></i></td>
  2632. </tr>
  2633. <tr>
  2634. <td><code>pAction</code></td>
  2635. <td>A pointer to a member function of
  2636. <code>ReactionContext</code>. The member function must accept a
  2637. <code>const Event &amp;</code> parameter and return
  2638. <code>void</code></td>
  2639. <td>The action that is executed during the in-state
  2640. reaction</td>
  2641. <td><i><code>unspecified</code></i></td>
  2642. </tr>
  2643. </table>
  2644. <h3>Class template <code>in_state_reaction</code> synopsis</h3>
  2645. <pre>
  2646. namespace boost
  2647. {
  2648. namespace statechart
  2649. {
  2650. template&lt;
  2651. class Event,
  2652. class ReactionContext = <i>unspecified</i>,
  2653. void ( ReactionContext::*pAction )(
  2654. const Event &amp; ) = <i>unspecified</i> &gt;
  2655. class in_state_reaction
  2656. {
  2657. // <i>implementation-defined</i>
  2658. };
  2659. }
  2660. }
  2661. </pre>
  2662. <h3>Class template <code>in_state_reaction</code> semantics</h3>
  2663. <p>When executed then the following happens:</p>
  2664. <ol>
  2665. <li>If an action was specified, <code>pAction</code> is called, passing
  2666. the triggering event as the only argument</li>
  2667. <li>A call is made to the <code><a href="#discard_event">discard_event</a>
  2668. </code> member function of the state for which the reaction was defined
  2669. </li>
  2670. </ol>
  2671. <h1>Header &lt;boost/statechart/<a name="termination.hpp" id=
  2672. "termination.hpp">termination.hpp</a>&gt;</h1>
  2673. <h2><a name="ClassTemplatetermination" id="ClassTemplatetermination">Class
  2674. template <code>termination</code></a></h2>
  2675. <p>This class template is used to specify a termination reaction.
  2676. Instantiations of this template can appear in the <code>reactions</code>
  2677. member <code>typedef</code> in models of the <a href=
  2678. "#SimpleState">SimpleState</a> and <a href="#State">State</a> concepts.</p>
  2679. <h3>Class template <code>termination</code> parameters</h3>
  2680. <table border="3" cellpadding="2" width="100%" summary=
  2681. "termination parameters">
  2682. <tr>
  2683. <td><b>Template parameter</b></td>
  2684. <td><b>Requirements</b></td>
  2685. <td><b>Semantics</b></td>
  2686. </tr>
  2687. <tr>
  2688. <td><code>Event</code></td>
  2689. <td>A model of the <a href="#Event">Event</a> concept or
  2690. the class <code><a href="#Classevent_base">event_base</a></code></td>
  2691. <td>The event triggering the termination. If <code><a href=
  2692. "#Classevent_base">event_base</a></code> is specified, the termination
  2693. is triggered by all models of the <a href="#Event">Event</a>
  2694. concept</td>
  2695. </tr>
  2696. </table>
  2697. <h3>Class template <code>termination</code> synopsis</h3>
  2698. <pre>
  2699. namespace boost
  2700. {
  2701. namespace statechart
  2702. {
  2703. template&lt; class Event &gt;
  2704. class termination
  2705. {
  2706. // <i>implementation-defined</i>
  2707. };
  2708. }
  2709. }
  2710. </pre>
  2711. <h3>Class template <code>termination</code> semantics</h3>
  2712. <p>When executed, a call is made to the <code><a href=
  2713. "#simple_state::terminate">terminate</a></code> member function of the
  2714. state for which the reaction was defined.</p>
  2715. <h1>Header &lt;boost/statechart/<a name="deferral.hpp" id=
  2716. "deferral.hpp">deferral.hpp</a>&gt;</h1>
  2717. <h2><a name="ClassTemplatedeferral" id="ClassTemplatedeferral">Class
  2718. template <code>deferral</code></a></h2>
  2719. <p>This class template is used to specify a deferral reaction.
  2720. Instantiations of this template can appear in the <code>reactions</code>
  2721. member <code>typedef</code> in models of the <a href=
  2722. "#SimpleState">SimpleState</a> and <a href="#State">State</a> concepts.</p>
  2723. <h3>Class template <code>deferral</code> parameters</h3>
  2724. <table border="3" cellpadding="2" width="100%" summary=
  2725. "deferral parameters">
  2726. <tr>
  2727. <td><b>Template parameter</b></td>
  2728. <td><b>Requirements</b></td>
  2729. <td><b>Semantics</b></td>
  2730. </tr>
  2731. <tr>
  2732. <td><code>Event</code></td>
  2733. <td>A model of the <a href="#Event">Event</a> concept or
  2734. the class <code><a href="#Classevent_base">event_base</a></code></td>
  2735. <td>The event triggering the deferral. If <code><a href=
  2736. "#Classevent_base">event_base</a></code> is specified, the deferral is
  2737. triggered by all models of the <a href="#Event">Event</a> concept</td>
  2738. </tr>
  2739. </table>
  2740. <h3>Class template <code>deferral</code> synopsis</h3>
  2741. <pre>
  2742. namespace boost
  2743. {
  2744. namespace statechart
  2745. {
  2746. template&lt; class Event &gt;
  2747. class deferral
  2748. {
  2749. // <i>implementation-defined</i>
  2750. };
  2751. }
  2752. }
  2753. </pre>
  2754. <h3>Class template <code>deferral</code> semantics</h3>
  2755. <p>When executed, a call is made to the <a href=
  2756. "#defer_event"><code>defer_event</code></a> member function of the state
  2757. for which the reaction was defined.</p>
  2758. <h1>Header &lt;boost/statechart/<a name="custom_reaction.hpp" id=
  2759. "custom_reaction.hpp">custom_reaction.hpp</a>&gt;</h1>
  2760. <h2><a name="ClassTemplatecustom_reaction" id=
  2761. "ClassTemplatecustom_reaction">Class template
  2762. <code>custom_reaction</code></a></h2>
  2763. <p>This class template is used to specify a custom reaction. Instantiations
  2764. of this template can appear in the <code>reactions</code> member
  2765. <code>typedef</code> in models of the <a href=
  2766. "#SimpleState">SimpleState</a> and <a href="#State">State</a> concepts.</p>
  2767. <h3>Class template <code>custom_reaction</code> parameters</h3>
  2768. <table border="3" cellpadding="2" width="100%" summary=
  2769. "custom_reaction parameters">
  2770. <tr>
  2771. <td><b>Template parameter</b></td>
  2772. <td><b>Requirements</b></td>
  2773. <td><b>Semantics</b></td>
  2774. </tr>
  2775. <tr>
  2776. <td><code>Event</code></td>
  2777. <td>A model of the <a href="#Event">Event</a> concept or
  2778. the class <code><a href="#Classevent_base">event_base</a></code></td>
  2779. <td>The event triggering the custom reaction. If
  2780. <code><a href="#Classevent_base">event_base</a></code> is specified,
  2781. the custom reaction is triggered by all models of the <a href=
  2782. "#Event">Event</a> concept</td>
  2783. </tr>
  2784. </table>
  2785. <h3>Class template <code>custom_reaction</code> synopsis</h3>
  2786. <pre>
  2787. namespace boost
  2788. {
  2789. namespace statechart
  2790. {
  2791. template&lt; class Event &gt;
  2792. class custom_reaction
  2793. {
  2794. // <i>implementation-defined</i>
  2795. };
  2796. }
  2797. }
  2798. </pre>
  2799. <h3>Class template <code>custom_reaction</code> semantics</h3>
  2800. <p>When executed, a call is made to the user-supplied <code>react</code>
  2801. member function of the state for which the reaction was defined. The
  2802. <code>react</code> member function must have the following signature:</p>
  2803. <pre>
  2804. <a href="#Classresult">result</a> react( const Event &amp; );
  2805. </pre>
  2806. <p>and must call exactly one of the following reaction functions and return
  2807. the obtained <code><a href="#Classresult">result</a></code> object:</p>
  2808. <pre>
  2809. <a href="#Classresult">result</a> <a href=
  2810. "#discard_event">discard_event</a>();
  2811. <a href="#Classresult">result</a> <a href=
  2812. "#forward_event">forward_event</a>();
  2813. <a href="#Classresult">result</a> <a href="#defer_event">defer_event</a>();
  2814. template&lt; class DestinationState &gt;
  2815. <a href="#Classresult">result</a> <a href="#transit1">transit</a>();
  2816. template&lt;
  2817. class DestinationState,
  2818. class TransitionContext,
  2819. class Event &gt;
  2820. <a href="#Classresult">result</a> <a href="#transit2">transit</a>(
  2821. void ( TransitionContext::* )( const Event &amp; ),
  2822. const Event &amp; );
  2823. <a href="#Classresult">result</a> <a href=
  2824. "#simple_state::terminate">terminate</a>();
  2825. </pre>
  2826. <h1>Header &lt;boost/statechart/<a name="result.hpp" id=
  2827. "result.hpp">result.hpp</a>&gt;</h1>
  2828. <h2><a name="Classresult" id="Classresult">Class
  2829. <code>result</code></a></h2>
  2830. <p>Defines the nature of the reaction taken in a user-supplied
  2831. <code>react</code> member function (called when a <code><a href=
  2832. "#ClassTemplatecustom_reaction">custom_reaction</a></code> is executed).
  2833. Objects of this type are always obtained by calling one of the reaction
  2834. functions and must be returned from the <code>react</code> member function
  2835. immediately.</p>
  2836. <pre>
  2837. namespace boost
  2838. {
  2839. namespace statechart
  2840. {
  2841. class result
  2842. {
  2843. public:
  2844. <a href="#result0">result</a>( const result &amp; other );
  2845. <a href="#resultdtor">~result</a>();
  2846. private:
  2847. // Result objects are not assignable
  2848. result &amp; operator=( const result &amp; other );
  2849. };
  2850. }
  2851. }
  2852. </pre>
  2853. <h3>Class <code>result</code> constructor and destructor</h3>
  2854. <pre>
  2855. <a name="result0" id="result0">result</a>( const result &amp; other );
  2856. </pre>
  2857. <p><b>Requires</b>: <code>other</code> is <b>not</b> consumed<br>
  2858. <b>Effects</b>: Copy-constructs a new <code>result</code> object and marks
  2859. <code>other</code> as consumed. That is, <code>result</code> has
  2860. destructive copy semantics</p>
  2861. <pre>
  2862. <a name="resultdtor" id="resultdtor">~result</a>();
  2863. </pre>
  2864. <p><b>Requires</b>: <code>this</code> is marked as consumed<br>
  2865. <b>Effects</b>: Destructs the result object</p>
  2866. <hr>
  2867. <p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src=
  2868. "../../../doc/images/valid-html401.png" alt="Valid HTML 4.01 Transitional"
  2869. height="31" width="88"></a></p>
  2870. <p>Revised 06 November, 2010</p>
  2871. <p><i>Copyright &copy; 2003-2010 <a href="contact.html">Andreas Huber
  2872. D&ouml;nni</a></i></p>
  2873. <p><i>Distributed under the Boost Software License, Version 1.0. (See
  2874. accompanying file <a href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or
  2875. copy at <a href=
  2876. "http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>)</i></p>
  2877. </body>
  2878. </html>