annotate DEPENDENCIES/generic/include/boost/msm/front/euml/transformation.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // Copyright 2008 Christophe Henry
Chris@16 2 // henry UNDERSCORE christophe AT hotmail DOT com
Chris@16 3 // This is an extended version of the state machine available in the boost::mpl library
Chris@16 4 // Distributed under the same license as the original.
Chris@16 5 // Copyright for the original version:
Chris@16 6 // Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed
Chris@16 7 // under the Boost Software License, Version 1.0. (See accompanying
Chris@16 8 // file LICENSE_1_0.txt or copy at
Chris@16 9 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 10
Chris@16 11 #ifndef BOOST_MSM_FRONT_EUML_TRANSFORMATION_H
Chris@16 12 #define BOOST_MSM_FRONT_EUML_TRANSFORMATION_H
Chris@16 13
Chris@16 14 #include <algorithm>
Chris@16 15 #include <boost/msm/front/euml/common.hpp>
Chris@16 16
Chris@16 17 namespace boost { namespace msm { namespace front { namespace euml
Chris@16 18 {
Chris@16 19 #ifdef __STL_CONFIG_H
Chris@16 20 BOOST_MSM_EUML_FUNCTION(FillN_ , std::fill_n , fill_n_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 )
Chris@16 21 BOOST_MSM_EUML_FUNCTION(Rotate_ , std::rotate , rotate_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 )
Chris@16 22 BOOST_MSM_EUML_FUNCTION(GenerateN_ , std::generate_n , generate_n_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 )
Chris@16 23
Chris@16 24 #else
Chris@16 25 BOOST_MSM_EUML_FUNCTION(FillN_ , std::fill_n , fill_n_ , void , void )
Chris@16 26 BOOST_MSM_EUML_FUNCTION(Rotate_ , std::rotate , rotate_ , void , void )
Chris@16 27 BOOST_MSM_EUML_FUNCTION(GenerateN_ , std::generate_n , generate_n_ , void , void )
Chris@16 28 #endif
Chris@16 29
Chris@16 30 BOOST_MSM_EUML_FUNCTION(Copy_ , std::copy , copy_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 )
Chris@16 31 BOOST_MSM_EUML_FUNCTION(CopyBackward_ , std::copy_backward , copy_backward_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 )
Chris@16 32 BOOST_MSM_EUML_FUNCTION(Reverse_ , std::reverse , reverse_ , void , void )
Chris@16 33 BOOST_MSM_EUML_FUNCTION(ReverseCopy_ , std::reverse_copy , reverse_copy_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 )
Chris@16 34 BOOST_MSM_EUML_FUNCTION(Remove_ , std::remove , remove_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 )
Chris@16 35 BOOST_MSM_EUML_FUNCTION(RemoveIf_ , std::remove_if , remove_if_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 )
Chris@16 36 BOOST_MSM_EUML_FUNCTION(RemoveCopy_ , std::remove_copy , remove_copy_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 )
Chris@16 37 BOOST_MSM_EUML_FUNCTION(RemoveCopyIf_ , std::remove_copy_if , remove_copy_if_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 )
Chris@16 38 BOOST_MSM_EUML_FUNCTION(Fill_ , std::fill , fill_ , void , void )
Chris@16 39 BOOST_MSM_EUML_FUNCTION(Generate_ , std::generate , generate_ , void , void )
Chris@16 40 BOOST_MSM_EUML_FUNCTION(Unique_ , std::unique , unique_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 )
Chris@16 41 BOOST_MSM_EUML_FUNCTION(UniqueCopy_ , std::unique_copy , unique_copy_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 )
Chris@16 42 BOOST_MSM_EUML_FUNCTION(RandomShuffle_ , std::random_shuffle , random_shuffle_ , void , void )
Chris@16 43 BOOST_MSM_EUML_FUNCTION(RotateCopy_ , std::rotate_copy , rotate_copy_ , RESULT_TYPE_PARAM4 , RESULT_TYPE2_PARAM4 )
Chris@16 44 BOOST_MSM_EUML_FUNCTION(Partition_ , std::partition , partition_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 )
Chris@16 45 BOOST_MSM_EUML_FUNCTION(StablePartition_ , std::stable_partition , stable_partition_ , RESULT_TYPE_PARAM1 , RESULT_TYPE2_PARAM1 )
Chris@16 46 BOOST_MSM_EUML_FUNCTION(Sort_ , std::sort , sort_ , void , void )
Chris@16 47 BOOST_MSM_EUML_FUNCTION(StableSort_ , std::stable_sort , stable_sort_ , void , void )
Chris@16 48 BOOST_MSM_EUML_FUNCTION(PartialSort_ , std::partial_sort , partial_sort_ , void , void )
Chris@16 49 BOOST_MSM_EUML_FUNCTION(PartialSortCopy_ , std::partial_sort_copy , partial_sort_copy_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 )
Chris@16 50 BOOST_MSM_EUML_FUNCTION(NthElement_ , std::nth_element , nth_element_ , void , void )
Chris@16 51 BOOST_MSM_EUML_FUNCTION(Merge_ , std::merge , merge_ , RESULT_TYPE_PARAM5 , RESULT_TYPE2_PARAM5 )
Chris@16 52 BOOST_MSM_EUML_FUNCTION(InplaceMerge_ , std::inplace_merge , inplace_merge_ , void , void )
Chris@16 53 BOOST_MSM_EUML_FUNCTION(SetUnion_ , std::set_union , set_union_ , RESULT_TYPE_PARAM5 , RESULT_TYPE2_PARAM5 )
Chris@16 54 BOOST_MSM_EUML_FUNCTION(PushHeap_ , std::push_heap , push_heap_ , void , void )
Chris@16 55 BOOST_MSM_EUML_FUNCTION(PopHeap_ , std::pop_heap , pop_heap_ , void , void )
Chris@16 56 BOOST_MSM_EUML_FUNCTION(MakeHeap_ , std::make_heap , make_heap_ , void , void )
Chris@16 57 BOOST_MSM_EUML_FUNCTION(SortHeap_ , std::sort_heap , sort_heap_ , void , void )
Chris@16 58 BOOST_MSM_EUML_FUNCTION(NextPermutation_ , std::next_permutation , next_permutation_ , bool , bool )
Chris@16 59 BOOST_MSM_EUML_FUNCTION(PrevPermutation_ , std::prev_permutation , prev_permutation_ , bool , bool )
Chris@16 60 BOOST_MSM_EUML_FUNCTION(InnerProduct_ , std::inner_product , inner_product_ , RESULT_TYPE_PARAM4 , RESULT_TYPE2_PARAM4 )
Chris@16 61 BOOST_MSM_EUML_FUNCTION(PartialSum_ , std::partial_sum , partial_sum_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 )
Chris@16 62 BOOST_MSM_EUML_FUNCTION(AdjacentDifference_ , std::adjacent_difference , adjacent_difference_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 )
Chris@16 63 BOOST_MSM_EUML_FUNCTION(Replace_ , std::replace , replace_ , void , void )
Chris@16 64 BOOST_MSM_EUML_FUNCTION(ReplaceIf_ , std::replace_if , replace_if_ , void , void )
Chris@16 65 BOOST_MSM_EUML_FUNCTION(ReplaceCopy_ , std::replace_copy , replace_copy_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 )
Chris@16 66 BOOST_MSM_EUML_FUNCTION(ReplaceCopyIf_ , std::replace_copy_if , replace_copy_if_ , RESULT_TYPE_PARAM3 , RESULT_TYPE2_PARAM3 )
Chris@16 67
Chris@16 68
Chris@16 69
Chris@16 70 template <class T>
Chris@16 71 struct BackInserter_ : euml_action<BackInserter_<T> >
Chris@16 72 {
Chris@16 73 template <class Event,class FSM,class STATE >
Chris@16 74 struct state_action_result
Chris@16 75 {
Chris@16 76 typedef std::back_insert_iterator<
Chris@16 77 typename ::boost::remove_reference<
Chris@16 78 typename get_result_type2<T,Event,FSM,STATE>::type>::type> type;
Chris@16 79 };
Chris@16 80 template <class EVT,class FSM,class SourceState,class TargetState>
Chris@16 81 struct transition_action_result
Chris@16 82 {
Chris@16 83 typedef std::back_insert_iterator<
Chris@16 84 typename ::boost::remove_reference<
Chris@16 85 typename get_result_type<T,EVT,FSM,SourceState,TargetState>::type>::type> type;
Chris@16 86 };
Chris@16 87 typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
Chris@16 88
Chris@16 89 template <class EVT,class FSM,class SourceState,class TargetState>
Chris@16 90 typename ::boost::enable_if<
Chris@16 91 typename ::boost::mpl::has_key<
Chris@16 92 typename T::tag_type,action_tag>::type,
Chris@16 93 typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
Chris@16 94 operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
Chris@16 95 {
Chris@16 96 return std::back_inserter(T()(evt,fsm,src,tgt));
Chris@16 97 }
Chris@16 98 template <class Event,class FSM,class STATE>
Chris@16 99 typename ::boost::enable_if<
Chris@16 100 typename ::boost::mpl::has_key<
Chris@16 101 typename T::tag_type,state_action_tag>::type,
Chris@16 102 typename state_action_result<Event,FSM,STATE>::type >::type
Chris@16 103 operator()(Event const& evt,FSM& fsm,STATE& state )const
Chris@16 104 {
Chris@16 105 return std::back_inserter(T()(evt,fsm,state));
Chris@16 106 }
Chris@16 107 };
Chris@16 108
Chris@16 109 struct back_inserter_tag {};
Chris@16 110 struct BackInserter_Helper: proto::extends< proto::terminal<back_inserter_tag>::type, BackInserter_Helper, boost::msm::sm_domain>
Chris@16 111 {
Chris@16 112 BackInserter_Helper(){}
Chris@16 113 template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5
Chris@16 114 #ifdef BOOST_MSVC
Chris@16 115 ,class Arg6
Chris@16 116 #endif
Chris@16 117 >
Chris@16 118 struct In
Chris@16 119 {
Chris@16 120 typedef BackInserter_<Arg1> type;
Chris@16 121 };
Chris@16 122 };
Chris@16 123 BackInserter_Helper const back_inserter_;
Chris@16 124
Chris@16 125 template <class T>
Chris@16 126 struct FrontInserter_ : euml_action<FrontInserter_<T> >
Chris@16 127 {
Chris@16 128 template <class Event,class FSM,class STATE >
Chris@16 129 struct state_action_result
Chris@16 130 {
Chris@16 131 typedef std::front_insert_iterator<
Chris@16 132 typename ::boost::remove_reference<
Chris@16 133 typename get_result_type2<T,Event,FSM,STATE>::type>::type> type;
Chris@16 134 };
Chris@16 135 template <class EVT,class FSM,class SourceState,class TargetState>
Chris@16 136 struct transition_action_result
Chris@16 137 {
Chris@16 138 typedef std::front_insert_iterator<
Chris@16 139 typename ::boost::remove_reference<
Chris@16 140 typename get_result_type<T,EVT,FSM,SourceState,TargetState>::type>::type> type;
Chris@16 141 };
Chris@16 142 typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
Chris@16 143
Chris@16 144 template <class EVT,class FSM,class SourceState,class TargetState>
Chris@16 145 typename ::boost::enable_if<
Chris@16 146 typename ::boost::mpl::has_key<
Chris@16 147 typename T::tag_type,action_tag>::type,
Chris@16 148 typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
Chris@16 149 operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
Chris@16 150 {
Chris@16 151 return std::front_inserter(T()(evt,fsm,src,tgt));
Chris@16 152 }
Chris@16 153 template <class Event,class FSM,class STATE>
Chris@16 154 typename ::boost::enable_if<
Chris@16 155 typename ::boost::mpl::has_key<
Chris@16 156 typename T::tag_type,state_action_tag>::type,
Chris@16 157 typename state_action_result<Event,FSM,STATE>::type >::type
Chris@16 158 operator()(Event const& evt,FSM& fsm,STATE& state )const
Chris@16 159 {
Chris@16 160 return std::front_inserter(T()(evt,fsm,state));
Chris@16 161 }
Chris@16 162 };
Chris@16 163
Chris@16 164 struct front_inserter_tag {};
Chris@16 165 struct FrontInserter_Helper: proto::extends< proto::terminal<front_inserter_tag>::type, FrontInserter_Helper, boost::msm::sm_domain>
Chris@16 166 {
Chris@16 167 FrontInserter_Helper(){}
Chris@16 168 template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5
Chris@16 169 #ifdef BOOST_MSVC
Chris@16 170 ,class Arg6
Chris@16 171 #endif
Chris@16 172 >
Chris@16 173 struct In
Chris@16 174 {
Chris@16 175 typedef FrontInserter_<Arg1> type;
Chris@16 176 };
Chris@16 177 };
Chris@16 178 FrontInserter_Helper const front_inserter_;
Chris@16 179
Chris@16 180 template <class T,class Pos>
Chris@16 181 struct Inserter_ : euml_action<Inserter_<T,Pos> >
Chris@16 182 {
Chris@16 183 template <class Event,class FSM,class STATE >
Chris@16 184 struct state_action_result
Chris@16 185 {
Chris@16 186 typedef std::insert_iterator<
Chris@16 187 typename ::boost::remove_reference<
Chris@16 188 typename get_result_type2<T,Event,FSM,STATE>::type>::type> type;
Chris@16 189 };
Chris@16 190 template <class EVT,class FSM,class SourceState,class TargetState>
Chris@16 191 struct transition_action_result
Chris@16 192 {
Chris@16 193 typedef std::insert_iterator<
Chris@16 194 typename ::boost::remove_reference<
Chris@16 195 typename get_result_type<T,EVT,FSM,SourceState,TargetState>::type>::type> type;
Chris@16 196 };
Chris@16 197 typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
Chris@16 198
Chris@16 199 template <class EVT,class FSM,class SourceState,class TargetState>
Chris@16 200 typename ::boost::enable_if<
Chris@16 201 typename ::boost::mpl::has_key<
Chris@16 202 typename T::tag_type,action_tag>::type,
Chris@16 203 typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
Chris@16 204 operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
Chris@16 205 {
Chris@16 206 return std::inserter(T()(evt,fsm,src,tgt),Pos()(evt,fsm,src,tgt));
Chris@16 207 }
Chris@16 208 template <class Event,class FSM,class STATE>
Chris@16 209 typename ::boost::enable_if<
Chris@16 210 typename ::boost::mpl::has_key<
Chris@16 211 typename T::tag_type,state_action_tag>::type,
Chris@16 212 typename state_action_result<Event,FSM,STATE>::type >::type
Chris@16 213 operator()(Event const& evt,FSM& fsm,STATE& state )const
Chris@16 214 {
Chris@16 215 return std::inserter(T()(evt,fsm,state),Pos()(evt,fsm,state));
Chris@16 216 }
Chris@16 217 };
Chris@16 218
Chris@16 219 struct inserter_tag {};
Chris@16 220 struct Inserter_Helper: proto::extends< proto::terminal<inserter_tag>::type, Inserter_Helper, boost::msm::sm_domain>
Chris@16 221 {
Chris@16 222 Inserter_Helper(){}
Chris@16 223 template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5
Chris@16 224 #ifdef BOOST_MSVC
Chris@16 225 ,class Arg6
Chris@16 226 #endif
Chris@16 227 >
Chris@16 228 struct In
Chris@16 229 {
Chris@16 230 typedef Inserter_<Arg1,Arg2> type;
Chris@16 231 };
Chris@16 232 };
Chris@16 233 Inserter_Helper const inserter_;
Chris@16 234
Chris@16 235 template <class Param1, class Param2, class Param3, class Param4, class Param5, class Enable=void >
Chris@16 236 struct Transform_ : euml_action<Transform_<Param1,Param2,Param3,Param4,Param5,Enable> >
Chris@16 237 {
Chris@16 238 };
Chris@16 239
Chris@16 240 template <class Param1, class Param2, class Param3, class Param4, class Param5>
Chris@16 241 struct Transform_<Param1,Param2,Param3,Param4,Param5,
Chris@16 242 typename ::boost::enable_if<typename ::boost::is_same<Param5,void>::type >::type>
Chris@16 243 : euml_action<Transform_<Param1,Param2,Param3,Param4,Param5> >
Chris@16 244 {
Chris@16 245 template <class Event,class FSM,class STATE >
Chris@16 246 struct state_action_result
Chris@16 247 {
Chris@16 248 typedef typename get_result_type2<Param3,Event,FSM,STATE>::type type;
Chris@16 249 };
Chris@16 250 template <class EVT,class FSM,class SourceState,class TargetState>
Chris@16 251 struct transition_action_result
Chris@16 252 {
Chris@16 253 typedef typename get_result_type<Param3,EVT,FSM,SourceState,TargetState>::type type;
Chris@16 254 };
Chris@16 255 typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
Chris@16 256
Chris@16 257 template <class EVT,class FSM,class SourceState,class TargetState>
Chris@16 258 typename ::boost::enable_if<
Chris@16 259 typename ::boost::mpl::has_key<
Chris@16 260 typename Param1::tag_type,action_tag>::type,
Chris@16 261 typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
Chris@16 262 operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
Chris@16 263 {
Chris@16 264 return std::transform(Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt),
Chris@16 265 Param4()(evt,fsm,src,tgt));
Chris@16 266 }
Chris@16 267 template <class Event,class FSM,class STATE>
Chris@16 268 typename ::boost::enable_if<
Chris@16 269 typename ::boost::mpl::has_key<
Chris@16 270 typename Param1::tag_type,state_action_tag>::type,
Chris@16 271 typename state_action_result<Event,FSM,STATE>::type >::type
Chris@16 272 operator()(Event const& evt,FSM& fsm,STATE& state )const
Chris@16 273 {
Chris@16 274 return std::transform(Param1()(evt,fsm,state),Param2()(evt,fsm,state),Param3()(evt,fsm,state),
Chris@16 275 Param4()(evt,fsm,state));
Chris@16 276 }
Chris@16 277 };
Chris@16 278
Chris@16 279 template <class Param1, class Param2, class Param3, class Param4, class Param5>
Chris@16 280 struct Transform_<Param1,Param2,Param3,Param4,Param5,
Chris@16 281 typename ::boost::disable_if<typename ::boost::is_same<Param5,void>::type >::type>
Chris@16 282 : euml_action<Transform_<Param1,Param2,Param3,Param4,Param5> >
Chris@16 283 {
Chris@16 284 template <class Event,class FSM,class STATE >
Chris@16 285 struct state_action_result
Chris@16 286 {
Chris@16 287 typedef typename get_result_type2<Param4,Event,FSM,STATE>::type type;
Chris@16 288 };
Chris@16 289 template <class EVT,class FSM,class SourceState,class TargetState>
Chris@16 290 struct transition_action_result
Chris@16 291 {
Chris@16 292 typedef typename get_result_type<Param4,EVT,FSM,SourceState,TargetState>::type type;
Chris@16 293 };
Chris@16 294 typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
Chris@16 295
Chris@16 296 template <class EVT,class FSM,class SourceState,class TargetState>
Chris@16 297 typename ::boost::enable_if<
Chris@16 298 typename ::boost::mpl::has_key<
Chris@16 299 typename Param1::tag_type,action_tag>::type,
Chris@16 300 typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
Chris@16 301 operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
Chris@16 302 {
Chris@16 303 return std::transform (Param1()(evt,fsm,src,tgt),Param2()(evt,fsm,src,tgt),Param3()(evt,fsm,src,tgt),
Chris@16 304 Param4()(evt,fsm,src,tgt),Param5()(evt,fsm,src,tgt));
Chris@16 305 }
Chris@16 306 template <class Event,class FSM,class STATE>
Chris@16 307 typename ::boost::enable_if<
Chris@16 308 typename ::boost::mpl::has_key<
Chris@16 309 typename Param1::tag_type,state_action_tag>::type,
Chris@16 310 typename state_action_result<Event,FSM,STATE>::type >::type
Chris@16 311 operator()(Event const& evt,FSM& fsm,STATE& state )const
Chris@16 312 {
Chris@16 313 return std::transform (Param1()(evt,fsm,state),Param2()(evt,fsm,state),Param3()(evt,fsm,state),
Chris@16 314 Param4()(evt,fsm,state),Param5()(evt,fsm,state));
Chris@16 315 }
Chris@16 316 };
Chris@16 317 struct transform_tag {};
Chris@16 318 struct Transform_Helper: proto::extends< proto::terminal<transform_tag>::type, Transform_Helper, boost::msm::sm_domain>
Chris@16 319 {
Chris@16 320 Transform_Helper(){}
Chris@16 321 template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5
Chris@16 322 #ifdef BOOST_MSVC
Chris@16 323 ,class Arg6
Chris@16 324 #endif
Chris@16 325 >
Chris@16 326 struct In
Chris@16 327 {
Chris@16 328 typedef Transform_<Arg1,Arg2,Arg3,Arg4,Arg5> type;
Chris@16 329 };
Chris@16 330 };
Chris@16 331 Transform_Helper const transform_;
Chris@16 332
Chris@16 333 }}}}
Chris@16 334
Chris@16 335 #endif //BOOST_MSM_FRONT_EUML_TRANSFORMATION_H