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_FRONT_EUML_TRANSFORMATION_H Chris@16: #define BOOST_MSM_FRONT_EUML_TRANSFORMATION_H Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost { namespace msm { namespace front { namespace euml Chris@16: { Chris@16: #ifdef __STL_CONFIG_H Chris@16: BOOST_MSM_EUML_FUNCTION(FillN_ , std::fill_n , fill_n_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 ) Chris@16: BOOST_MSM_EUML_FUNCTION(Rotate_ , std::rotate , rotate_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 ) Chris@16: BOOST_MSM_EUML_FUNCTION(GenerateN_ , std::generate_n , generate_n_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 ) Chris@16: Chris@16: #else Chris@16: BOOST_MSM_EUML_FUNCTION(FillN_ , std::fill_n , fill_n_ , void , void ) Chris@16: BOOST_MSM_EUML_FUNCTION(Rotate_ , std::rotate , rotate_ , void , void ) Chris@16: BOOST_MSM_EUML_FUNCTION(GenerateN_ , std::generate_n , generate_n_ , void , void ) Chris@16: #endif Chris@16: Chris@16: BOOST_MSM_EUML_FUNCTION(Copy_ , std::copy , copy_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 ) Chris@16: BOOST_MSM_EUML_FUNCTION(CopyBackward_ , std::copy_backward , copy_backward_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 ) Chris@16: BOOST_MSM_EUML_FUNCTION(Reverse_ , std::reverse , reverse_ , void , void ) Chris@16: BOOST_MSM_EUML_FUNCTION(ReverseCopy_ , std::reverse_copy , reverse_copy_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 ) Chris@16: BOOST_MSM_EUML_FUNCTION(Remove_ , std::remove , remove_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 ) Chris@16: BOOST_MSM_EUML_FUNCTION(RemoveIf_ , std::remove_if , remove_if_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 ) Chris@16: BOOST_MSM_EUML_FUNCTION(RemoveCopy_ , std::remove_copy , remove_copy_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 ) Chris@16: BOOST_MSM_EUML_FUNCTION(RemoveCopyIf_ , std::remove_copy_if , remove_copy_if_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 ) Chris@16: BOOST_MSM_EUML_FUNCTION(Fill_ , std::fill , fill_ , void , void ) Chris@16: BOOST_MSM_EUML_FUNCTION(Generate_ , std::generate , generate_ , void , void ) Chris@16: BOOST_MSM_EUML_FUNCTION(Unique_ , std::unique , unique_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 ) Chris@16: BOOST_MSM_EUML_FUNCTION(UniqueCopy_ , std::unique_copy , unique_copy_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 ) Chris@16: BOOST_MSM_EUML_FUNCTION(RandomShuffle_ , std::random_shuffle , random_shuffle_ , void , void ) Chris@16: BOOST_MSM_EUML_FUNCTION(RotateCopy_ , std::rotate_copy , rotate_copy_ , RESULT_TYPE_PARAM4 , RESULT_TYPE2_PARAM4 ) Chris@16: BOOST_MSM_EUML_FUNCTION(Partition_ , std::partition , partition_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 ) Chris@16: BOOST_MSM_EUML_FUNCTION(StablePartition_ , std::stable_partition , stable_partition_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 ) Chris@16: BOOST_MSM_EUML_FUNCTION(Sort_ , std::sort , sort_ , void , void ) Chris@16: BOOST_MSM_EUML_FUNCTION(StableSort_ , std::stable_sort , stable_sort_ , void , void ) Chris@16: BOOST_MSM_EUML_FUNCTION(PartialSort_ , std::partial_sort , partial_sort_ , void , void ) Chris@16: BOOST_MSM_EUML_FUNCTION(PartialSortCopy_ , std::partial_sort_copy , partial_sort_copy_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 ) Chris@16: BOOST_MSM_EUML_FUNCTION(NthElement_ , std::nth_element , nth_element_ , void , void ) Chris@16: BOOST_MSM_EUML_FUNCTION(Merge_ , std::merge , merge_ , RESULT_TYPE_PARAM5 , RESULT_TYPE2_PARAM5 ) Chris@16: BOOST_MSM_EUML_FUNCTION(InplaceMerge_ , std::inplace_merge , inplace_merge_ , void , void ) Chris@16: BOOST_MSM_EUML_FUNCTION(SetUnion_ , std::set_union , set_union_ , RESULT_TYPE_PARAM5 , RESULT_TYPE2_PARAM5 ) Chris@16: BOOST_MSM_EUML_FUNCTION(PushHeap_ , std::push_heap , push_heap_ , void , void ) Chris@16: BOOST_MSM_EUML_FUNCTION(PopHeap_ , std::pop_heap , pop_heap_ , void , void ) Chris@16: BOOST_MSM_EUML_FUNCTION(MakeHeap_ , std::make_heap , make_heap_ , void , void ) Chris@16: BOOST_MSM_EUML_FUNCTION(SortHeap_ , std::sort_heap , sort_heap_ , void , void ) Chris@16: BOOST_MSM_EUML_FUNCTION(NextPermutation_ , std::next_permutation , next_permutation_ , bool , bool ) Chris@16: BOOST_MSM_EUML_FUNCTION(PrevPermutation_ , std::prev_permutation , prev_permutation_ , bool , bool ) Chris@16: BOOST_MSM_EUML_FUNCTION(InnerProduct_ , std::inner_product , inner_product_ , RESULT_TYPE_PARAM4 , RESULT_TYPE2_PARAM4 ) Chris@16: BOOST_MSM_EUML_FUNCTION(PartialSum_ , std::partial_sum , partial_sum_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 ) Chris@16: BOOST_MSM_EUML_FUNCTION(AdjacentDifference_ , std::adjacent_difference , adjacent_difference_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 ) Chris@16: BOOST_MSM_EUML_FUNCTION(Replace_ , std::replace , replace_ , void , void ) Chris@16: BOOST_MSM_EUML_FUNCTION(ReplaceIf_ , std::replace_if , replace_if_ , void , void ) Chris@16: BOOST_MSM_EUML_FUNCTION(ReplaceCopy_ , std::replace_copy , replace_copy_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 ) Chris@16: BOOST_MSM_EUML_FUNCTION(ReplaceCopyIf_ , std::replace_copy_if , replace_copy_if_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 ) Chris@16: Chris@16: Chris@16: Chris@16: template Chris@16: struct BackInserter_ : euml_action > Chris@16: { Chris@16: template Chris@16: struct state_action_result Chris@16: { Chris@16: typedef std::back_insert_iterator< Chris@16: typename ::boost::remove_reference< Chris@16: typename get_result_type2::type>::type> type; Chris@16: }; Chris@16: template Chris@16: struct transition_action_result Chris@16: { Chris@16: typedef std::back_insert_iterator< Chris@16: typename ::boost::remove_reference< Chris@16: typename get_result_type::type>::type> type; Chris@16: }; Chris@16: typedef ::boost::mpl::set tag_type; Chris@16: Chris@16: template Chris@16: typename ::boost::enable_if< Chris@16: typename ::boost::mpl::has_key< Chris@16: typename T::tag_type,action_tag>::type, Chris@16: typename transition_action_result::type >::type Chris@16: operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const Chris@16: { Chris@16: return std::back_inserter(T()(evt,fsm,src,tgt)); Chris@16: } Chris@16: template Chris@16: typename ::boost::enable_if< Chris@16: typename ::boost::mpl::has_key< Chris@16: typename T::tag_type,state_action_tag>::type, Chris@16: typename state_action_result::type >::type Chris@16: operator()(Event const& evt,FSM& fsm,STATE& state )const Chris@16: { Chris@16: return std::back_inserter(T()(evt,fsm,state)); Chris@16: } Chris@16: }; Chris@16: Chris@16: struct back_inserter_tag {}; Chris@16: struct BackInserter_Helper: proto::extends< proto::terminal::type, BackInserter_Helper, boost::msm::sm_domain> Chris@16: { Chris@16: BackInserter_Helper(){} Chris@16: template Chris@16: struct In Chris@16: { Chris@16: typedef BackInserter_ type; Chris@16: }; Chris@16: }; Chris@16: BackInserter_Helper const back_inserter_; Chris@16: Chris@16: template Chris@16: struct FrontInserter_ : euml_action > Chris@16: { Chris@16: template Chris@16: struct state_action_result Chris@16: { Chris@16: typedef std::front_insert_iterator< Chris@16: typename ::boost::remove_reference< Chris@16: typename get_result_type2::type>::type> type; Chris@16: }; Chris@16: template Chris@16: struct transition_action_result Chris@16: { Chris@16: typedef std::front_insert_iterator< Chris@16: typename ::boost::remove_reference< Chris@16: typename get_result_type::type>::type> type; Chris@16: }; Chris@16: typedef ::boost::mpl::set tag_type; Chris@16: Chris@16: template Chris@16: typename ::boost::enable_if< Chris@16: typename ::boost::mpl::has_key< Chris@16: typename T::tag_type,action_tag>::type, Chris@16: typename transition_action_result::type >::type Chris@16: operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const Chris@16: { Chris@16: return std::front_inserter(T()(evt,fsm,src,tgt)); Chris@16: } Chris@16: template Chris@16: typename ::boost::enable_if< Chris@16: typename ::boost::mpl::has_key< Chris@16: typename T::tag_type,state_action_tag>::type, Chris@16: typename state_action_result::type >::type Chris@16: operator()(Event const& evt,FSM& fsm,STATE& state )const Chris@16: { Chris@16: return std::front_inserter(T()(evt,fsm,state)); Chris@16: } Chris@16: }; Chris@16: Chris@16: struct front_inserter_tag {}; Chris@16: struct FrontInserter_Helper: proto::extends< proto::terminal::type, FrontInserter_Helper, boost::msm::sm_domain> Chris@16: { Chris@16: FrontInserter_Helper(){} Chris@16: template Chris@16: struct In Chris@16: { Chris@16: typedef FrontInserter_ type; Chris@16: }; Chris@16: }; Chris@16: FrontInserter_Helper const front_inserter_; Chris@16: Chris@16: template Chris@16: struct Inserter_ : euml_action > Chris@16: { Chris@16: template Chris@16: struct state_action_result Chris@16: { Chris@16: typedef std::insert_iterator< Chris@16: typename ::boost::remove_reference< Chris@16: typename get_result_type2::type>::type> type; Chris@16: }; Chris@16: template Chris@16: struct transition_action_result Chris@16: { Chris@16: typedef std::insert_iterator< Chris@16: typename ::boost::remove_reference< Chris@16: typename get_result_type::type>::type> type; Chris@16: }; Chris@16: typedef ::boost::mpl::set tag_type; Chris@16: Chris@16: template Chris@16: typename ::boost::enable_if< Chris@16: typename ::boost::mpl::has_key< Chris@16: typename T::tag_type,action_tag>::type, Chris@16: typename transition_action_result::type >::type Chris@16: operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const Chris@16: { Chris@16: return std::inserter(T()(evt,fsm,src,tgt),Pos()(evt,fsm,src,tgt)); Chris@16: } Chris@16: template Chris@16: typename ::boost::enable_if< Chris@16: typename ::boost::mpl::has_key< Chris@16: typename T::tag_type,state_action_tag>::type, Chris@16: typename state_action_result::type >::type Chris@16: operator()(Event const& evt,FSM& fsm,STATE& state )const Chris@16: { Chris@16: return std::inserter(T()(evt,fsm,state),Pos()(evt,fsm,state)); Chris@16: } Chris@16: }; Chris@16: Chris@16: struct inserter_tag {}; Chris@16: struct Inserter_Helper: proto::extends< proto::terminal::type, Inserter_Helper, boost::msm::sm_domain> Chris@16: { Chris@16: Inserter_Helper(){} Chris@16: template Chris@16: struct In Chris@16: { Chris@16: typedef Inserter_ type; Chris@16: }; Chris@16: }; Chris@16: Inserter_Helper const inserter_; Chris@16: Chris@16: template Chris@16: struct Transform_ : euml_action > Chris@16: { Chris@16: }; Chris@16: Chris@16: template Chris@16: struct Transform_::type >::type> Chris@16: : euml_action > Chris@16: { Chris@16: template Chris@16: struct state_action_result Chris@16: { Chris@16: typedef typename get_result_type2::type type; Chris@16: }; Chris@16: template Chris@16: struct transition_action_result Chris@16: { Chris@16: typedef typename get_result_type::type type; Chris@16: }; Chris@16: typedef ::boost::mpl::set tag_type; Chris@16: Chris@16: template Chris@16: typename ::boost::enable_if< Chris@16: typename ::boost::mpl::has_key< Chris@16: typename Param1::tag_type,action_tag>::type, Chris@16: typename transition_action_result::type >::type Chris@16: operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const Chris@16: { Chris@16: return std::transform(Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt), Chris@16: Param4()(evt,fsm,src,tgt)); Chris@16: } Chris@16: template Chris@16: typename ::boost::enable_if< Chris@16: typename ::boost::mpl::has_key< Chris@16: typename Param1::tag_type,state_action_tag>::type, Chris@16: typename state_action_result::type >::type Chris@16: operator()(Event const& evt,FSM& fsm,STATE& state )const Chris@16: { Chris@16: return std::transform(Param1()(evt,fsm,state),Param2()(evt,fsm,state),Param3()(evt,fsm,state), Chris@16: Param4()(evt,fsm,state)); Chris@16: } Chris@16: }; Chris@16: Chris@16: template Chris@16: struct Transform_::type >::type> Chris@16: : euml_action > Chris@16: { Chris@16: template Chris@16: struct state_action_result Chris@16: { Chris@16: typedef typename get_result_type2::type type; Chris@16: }; Chris@16: template Chris@16: struct transition_action_result Chris@16: { Chris@16: typedef typename get_result_type::type type; Chris@16: }; Chris@16: typedef ::boost::mpl::set tag_type; Chris@16: Chris@16: template Chris@16: typename ::boost::enable_if< Chris@16: typename ::boost::mpl::has_key< Chris@16: typename Param1::tag_type,action_tag>::type, Chris@16: typename transition_action_result::type >::type Chris@16: operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const Chris@16: { Chris@16: return std::transform (Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt), Chris@16: Param4()(evt,fsm,src,tgt),Param5()(evt,fsm,src,tgt)); Chris@16: } Chris@16: template Chris@16: typename ::boost::enable_if< Chris@16: typename ::boost::mpl::has_key< Chris@16: typename Param1::tag_type,state_action_tag>::type, Chris@16: typename state_action_result::type >::type Chris@16: operator()(Event const& evt,FSM& fsm,STATE& state )const Chris@16: { Chris@16: return std::transform (Param1()(evt,fsm,state),Param2()(evt,fsm,state),Param3()(evt,fsm,state), Chris@16: Param4()(evt,fsm,state),Param5()(evt,fsm,state)); Chris@16: } Chris@16: }; Chris@16: struct transform_tag {}; Chris@16: struct Transform_Helper: proto::extends< proto::terminal::type, Transform_Helper, boost::msm::sm_domain> Chris@16: { Chris@16: Transform_Helper(){} Chris@16: template Chris@16: struct In Chris@16: { Chris@16: typedef Transform_ type; Chris@16: }; Chris@16: }; Chris@16: Transform_Helper const transform_; Chris@16: Chris@16: }}}} Chris@16: Chris@16: #endif //BOOST_MSM_FRONT_EUML_TRANSFORMATION_H