File indexing completed on 2024-11-16 09:21:30
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_MSM_FRONT_EUML_TRANSFORMATION_H
0012 #define BOOST_MSM_FRONT_EUML_TRANSFORMATION_H
0013
0014 #include <algorithm>
0015 #include <boost/msm/front/euml/common.hpp>
0016
0017 namespace boost { namespace msm { namespace front { namespace euml
0018 {
0019 #ifdef __STL_CONFIG_H
0020 BOOST_MSM_EUML_FUNCTION(FillN_ , std::fill_n , fill_n_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 )
0021 BOOST_MSM_EUML_FUNCTION(Rotate_ , std::rotate , rotate_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 )
0022 BOOST_MSM_EUML_FUNCTION(GenerateN_ , std::generate_n , generate_n_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 )
0023
0024 #else
0025 BOOST_MSM_EUML_FUNCTION(FillN_ , std::fill_n , fill_n_ , void , void )
0026 BOOST_MSM_EUML_FUNCTION(Rotate_ , std::rotate , rotate_ , void , void )
0027 BOOST_MSM_EUML_FUNCTION(GenerateN_ , std::generate_n , generate_n_ , void , void )
0028 #endif
0029
0030 BOOST_MSM_EUML_FUNCTION(Copy_ , std::copy , copy_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 )
0031 BOOST_MSM_EUML_FUNCTION(CopyBackward_ , std::copy_backward , copy_backward_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 )
0032 BOOST_MSM_EUML_FUNCTION(Reverse_ , std::reverse , reverse_ , void , void )
0033 BOOST_MSM_EUML_FUNCTION(ReverseCopy_ , std::reverse_copy , reverse_copy_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 )
0034 BOOST_MSM_EUML_FUNCTION(Remove_ , std::remove , remove_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 )
0035 BOOST_MSM_EUML_FUNCTION(RemoveIf_ , std::remove_if , remove_if_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 )
0036 BOOST_MSM_EUML_FUNCTION(RemoveCopy_ , std::remove_copy , remove_copy_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 )
0037 BOOST_MSM_EUML_FUNCTION(RemoveCopyIf_ , std::remove_copy_if , remove_copy_if_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 )
0038 BOOST_MSM_EUML_FUNCTION(Fill_ , std::fill , fill_ , void , void )
0039 BOOST_MSM_EUML_FUNCTION(Generate_ , std::generate , generate_ , void , void )
0040 BOOST_MSM_EUML_FUNCTION(Unique_ , std::unique , unique_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 )
0041 BOOST_MSM_EUML_FUNCTION(UniqueCopy_ , std::unique_copy , unique_copy_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 )
0042 #if __cplusplus < 201703L
0043 BOOST_MSM_EUML_FUNCTION(RandomShuffle_ , std::random_shuffle , random_shuffle_ , void , void )
0044 #endif
0045 #if __cplusplus >= 201103L
0046 BOOST_MSM_EUML_FUNCTION(Shuffle_ , std::shuffle , shuffle_ , void , void )
0047 #endif
0048 BOOST_MSM_EUML_FUNCTION(RotateCopy_ , std::rotate_copy , rotate_copy_ , RESULT_TYPE_PARAM4 , RESULT_TYPE2_PARAM4 )
0049 BOOST_MSM_EUML_FUNCTION(Partition_ , std::partition , partition_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 )
0050 BOOST_MSM_EUML_FUNCTION(StablePartition_ , std::stable_partition , stable_partition_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 )
0051 BOOST_MSM_EUML_FUNCTION(Sort_ , std::sort , sort_ , void , void )
0052 BOOST_MSM_EUML_FUNCTION(StableSort_ , std::stable_sort , stable_sort_ , void , void )
0053 BOOST_MSM_EUML_FUNCTION(PartialSort_ , std::partial_sort , partial_sort_ , void , void )
0054 BOOST_MSM_EUML_FUNCTION(PartialSortCopy_ , std::partial_sort_copy , partial_sort_copy_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 )
0055 BOOST_MSM_EUML_FUNCTION(NthElement_ , std::nth_element , nth_element_ , void , void )
0056 BOOST_MSM_EUML_FUNCTION(Merge_ , std::merge , merge_ , RESULT_TYPE_PARAM5 , RESULT_TYPE2_PARAM5 )
0057 BOOST_MSM_EUML_FUNCTION(InplaceMerge_ , std::inplace_merge , inplace_merge_ , void , void )
0058 BOOST_MSM_EUML_FUNCTION(SetUnion_ , std::set_union , set_union_ , RESULT_TYPE_PARAM5 , RESULT_TYPE2_PARAM5 )
0059 BOOST_MSM_EUML_FUNCTION(PushHeap_ , std::push_heap , push_heap_ , void , void )
0060 BOOST_MSM_EUML_FUNCTION(PopHeap_ , std::pop_heap , pop_heap_ , void , void )
0061 BOOST_MSM_EUML_FUNCTION(MakeHeap_ , std::make_heap , make_heap_ , void , void )
0062 BOOST_MSM_EUML_FUNCTION(SortHeap_ , std::sort_heap , sort_heap_ , void , void )
0063 BOOST_MSM_EUML_FUNCTION(NextPermutation_ , std::next_permutation , next_permutation_ , bool , bool )
0064 BOOST_MSM_EUML_FUNCTION(PrevPermutation_ , std::prev_permutation , prev_permutation_ , bool , bool )
0065 BOOST_MSM_EUML_FUNCTION(InnerProduct_ , std::inner_product , inner_product_ , RESULT_TYPE_PARAM4 , RESULT_TYPE2_PARAM4 )
0066 BOOST_MSM_EUML_FUNCTION(PartialSum_ , std::partial_sum , partial_sum_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 )
0067 BOOST_MSM_EUML_FUNCTION(AdjacentDifference_ , std::adjacent_difference , adjacent_difference_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 )
0068 BOOST_MSM_EUML_FUNCTION(Replace_ , std::replace , replace_ , void , void )
0069 BOOST_MSM_EUML_FUNCTION(ReplaceIf_ , std::replace_if , replace_if_ , void , void )
0070 BOOST_MSM_EUML_FUNCTION(ReplaceCopy_ , std::replace_copy , replace_copy_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 )
0071 BOOST_MSM_EUML_FUNCTION(ReplaceCopyIf_ , std::replace_copy_if , replace_copy_if_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 )
0072
0073
0074
0075 template <class T>
0076 struct BackInserter_ : euml_action<BackInserter_<T> >
0077 {
0078 template <class Event,class FSM,class STATE >
0079 struct state_action_result
0080 {
0081 typedef std::back_insert_iterator<
0082 typename ::boost::remove_reference<
0083 typename get_result_type2<T,Event,FSM,STATE>::type>::type> type;
0084 };
0085 template <class EVT,class FSM,class SourceState,class TargetState>
0086 struct transition_action_result
0087 {
0088 typedef std::back_insert_iterator<
0089 typename ::boost::remove_reference<
0090 typename get_result_type<T,EVT,FSM,SourceState,TargetState>::type>::type> type;
0091 };
0092 typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
0093
0094 template <class EVT,class FSM,class SourceState,class TargetState>
0095 typename ::boost::enable_if<
0096 typename ::boost::mpl::has_key<
0097 typename T::tag_type,action_tag>::type,
0098 typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
0099 operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
0100 {
0101 return std::back_inserter(T()(evt,fsm,src,tgt));
0102 }
0103 template <class Event,class FSM,class STATE>
0104 typename ::boost::enable_if<
0105 typename ::boost::mpl::has_key<
0106 typename T::tag_type,state_action_tag>::type,
0107 typename state_action_result<Event,FSM,STATE>::type >::type
0108 operator()(Event const& evt,FSM& fsm,STATE& state )const
0109 {
0110 return std::back_inserter(T()(evt,fsm,state));
0111 }
0112 };
0113
0114 struct back_inserter_tag {};
0115 struct BackInserter_Helper: proto::extends< proto::terminal<back_inserter_tag>::type, BackInserter_Helper, boost::msm::sm_domain>
0116 {
0117 BackInserter_Helper(){}
0118 template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5
0119 #ifdef BOOST_MSVC
0120 ,class Arg6
0121 #endif
0122 >
0123 struct In
0124 {
0125 typedef BackInserter_<Arg1> type;
0126 };
0127 };
0128 BackInserter_Helper const back_inserter_;
0129
0130 template <class T>
0131 struct FrontInserter_ : euml_action<FrontInserter_<T> >
0132 {
0133 template <class Event,class FSM,class STATE >
0134 struct state_action_result
0135 {
0136 typedef std::front_insert_iterator<
0137 typename ::boost::remove_reference<
0138 typename get_result_type2<T,Event,FSM,STATE>::type>::type> type;
0139 };
0140 template <class EVT,class FSM,class SourceState,class TargetState>
0141 struct transition_action_result
0142 {
0143 typedef std::front_insert_iterator<
0144 typename ::boost::remove_reference<
0145 typename get_result_type<T,EVT,FSM,SourceState,TargetState>::type>::type> type;
0146 };
0147 typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
0148
0149 template <class EVT,class FSM,class SourceState,class TargetState>
0150 typename ::boost::enable_if<
0151 typename ::boost::mpl::has_key<
0152 typename T::tag_type,action_tag>::type,
0153 typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
0154 operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
0155 {
0156 return std::front_inserter(T()(evt,fsm,src,tgt));
0157 }
0158 template <class Event,class FSM,class STATE>
0159 typename ::boost::enable_if<
0160 typename ::boost::mpl::has_key<
0161 typename T::tag_type,state_action_tag>::type,
0162 typename state_action_result<Event,FSM,STATE>::type >::type
0163 operator()(Event const& evt,FSM& fsm,STATE& state )const
0164 {
0165 return std::front_inserter(T()(evt,fsm,state));
0166 }
0167 };
0168
0169 struct front_inserter_tag {};
0170 struct FrontInserter_Helper: proto::extends< proto::terminal<front_inserter_tag>::type, FrontInserter_Helper, boost::msm::sm_domain>
0171 {
0172 FrontInserter_Helper(){}
0173 template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5
0174 #ifdef BOOST_MSVC
0175 ,class Arg6
0176 #endif
0177 >
0178 struct In
0179 {
0180 typedef FrontInserter_<Arg1> type;
0181 };
0182 };
0183 FrontInserter_Helper const front_inserter_;
0184
0185 template <class T,class Pos>
0186 struct Inserter_ : euml_action<Inserter_<T,Pos> >
0187 {
0188 template <class Event,class FSM,class STATE >
0189 struct state_action_result
0190 {
0191 typedef std::insert_iterator<
0192 typename ::boost::remove_reference<
0193 typename get_result_type2<T,Event,FSM,STATE>::type>::type> type;
0194 };
0195 template <class EVT,class FSM,class SourceState,class TargetState>
0196 struct transition_action_result
0197 {
0198 typedef std::insert_iterator<
0199 typename ::boost::remove_reference<
0200 typename get_result_type<T,EVT,FSM,SourceState,TargetState>::type>::type> type;
0201 };
0202 typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
0203
0204 template <class EVT,class FSM,class SourceState,class TargetState>
0205 typename ::boost::enable_if<
0206 typename ::boost::mpl::has_key<
0207 typename T::tag_type,action_tag>::type,
0208 typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
0209 operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
0210 {
0211 return std::inserter(T()(evt,fsm,src,tgt),Pos()(evt,fsm,src,tgt));
0212 }
0213 template <class Event,class FSM,class STATE>
0214 typename ::boost::enable_if<
0215 typename ::boost::mpl::has_key<
0216 typename T::tag_type,state_action_tag>::type,
0217 typename state_action_result<Event,FSM,STATE>::type >::type
0218 operator()(Event const& evt,FSM& fsm,STATE& state )const
0219 {
0220 return std::inserter(T()(evt,fsm,state),Pos()(evt,fsm,state));
0221 }
0222 };
0223
0224 struct inserter_tag {};
0225 struct Inserter_Helper: proto::extends< proto::terminal<inserter_tag>::type, Inserter_Helper, boost::msm::sm_domain>
0226 {
0227 Inserter_Helper(){}
0228 template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5
0229 #ifdef BOOST_MSVC
0230 ,class Arg6
0231 #endif
0232 >
0233 struct In
0234 {
0235 typedef Inserter_<Arg1,Arg2> type;
0236 };
0237 };
0238 Inserter_Helper const inserter_;
0239
0240 template <class Param1, class Param2, class Param3, class Param4, class Param5, class Enable=void >
0241 struct Transform_ : euml_action<Transform_<Param1,Param2,Param3,Param4,Param5,Enable> >
0242 {
0243 };
0244
0245 template <class Param1, class Param2, class Param3, class Param4, class Param5>
0246 struct Transform_<Param1,Param2,Param3,Param4,Param5,
0247 typename ::boost::enable_if<typename ::boost::is_same<Param5,void>::type >::type>
0248 : euml_action<Transform_<Param1,Param2,Param3,Param4,Param5> >
0249 {
0250 template <class Event,class FSM,class STATE >
0251 struct state_action_result
0252 {
0253 typedef typename get_result_type2<Param3,Event,FSM,STATE>::type type;
0254 };
0255 template <class EVT,class FSM,class SourceState,class TargetState>
0256 struct transition_action_result
0257 {
0258 typedef typename get_result_type<Param3,EVT,FSM,SourceState,TargetState>::type type;
0259 };
0260 typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
0261
0262 template <class EVT,class FSM,class SourceState,class TargetState>
0263 typename ::boost::enable_if<
0264 typename ::boost::mpl::has_key<
0265 typename Param1::tag_type,action_tag>::type,
0266 typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
0267 operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
0268 {
0269 return std::transform(Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt),
0270 Param4()(evt,fsm,src,tgt));
0271 }
0272 template <class Event,class FSM,class STATE>
0273 typename ::boost::enable_if<
0274 typename ::boost::mpl::has_key<
0275 typename Param1::tag_type,state_action_tag>::type,
0276 typename state_action_result<Event,FSM,STATE>::type >::type
0277 operator()(Event const& evt,FSM& fsm,STATE& state )const
0278 {
0279 return std::transform(Param1()(evt,fsm,state),Param2()(evt,fsm,state),Param3()(evt,fsm,state),
0280 Param4()(evt,fsm,state));
0281 }
0282 };
0283
0284 template <class Param1, class Param2, class Param3, class Param4, class Param5>
0285 struct Transform_<Param1,Param2,Param3,Param4,Param5,
0286 typename ::boost::disable_if<typename ::boost::is_same<Param5,void>::type >::type>
0287 : euml_action<Transform_<Param1,Param2,Param3,Param4,Param5> >
0288 {
0289 template <class Event,class FSM,class STATE >
0290 struct state_action_result
0291 {
0292 typedef typename get_result_type2<Param4,Event,FSM,STATE>::type type;
0293 };
0294 template <class EVT,class FSM,class SourceState,class TargetState>
0295 struct transition_action_result
0296 {
0297 typedef typename get_result_type<Param4,EVT,FSM,SourceState,TargetState>::type type;
0298 };
0299 typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
0300
0301 template <class EVT,class FSM,class SourceState,class TargetState>
0302 typename ::boost::enable_if<
0303 typename ::boost::mpl::has_key<
0304 typename Param1::tag_type,action_tag>::type,
0305 typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
0306 operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
0307 {
0308 return std::transform (Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt),
0309 Param4()(evt,fsm,src,tgt),Param5()(evt,fsm,src,tgt));
0310 }
0311 template <class Event,class FSM,class STATE>
0312 typename ::boost::enable_if<
0313 typename ::boost::mpl::has_key<
0314 typename Param1::tag_type,state_action_tag>::type,
0315 typename state_action_result<Event,FSM,STATE>::type >::type
0316 operator()(Event const& evt,FSM& fsm,STATE& state )const
0317 {
0318 return std::transform (Param1()(evt,fsm,state),Param2()(evt,fsm,state),Param3()(evt,fsm,state),
0319 Param4()(evt,fsm,state),Param5()(evt,fsm,state));
0320 }
0321 };
0322 struct transform_tag {};
0323 struct Transform_Helper: proto::extends< proto::terminal<transform_tag>::type, Transform_Helper, boost::msm::sm_domain>
0324 {
0325 Transform_Helper(){}
0326 template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5
0327 #ifdef BOOST_MSVC
0328 ,class Arg6
0329 #endif
0330 >
0331 struct In
0332 {
0333 typedef Transform_<Arg1,Arg2,Arg3,Arg4,Arg5> type;
0334 };
0335 };
0336 Transform_Helper const transform_;
0337
0338 }}}}
0339
0340 #endif