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