Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:00:51

0001 #ifndef BOOST_STATECHART_CUSTOM_REACTION_HPP_INCLUDED
0002 #define BOOST_STATECHART_CUSTOM_REACTION_HPP_INCLUDED
0003 //////////////////////////////////////////////////////////////////////////////
0004 // Copyright 2002-2006 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/polymorphic_cast.hpp> // boost::polymorphic_downcast
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 custom_reaction
0029 {
0030   public:
0031     //////////////////////////////////////////////////////////////////////////
0032     // The following declarations should be private.
0033     // They are only public because many compilers lack template friends.
0034     //////////////////////////////////////////////////////////////////////////
0035     template< class State, class EventBase, class IdType >
0036     static detail::reaction_result react(
0037       State & stt, const EventBase & evt, const IdType & eventType )
0038     {
0039       if ( eventType == Event::static_type() )
0040       {
0041         return detail::result_utility::get_result( 
0042           stt.react( *polymorphic_downcast< const Event * >( &evt ) ) );
0043       }
0044       else
0045       {
0046         return detail::no_reaction;
0047       }
0048     }
0049 };
0050 
0051 template<>
0052 class custom_reaction< event_base >
0053 {
0054   public:
0055     //////////////////////////////////////////////////////////////////////////
0056     // The following declarations should be private.
0057     // They are only public because many compilers lack template friends.
0058     //////////////////////////////////////////////////////////////////////////
0059     template< class State, class EventBase, class IdType >
0060     static detail::reaction_result react(
0061       State & stt, const EventBase & evt, const IdType & )
0062     {
0063       return detail::result_utility::get_result( stt.react( evt ) );
0064     }
0065 };
0066 
0067 
0068 
0069 } // namespace statechart
0070 } // namespace boost
0071 
0072 
0073 
0074 #endif