]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/msm/doc/PDF/examples/TestErrorOrthogonality.cpp
1 // Copyright 2010 Christophe Henry
2 // henry UNDERSCORE christophe AT hotmail DOT com
3 // This is an extended version of the state machine available in the boost::mpl library
4 // Distributed under the same license as the original.
5 // Copyright for the original version:
6 // Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed
7 // under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
14 #include <boost/msm/back/state_machine.hpp>
15 #include <boost/msm/back/mpl_graph_fsm_check.hpp>
17 #include <boost/msm/front/state_machine_def.hpp>
19 namespace msm
= boost::msm
;
20 namespace mpl
= boost::mpl
;
21 using namespace msm::back
;
31 struct error_found
{};
33 // front-end: define the FSM structure
34 struct player_
: public msm::front::state_machine_def
<player_
>
36 // The list of FSM states
37 struct Empty
: public msm::front::state
<>
40 struct Open
: public msm::front::state
<>
44 // sm_ptr still supported but deprecated as functors are a much better way to do the same thing
45 struct Stopped
: public msm::front::state
<>
49 struct Playing
: public msm::front::state
<>
53 // state not defining any entry or exit
54 struct Paused
: public msm::front::state
<>
57 struct AllOk
: public msm::front::state
<>
60 struct ErrorMode
: public msm::front::state
<>
63 struct State1
: public msm::front::state
<>
66 struct State2
: public msm::front::state
<>
69 // the initial state of the player SM. Must be defined
70 typedef mpl::vector
<Empty
,AllOk
> initial_state
;
72 // Transition table for player
73 struct transition_table
: mpl::vector
<
74 // Start Event Next Action Guard
75 // +---------+-------------+---------+---------------------+----------------------+
76 // adding this line makes non-reachable states and should cause a static assert
77 //_row < State1 , open_close , State2 >,
78 // adding this line makes non-orthogonal regions and should cause a static assert
79 //_row < Paused , error_found , ErrorMode >,
80 _row
< Stopped
, play
, Playing
>,
81 _row
< Stopped
, open_close
, Open
>,
82 _row
< Stopped
, stop
, Stopped
>,
83 // +---------+-------------+---------+---------------------+----------------------+
84 _row
< Open
, open_close
, Empty
>,
85 // +---------+-------------+---------+---------------------+----------------------+
86 _row
< Empty
, open_close
, Open
>,
87 _row
< Empty
, cd_detected
, Stopped
>,
88 _row
< Empty
, cd_detected
, Playing
>,
89 // +---------+-------------+---------+---------------------+----------------------+
90 _row
< Playing
, stop
, Stopped
>,
91 _row
< Playing
, pause
, Paused
>,
92 _row
< Playing
, open_close
, Open
>,
93 // +---------+-------------+---------+---------------------+----------------------+
94 _row
< Paused
, end_pause
, Playing
>,
95 _row
< Paused
, stop
, Stopped
>,
96 _row
< Paused
, open_close
, Open
>,
97 _row
< AllOk
, error_found
, ErrorMode
>
98 // +---------+-------------+---------+---------------------+----------------------+
100 // Replaces the default no-transition response.
101 template <class FSM
,class Event
>
102 void no_transition(Event
const& e
, FSM
&,int state
)
107 typedef msm::back::state_machine
<player_
,msm::back::mpl_graph_fsm_check
> player
;