Imported Upstream version 1.57.0
[platform/upstream/boost.git] / libs / mpl / example / fsm / aux_ / transition.hpp
1
2 #ifndef BOOST_FSM_TRANSITION_INCLUDED
3 #define BOOST_FSM_TRANSITION_INCLUDED
4
5 // Copyright Aleksey Gurtovoy 2002-2004
6 //
7 // Distributed under the Boost Software License, Version 1.0. 
8 // (See accompanying file LICENSE_1_0.txt or copy at 
9 // http://www.boost.org/LICENSE_1_0.txt)
10 //
11 // See http://www.boost.org/libs/mpl for documentation.
12
13 // $Id$
14 // $Date$
15 // $Revision$
16
17 #include <cassert>
18
19 namespace fsm { namespace aux {
20
21 // represent a signle transition between states |From| and |To|
22
23 template<
24       typename T
25     , typename From
26     , typename Event
27     , typename To
28     , bool (T::* transition_func)(Event const&)
29     >
30 struct transition
31 {
32     typedef T       fsm_t;
33     typedef From    from_state_t;
34     typedef Event   event_t;
35     typedef To      to_state_t;
36
37     typedef typename Event::base_t  base_event_t;
38     static bool do_transition(T& x, base_event_t const& e)
39     {
40         assert(dynamic_cast<event_t const*>(&e) == &e);
41         return (x.*transition_func)(static_cast<event_t const &>(e));
42     }
43 };
44
45 }}
46
47 #endif // BOOST_FSM_TRANSITION_INCLUDED