Chris@16
|
1 #ifndef BOOST_STATECHART_TRANSITION_HPP_INCLUDED
|
Chris@16
|
2 #define BOOST_STATECHART_TRANSITION_HPP_INCLUDED
|
Chris@16
|
3 //////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
4 // Copyright 2002-2008 Andreas Huber Doenni
|
Chris@16
|
5 // Distributed under the Boost Software License, Version 1.0. (See accompany-
|
Chris@16
|
6 // ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
7 //////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
8
|
Chris@16
|
9
|
Chris@16
|
10
|
Chris@16
|
11 #include <boost/statechart/result.hpp>
|
Chris@16
|
12
|
Chris@16
|
13 #include <boost/statechart/detail/reaction_dispatcher.hpp>
|
Chris@16
|
14
|
Chris@16
|
15
|
Chris@16
|
16
|
Chris@16
|
17 namespace boost
|
Chris@16
|
18 {
|
Chris@16
|
19 namespace statechart
|
Chris@16
|
20 {
|
Chris@16
|
21
|
Chris@16
|
22
|
Chris@16
|
23
|
Chris@16
|
24 //////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
25 template< class Event, class Destination,
|
Chris@16
|
26 class TransitionContext = detail::no_context< Event >,
|
Chris@16
|
27 void ( TransitionContext::*pTransitionAction )( const Event & ) =
|
Chris@16
|
28 &detail::no_context< Event >::no_function >
|
Chris@16
|
29 class transition
|
Chris@16
|
30 {
|
Chris@16
|
31 private:
|
Chris@16
|
32 //////////////////////////////////////////////////////////////////////////
|
Chris@16
|
33 template< class State >
|
Chris@16
|
34 struct reactions
|
Chris@16
|
35 {
|
Chris@16
|
36 static result react_without_action( State & stt )
|
Chris@16
|
37 {
|
Chris@16
|
38 return stt.template transit< Destination >();
|
Chris@16
|
39 }
|
Chris@16
|
40
|
Chris@16
|
41 static result react_with_action( State & stt, const Event & evt )
|
Chris@16
|
42 {
|
Chris@16
|
43 return stt.template transit< Destination >( pTransitionAction, evt );
|
Chris@16
|
44 }
|
Chris@16
|
45 };
|
Chris@16
|
46
|
Chris@16
|
47 public:
|
Chris@16
|
48 //////////////////////////////////////////////////////////////////////////
|
Chris@16
|
49 // The following declarations should be private.
|
Chris@16
|
50 // They are only public because many compilers lack template friends.
|
Chris@16
|
51 //////////////////////////////////////////////////////////////////////////
|
Chris@16
|
52 template< class State, class EventBase, class IdType >
|
Chris@16
|
53 static detail::reaction_result react(
|
Chris@16
|
54 State & stt, const EventBase & evt, const IdType & eventType )
|
Chris@16
|
55 {
|
Chris@16
|
56 typedef detail::reaction_dispatcher<
|
Chris@16
|
57 reactions< State >, State, EventBase, Event, TransitionContext, IdType
|
Chris@16
|
58 > dispatcher;
|
Chris@16
|
59 return dispatcher::react( stt, evt, eventType );
|
Chris@16
|
60 }
|
Chris@16
|
61 };
|
Chris@16
|
62
|
Chris@16
|
63
|
Chris@16
|
64
|
Chris@16
|
65 } // namespace statechart
|
Chris@16
|
66 } // namespace boost
|
Chris@16
|
67
|
Chris@16
|
68
|
Chris@16
|
69
|
Chris@16
|
70 #endif
|