My Project
custom_reaction.hpp
Go to the documentation of this file.
1 #ifndef BOOST_STATECHART_CUSTOM_REACTION_HPP_INCLUDED
2 #define BOOST_STATECHART_CUSTOM_REACTION_HPP_INCLUDED
3 // Copyright 2002-2006 Andreas Huber Doenni
5 // Distributed under the Boost Software License, Version 1.0. (See accompany-
6 // ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 
9 
10 
12 
13 #include <boost/polymorphic_cast.hpp> // boost::polymorphic_downcast
14 
15 
16 
17 namespace boost
18 {
19 namespace statechart
20 {
21 
22 
23 
24 class event_base;
25 
27 template< class Event >
29 {
30  public:
32  // The following declarations should be private.
33  // They are only public because many compilers lack template friends.
35  template< class State, class EventBase, class IdType >
37  State & stt, const EventBase & evt, const IdType & eventType )
38  {
39  if ( eventType == Event::static_type() )
40  {
42  stt.react( *polymorphic_downcast< const Event * >( &evt ) ) );
43  }
44  else
45  {
46  return detail::no_reaction;
47  }
48  }
49 };
50 
51 template<>
53 {
54  public:
56  // The following declarations should be private.
57  // They are only public because many compilers lack template friends.
59  template< class State, class EventBase, class IdType >
61  State & stt, const EventBase & evt, const IdType & )
62  {
63  return detail::result_utility::get_result( stt.react( evt ) );
64  }
65 };
66 
67 
68 
69 } // namespace statechart
70 } // namespace boost
71 
72 
73 
74 #endif
boost::statechart::detail::result_utility::get_result
static reaction_result get_result(::boost::statechart::result value)
Definition: result.hpp:108
boost
Definition: asynchronous_state_machine.hpp:20
boost::statechart::custom_reaction< event_base >::react
static detail::reaction_result react(State &stt, const EventBase &evt, const IdType &)
Definition: custom_reaction.hpp:60
boost::statechart::detail::reaction_result
reaction_result
Definition: result.hpp:26
boost::statechart::detail::no_reaction
@ no_reaction
Definition: result.hpp:27
boost::statechart::custom_reaction::react
static detail::reaction_result react(State &stt, const EventBase &evt, const IdType &eventType)
Definition: custom_reaction.hpp:36
boost::statechart::event_base
Definition: event_base.hpp:51
boost::statechart::custom_reaction
Definition: custom_reaction.hpp:29
result.hpp