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
0005
0006
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
0033
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
0057
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 }
0070 }
0071
0072
0073
0074 #endif