Chris@16: // Copyright 2008 Christophe Henry Chris@16: // henry UNDERSCORE christophe AT hotmail DOT com Chris@16: // This is an extended version of the state machine available in the boost::mpl library Chris@16: // Distributed under the same license as the original. Chris@16: // Copyright for the original version: Chris@16: // Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed Chris@16: // under the Boost Software License, Version 1.0. (See accompanying Chris@16: // file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: #ifndef BOOST_MSM_ROW2_HPP Chris@16: #define BOOST_MSM_ROW2_HPP Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost { namespace msm { namespace front Chris@16: { Chris@16: template< Chris@16: typename T1 Chris@16: , class Event Chris@16: , typename T2 Chris@16: > Chris@16: struct _row2 Chris@16: { Chris@16: typedef _row_tag row_type_tag; Chris@16: typedef T1 Source; Chris@16: typedef T2 Target; Chris@16: typedef Event Evt; Chris@16: }; Chris@16: Chris@16: template< Chris@16: typename T1 Chris@16: , class Event Chris@16: , typename T2 Chris@16: , typename CalledForAction Chris@16: , void (CalledForAction::*action)(Event const&) Chris@16: > Chris@16: struct a_row2 Chris@16: { Chris@16: typedef a_row_tag row_type_tag; Chris@16: typedef T1 Source; Chris@16: typedef T2 Target; Chris@16: typedef Event Evt; Chris@16: template Chris@16: static ::boost::msm::back::HandledEnum action_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt, Chris@16: AllStates& all_states) Chris@16: { Chris@16: // in this front-end, we don't need to know source and target states Chris@16: ::boost::msm::front::detail::row2_action_helper::template call_helper Chris@16: (fsm,evt,src,tgt,all_states, Chris@16: ::boost::mpl::bool_< ::boost::is_base_of::type::value>()); Chris@16: return ::boost::msm::back::HANDLED_TRUE; Chris@16: } Chris@16: }; Chris@16: Chris@16: template< Chris@16: typename T1 Chris@16: , class Event Chris@16: , typename T2 Chris@16: , typename CalledForAction Chris@16: , void (CalledForAction::*action)(Event const&) Chris@16: , typename CalledForGuard Chris@16: , bool (CalledForGuard::*guard)(Event const&) Chris@16: > Chris@16: struct row2 Chris@16: { Chris@16: typedef row_tag row_type_tag; Chris@16: typedef T1 Source; Chris@16: typedef T2 Target; Chris@16: typedef Event Evt; Chris@16: template Chris@16: static ::boost::msm::back::HandledEnum action_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt, Chris@16: AllStates& all_states) Chris@16: { Chris@16: // in this front-end, we don't need to know source and target states Chris@16: ::boost::msm::front::detail::row2_action_helper::call_helper Chris@16: (fsm,evt,src,tgt,all_states, Chris@16: ::boost::mpl::bool_< ::boost::is_base_of::type::value>()); Chris@16: return ::boost::msm::back::HANDLED_TRUE; Chris@16: } Chris@16: template Chris@16: static bool guard_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt, Chris@16: AllStates& all_states) Chris@16: { Chris@16: // in this front-end, we don't need to know source and target states Chris@16: return ::boost::msm::front::detail::row2_guard_helper::call_helper Chris@16: (fsm,evt,src,tgt,all_states, Chris@16: ::boost::mpl::bool_< ::boost::is_base_of::type::value>()); Chris@16: } Chris@16: }; Chris@16: template< Chris@16: typename T1 Chris@16: , class Event Chris@16: , typename T2 Chris@16: , typename CalledForGuard Chris@16: , bool (CalledForGuard::*guard)(Event const&) Chris@16: > Chris@16: struct g_row2 Chris@16: { Chris@16: typedef g_row_tag row_type_tag; Chris@16: typedef T1 Source; Chris@16: typedef T2 Target; Chris@16: typedef Event Evt; Chris@16: template Chris@16: static bool guard_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt, Chris@16: AllStates& all_states) Chris@16: { Chris@16: // in this front-end, we don't need to know source and target states Chris@16: return ::boost::msm::front::detail::row2_guard_helper::call_helper Chris@16: (fsm,evt,src,tgt,all_states, Chris@16: ::boost::mpl::bool_< ::boost::is_base_of::type::value>()); Chris@16: } Chris@16: }; Chris@16: // internal transitions Chris@16: template< Chris@16: typename T1 Chris@16: , class Event Chris@16: , typename CalledForAction Chris@16: , void (CalledForAction::*action)(Event const&) Chris@16: > Chris@16: struct a_irow2 Chris@16: { Chris@16: typedef a_irow_tag row_type_tag; Chris@16: typedef T1 Source; Chris@16: typedef T1 Target; Chris@16: typedef Event Evt; Chris@16: template Chris@16: static ::boost::msm::back::HandledEnum action_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt, Chris@16: AllStates& all_states) Chris@16: { Chris@16: // in this front-end, we don't need to know source and target states Chris@16: ::boost::msm::front::detail::row2_action_helper::call_helper Chris@16: (fsm,evt,src,tgt,all_states, Chris@16: ::boost::mpl::bool_< ::boost::is_base_of::type::value>()); Chris@16: return ::boost::msm::back::HANDLED_TRUE; Chris@16: } Chris@16: }; Chris@16: Chris@16: template< Chris@16: typename T1 Chris@16: , class Event Chris@16: , typename CalledForAction Chris@16: , void (CalledForAction::*action)(Event const&) Chris@16: , typename CalledForGuard Chris@16: , bool (CalledForGuard::*guard)(Event const&) Chris@16: > Chris@16: struct irow2 Chris@16: { Chris@16: typedef irow_tag row_type_tag; Chris@16: typedef T1 Source; Chris@16: typedef T1 Target; Chris@16: typedef Event Evt; Chris@16: template Chris@16: static ::boost::msm::back::HandledEnum action_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt, Chris@16: AllStates& all_states) Chris@16: { Chris@16: // in this front-end, we don't need to know source and target states Chris@16: ::boost::msm::front::detail::row2_action_helper::call_helper Chris@16: (fsm,evt,src,tgt,all_states, Chris@16: ::boost::mpl::bool_< ::boost::is_base_of::type::value>()); Chris@16: return ::boost::msm::back::HANDLED_TRUE; Chris@16: } Chris@16: template Chris@16: static bool guard_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt, Chris@16: AllStates& all_states) Chris@16: { Chris@16: // in this front-end, we don't need to know source and target states Chris@16: return ::boost::msm::front::detail::row2_guard_helper::call_helper Chris@16: (fsm,evt,src,tgt,all_states, Chris@16: ::boost::mpl::bool_< ::boost::is_base_of::type::value>()); Chris@16: } Chris@16: }; Chris@16: template< Chris@16: typename T1 Chris@16: , class Event Chris@16: , typename CalledForGuard Chris@16: , bool (CalledForGuard::*guard)(Event const&) Chris@16: > Chris@16: struct g_irow2 Chris@16: { Chris@16: typedef g_irow_tag row_type_tag; Chris@16: typedef T1 Source; Chris@16: typedef T1 Target; Chris@16: typedef Event Evt; Chris@16: template Chris@16: static bool guard_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt, Chris@16: AllStates& all_states) Chris@16: { Chris@16: // in this front-end, we don't need to know source and target states Chris@16: return ::boost::msm::front::detail::row2_guard_helper::call_helper Chris@16: (fsm,evt,src,tgt,all_states, Chris@16: ::boost::mpl::bool_< ::boost::is_base_of::type::value>()); Chris@16: } Chris@16: }; Chris@16: Chris@16: }}} Chris@16: Chris@16: #endif //BOOST_MSM_ROW2_HPP Chris@16: