Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:52:32

0001 #ifndef BOOST_STATECHART_IN_STATE_REACTION_HPP_INCLUDED
0002 #define BOOST_STATECHART_IN_STATE_REACTION_HPP_INCLUDED
0003 //////////////////////////////////////////////////////////////////////////////
0004 // Copyright 2005-2008 Andreas Huber Doenni
0005 // Distributed under the Boost Software License, Version 1.0. (See accompany-
0006 // ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0007 //////////////////////////////////////////////////////////////////////////////
0008 
0009 
0010 
0011 #include <boost/statechart/result.hpp>
0012 
0013 #include <boost/statechart/detail/reaction_dispatcher.hpp>
0014 
0015 
0016 
0017 namespace boost
0018 {
0019 namespace statechart
0020 {
0021 
0022 
0023 
0024 class event_base;
0025 
0026 //////////////////////////////////////////////////////////////////////////////
0027 template< class Event,
0028           class ReactionContext = detail::no_context< Event >,
0029           void ( ReactionContext::*pAction )( const Event & ) =
0030             &detail::no_context< Event >::no_function >
0031 class in_state_reaction
0032 {
0033   private:
0034     //////////////////////////////////////////////////////////////////////////
0035     template< class State >
0036     struct reactions
0037     {
0038       static result react_without_action( State & stt )
0039       {
0040         return stt.discard_event();
0041       }
0042 
0043       static result react_with_action( State & stt, const Event & evt )
0044       {
0045         ( stt.template context< ReactionContext >().*pAction )( evt );
0046         return react_without_action( stt );
0047       }
0048     };
0049 
0050   public:
0051     //////////////////////////////////////////////////////////////////////////
0052     // The following declarations should be private.
0053     // They are only public because many compilers lack template friends.
0054     //////////////////////////////////////////////////////////////////////////
0055     template< class State, class EventBase, class IdType >
0056     static detail::reaction_result react(
0057       State & stt, const EventBase & evt, const IdType & eventType )
0058     {
0059       typedef detail::reaction_dispatcher<
0060         reactions< State >, State, EventBase, Event, ReactionContext, IdType
0061       > dispatcher;
0062       return dispatcher::react( stt, evt, eventType );
0063     }
0064 };
0065 
0066 
0067 
0068 } // namespace statechart
0069 } // namespace boost
0070 
0071 
0072 
0073 #endif