operator.hpp 56 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566
  1. // Copyright 2008 Christophe Henry
  2. // henry UNDERSCORE christophe AT hotmail DOT com
  3. // This is an extended version of the state machine available in the boost::mpl library
  4. // Distributed under the same license as the original.
  5. // Copyright for the original version:
  6. // Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed
  7. // under the Boost Software License, Version 1.0. (See accompanying
  8. // file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. #ifndef BOOST_MSM_FRONT_EUML_OPERATOR_H
  11. #define BOOST_MSM_FRONT_EUML_OPERATOR_H
  12. #include <iterator>
  13. #include <boost/msm/front/euml/common.hpp>
  14. #include <boost/type_traits/remove_reference.hpp>
  15. #include <boost/utility/enable_if.hpp>
  16. #include <boost/mpl/has_key.hpp>
  17. #include <boost/mpl/eval_if.hpp>
  18. #include <boost/mpl/set.hpp>
  19. #include <boost/type_traits.hpp>
  20. BOOST_MPL_HAS_XXX_TRAIT_DEF(reference)
  21. BOOST_MPL_HAS_XXX_TRAIT_DEF(key_type)
  22. namespace boost { namespace msm { namespace front { namespace euml
  23. {
  24. template <class T1,class T2>
  25. struct Or_ : euml_action<Or_<T1,T2> >
  26. {
  27. template <class EVT,class FSM,class SourceState,class TargetState>
  28. bool operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)
  29. {
  30. return (T1()(evt,fsm,src,tgt) || T2()(evt,fsm,src,tgt));
  31. }
  32. template <class Event,class FSM,class STATE>
  33. bool operator()(Event const& evt,FSM& fsm,STATE& state)
  34. {
  35. return (T1()(evt,fsm,state) || T2()(evt,fsm,state));
  36. }
  37. };
  38. template <class T1,class T2>
  39. struct And_ : euml_action<And_<T1,T2> >
  40. {
  41. template <class EVT,class FSM,class SourceState,class TargetState>
  42. bool operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)
  43. {
  44. return (T1()(evt,fsm,src,tgt) && T2()(evt,fsm,src,tgt));
  45. }
  46. template <class Event,class FSM,class STATE>
  47. bool operator()(Event const& evt,FSM& fsm,STATE& state)
  48. {
  49. return (T1()(evt,fsm,state) && T2()(evt,fsm,state));
  50. }
  51. };
  52. template <class T1>
  53. struct Not_ : euml_action<Not_<T1> >
  54. {
  55. template <class EVT,class FSM,class SourceState,class TargetState>
  56. bool operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)
  57. {
  58. return !(T1()(evt,fsm,src,tgt));
  59. }
  60. template <class Event,class FSM,class STATE>
  61. bool operator()(Event const& evt,FSM& fsm,STATE& state)
  62. {
  63. return !(T1()(evt,fsm,state));
  64. }
  65. };
  66. template <class Condition,class Action1,class Action2, class Enable=void >
  67. struct If_Else_ : euml_action<If_Else_<Condition,Action1,Action2,Enable> > {};
  68. template <class Condition,class Action1,class Action2>
  69. struct If_Else_<Condition,Action1,Action2
  70. , typename ::boost::enable_if<typename has_tag_type<Action1>::type >::type>
  71. : euml_action<If_Else_<Condition,Action1,Action2> >
  72. {
  73. template <class Event,class FSM,class STATE >
  74. struct state_action_result
  75. {
  76. typedef typename get_result_type2<Action1,Event,FSM,STATE>::type type;
  77. };
  78. template <class EVT,class FSM,class SourceState,class TargetState>
  79. struct transition_action_result
  80. {
  81. typedef typename get_result_type<Action1,EVT,FSM,SourceState,TargetState>::type type;
  82. };
  83. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  84. template <class EVT,class FSM,class SourceState,class TargetState>
  85. typename ::boost::enable_if<
  86. typename ::boost::mpl::has_key<
  87. typename Action1::tag_type,action_tag>::type,
  88. typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
  89. operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  90. {
  91. if (Condition()(evt,fsm,src,tgt))
  92. {
  93. return Action1()(evt,fsm,src,tgt);
  94. }
  95. return Action2()(evt,fsm,src,tgt);
  96. }
  97. template <class Event,class FSM,class STATE>
  98. typename ::boost::enable_if<
  99. typename ::boost::mpl::has_key<
  100. typename Action1::tag_type,state_action_tag>::type,
  101. typename state_action_result<Event,FSM,STATE>::type >::type
  102. operator()(Event const& evt,FSM& fsm,STATE& state )const
  103. {
  104. if (Condition()(evt,fsm,state))
  105. {
  106. return Action1()(evt,fsm,state);
  107. }
  108. return Action2()(evt,fsm,state);
  109. }
  110. };
  111. template <class Condition,class Action1,class Action2>
  112. struct If_Else_<Condition,Action1,Action2
  113. , typename ::boost::disable_if<typename has_tag_type<Action1>::type >::type>
  114. : euml_action<If_Else_<Condition,Action1,Action2> >
  115. {
  116. template <class Event,class FSM,class STATE >
  117. struct state_action_result
  118. {
  119. typedef bool type;
  120. };
  121. template <class EVT,class FSM,class SourceState,class TargetState>
  122. struct transition_action_result
  123. {
  124. typedef bool type;
  125. };
  126. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  127. template <class EVT,class FSM,class SourceState,class TargetState>
  128. bool operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  129. {
  130. if (Condition()(evt,fsm,src,tgt))
  131. {
  132. return Action1()(evt,fsm,src,tgt);
  133. }
  134. return Action2()(evt,fsm,src,tgt);
  135. }
  136. template <class Event,class FSM,class STATE>
  137. bool operator()(Event const& evt,FSM& fsm,STATE& state )const
  138. {
  139. if (Condition()(evt,fsm,state))
  140. {
  141. return Action1()(evt,fsm,state);
  142. }
  143. return Action2()(evt,fsm,state);
  144. }
  145. };
  146. struct if_tag
  147. {
  148. };
  149. struct If : proto::extends<proto::terminal<if_tag>::type, If, boost::msm::sm_domain>
  150. {
  151. If(){}
  152. using proto::extends< proto::terminal<if_tag>::type, If, boost::msm::sm_domain>::operator=;
  153. template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5
  154. #ifdef BOOST_MSVC
  155. ,class Arg6
  156. #endif
  157. >
  158. struct In
  159. {
  160. typedef If_Else_<Arg1,Arg2,Arg3> type;
  161. };
  162. };
  163. If const if_then_else_;
  164. template <class Condition,class Action1, class Enable=void >
  165. struct If_Then_ : euml_action<If_Then_<Condition,Action1,Enable> > {};
  166. template <class Condition,class Action1>
  167. struct If_Then_<Condition,Action1
  168. , typename ::boost::enable_if<typename has_tag_type<Action1>::type >::type>
  169. : euml_action<If_Then_<Condition,Action1> >
  170. {
  171. template <class Event,class FSM,class STATE >
  172. struct state_action_result
  173. {
  174. typedef typename get_result_type2<Action1,Event,FSM,STATE>::type type;
  175. };
  176. template <class EVT,class FSM,class SourceState,class TargetState>
  177. struct transition_action_result
  178. {
  179. typedef typename get_result_type<Action1,EVT,FSM,SourceState,TargetState>::type type;
  180. };
  181. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  182. template <class EVT,class FSM,class SourceState,class TargetState>
  183. typename ::boost::enable_if<
  184. typename ::boost::mpl::has_key<
  185. typename Action1::tag_type,action_tag>::type,
  186. typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
  187. operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  188. {
  189. if (Condition()(evt,fsm,src,tgt))
  190. {
  191. return Action1()(evt,fsm,src,tgt);
  192. }
  193. }
  194. template <class Event,class FSM,class STATE>
  195. typename ::boost::enable_if<
  196. typename ::boost::mpl::has_key<
  197. typename Action1::tag_type,state_action_tag>::type,
  198. typename state_action_result<Event,FSM,STATE>::type >::type
  199. operator()(Event const& evt,FSM& fsm,STATE& state )const
  200. {
  201. if (Condition()(evt,fsm,state))
  202. {
  203. return Action1()(evt,fsm,state);
  204. }
  205. }
  206. };
  207. template <class Condition,class Action1>
  208. struct If_Then_<Condition,Action1
  209. , typename ::boost::disable_if<typename has_tag_type<Action1>::type >::type>
  210. : euml_action<If_Then_<Condition,Action1> >
  211. {
  212. template <class Event,class FSM,class STATE >
  213. struct state_action_result
  214. {
  215. typedef bool type;
  216. };
  217. template <class EVT,class FSM,class SourceState,class TargetState>
  218. struct transition_action_result
  219. {
  220. typedef bool type;
  221. };
  222. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  223. template <class EVT,class FSM,class SourceState,class TargetState>
  224. bool operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  225. {
  226. if (Condition()(evt,fsm,src,tgt))
  227. {
  228. return Action1()(evt,fsm,src,tgt);
  229. }
  230. }
  231. template <class Event,class FSM,class STATE>
  232. bool operator()(Event const& evt,FSM& fsm,STATE& state )const
  233. {
  234. if (Condition()(evt,fsm,state))
  235. {
  236. return Action1()(evt,fsm,state);
  237. }
  238. }
  239. };
  240. struct if_then_tag
  241. {
  242. };
  243. struct If_Then : proto::extends< proto::terminal<if_then_tag>::type, If_Then, boost::msm::sm_domain>
  244. {
  245. If_Then(){}
  246. using proto::extends< proto::terminal<if_then_tag>::type, If_Then, boost::msm::sm_domain>::operator=;
  247. template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5
  248. #ifdef BOOST_MSVC
  249. ,class Arg6
  250. #endif
  251. >
  252. struct In
  253. {
  254. typedef If_Then_<Arg1,Arg2> type;
  255. };
  256. };
  257. If_Then const if_then_;
  258. template <class Condition,class Body>
  259. struct While_Do_ : euml_action<While_Do_<Condition,Body> >
  260. {
  261. template <class Event,class FSM,class STATE >
  262. struct state_action_result
  263. {
  264. typedef void type;
  265. };
  266. template <class EVT,class FSM,class SourceState,class TargetState>
  267. struct transition_action_result
  268. {
  269. typedef void type;
  270. };
  271. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  272. template <class EVT,class FSM,class SourceState,class TargetState>
  273. void operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  274. {
  275. Body body_;
  276. Condition cond_;
  277. while (cond_(evt,fsm,src,tgt))
  278. {
  279. body_(evt,fsm,src,tgt);
  280. }
  281. }
  282. template <class Event,class FSM,class STATE>
  283. void operator()(Event const& evt,FSM& fsm,STATE& state )const
  284. {
  285. Body body_;
  286. Condition cond_;
  287. while (cond_(evt,fsm,state))
  288. {
  289. body_(evt,fsm,state);
  290. }
  291. }
  292. };
  293. struct while_do_tag
  294. {
  295. };
  296. struct While_Do_Helper : proto::extends< proto::terminal<while_do_tag>::type, While_Do_Helper, boost::msm::sm_domain>
  297. {
  298. While_Do_Helper(){}
  299. using proto::extends< proto::terminal<while_do_tag>::type, While_Do_Helper, boost::msm::sm_domain>::operator=;
  300. template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5
  301. #ifdef BOOST_MSVC
  302. ,class Arg6
  303. #endif
  304. >
  305. struct In
  306. {
  307. typedef While_Do_<Arg1,Arg2> type;
  308. };
  309. };
  310. While_Do_Helper const while_;
  311. template <class Condition,class Body>
  312. struct Do_While_ : euml_action<Do_While_<Condition,Body> >
  313. {
  314. template <class Event,class FSM,class STATE >
  315. struct state_action_result
  316. {
  317. typedef void type;
  318. };
  319. template <class EVT,class FSM,class SourceState,class TargetState>
  320. struct transition_action_result
  321. {
  322. typedef void type;
  323. };
  324. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  325. template <class EVT,class FSM,class SourceState,class TargetState>
  326. void operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  327. {
  328. Condition cond_;
  329. Body body_;
  330. do
  331. {
  332. body_(evt,fsm,src,tgt);
  333. } while (cond_(evt,fsm,src,tgt));
  334. }
  335. template <class Event,class FSM,class STATE>
  336. void operator()(Event const& evt,FSM& fsm,STATE& state )const
  337. {
  338. Condition cond_;
  339. Body body_;
  340. do
  341. {
  342. body_(evt,fsm,state);
  343. } while (cond_(evt,fsm,state));
  344. }
  345. };
  346. struct do_while_tag
  347. {
  348. };
  349. struct Do_While_Helper : proto::extends< proto::terminal<do_while_tag>::type, Do_While_Helper, boost::msm::sm_domain>
  350. {
  351. Do_While_Helper(){}
  352. using proto::extends< proto::terminal<do_while_tag>::type, Do_While_Helper, boost::msm::sm_domain>::operator=;
  353. template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5
  354. #ifdef BOOST_MSVC
  355. ,class Arg6
  356. #endif
  357. >
  358. struct In
  359. {
  360. typedef Do_While_<Arg1,Arg2> type;
  361. };
  362. };
  363. Do_While_Helper const do_while_;
  364. template <class Begin,class End,class EndLoop,class Body>
  365. struct For_Loop_ : euml_action<For_Loop_<Begin,End,EndLoop,Body> >
  366. {
  367. template <class Event,class FSM,class STATE >
  368. struct state_action_result
  369. {
  370. typedef void type;
  371. };
  372. template <class EVT,class FSM,class SourceState,class TargetState>
  373. struct transition_action_result
  374. {
  375. typedef void type;
  376. };
  377. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  378. template <class EVT,class FSM,class SourceState,class TargetState>
  379. void operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  380. {
  381. End end_;
  382. EndLoop end_loop_;
  383. Body body_;
  384. for(Begin()(evt,fsm,src,tgt);end_(evt,fsm,src,tgt);end_loop_(evt,fsm,src,tgt))
  385. {
  386. body_(evt,fsm,src,tgt);
  387. }
  388. }
  389. template <class Event,class FSM,class STATE>
  390. void operator()(Event const& evt,FSM& fsm,STATE& state )const
  391. {
  392. End end_;
  393. EndLoop end_loop_;
  394. Body body_;
  395. for(Begin()(evt,fsm,state);end_(evt,fsm,state);end_loop_(evt,fsm,state))
  396. {
  397. body_(evt,fsm,state);
  398. }
  399. }
  400. };
  401. struct for_loop_tag
  402. {
  403. };
  404. struct For_Loop_Helper : proto::extends< proto::terminal<for_loop_tag>::type, For_Loop_Helper, boost::msm::sm_domain>
  405. {
  406. For_Loop_Helper(){}
  407. using proto::extends< proto::terminal<for_loop_tag>::type, For_Loop_Helper, boost::msm::sm_domain>::operator=;
  408. template <class Arg1,class Arg2,class Arg3,class Arg4,class Arg5
  409. #ifdef BOOST_MSVC
  410. ,class Arg6
  411. #endif
  412. >
  413. struct In
  414. {
  415. typedef For_Loop_<Arg1,Arg2,Arg3,Arg4> type;
  416. };
  417. };
  418. For_Loop_Helper const for_;
  419. template <class T>
  420. struct Deref_ : euml_action<Deref_<T> >
  421. {
  422. Deref_(){}
  423. using euml_action<Deref_<T> >::operator=;
  424. template <class Event,class FSM,class STATE >
  425. struct state_action_result
  426. {
  427. typedef typename ::boost::add_reference<
  428. typename std::iterator_traits <
  429. typename ::boost::remove_reference<
  430. typename get_result_type2<T,Event,FSM,STATE>::type>::type>::value_type>::type type;
  431. };
  432. template <class EVT,class FSM,class SourceState,class TargetState>
  433. struct transition_action_result
  434. {
  435. typedef typename ::boost::add_reference<
  436. typename std::iterator_traits<
  437. typename ::boost::remove_reference<
  438. typename get_result_type<T,EVT,FSM,SourceState,TargetState>::type>::type
  439. >::value_type
  440. >::type type;
  441. };
  442. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  443. template <class EVT,class FSM,class SourceState,class TargetState>
  444. typename ::boost::enable_if<
  445. typename ::boost::mpl::has_key<
  446. typename T::tag_type,action_tag>::type,
  447. typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
  448. operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  449. {
  450. return *(T()(evt,fsm,src,tgt));
  451. }
  452. template <class Event,class FSM,class STATE>
  453. typename ::boost::enable_if<
  454. typename ::boost::mpl::has_key<
  455. typename T::tag_type,state_action_tag>::type,
  456. typename state_action_result<Event,FSM,STATE>::type >::type
  457. operator()(Event const& evt,FSM& fsm,STATE& state )const
  458. {
  459. return *(T()(evt,fsm,state));
  460. }
  461. };
  462. template <class T>
  463. struct Pre_inc_ : euml_action<Pre_inc_<T> >
  464. {
  465. using euml_action<Pre_inc_<T> >::operator=;
  466. template <class Event,class FSM,class STATE >
  467. struct state_action_result
  468. {
  469. typedef typename get_result_type2<T,Event,FSM,STATE>::type type;
  470. };
  471. template <class EVT,class FSM,class SourceState,class TargetState>
  472. struct transition_action_result
  473. {
  474. typedef typename get_result_type<T,EVT,FSM,SourceState,TargetState>::type type;
  475. };
  476. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  477. template <class EVT,class FSM,class SourceState,class TargetState>
  478. typename ::boost::enable_if<
  479. typename ::boost::mpl::has_key<
  480. typename T::tag_type,action_tag>::type,
  481. typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
  482. operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  483. {
  484. return ++T()(evt,fsm,src,tgt);
  485. }
  486. template <class Event,class FSM,class STATE>
  487. typename ::boost::enable_if<
  488. typename ::boost::mpl::has_key<
  489. typename T::tag_type,state_action_tag>::type,
  490. typename state_action_result<Event,FSM,STATE>::type >::type
  491. operator()(Event const& evt,FSM& fsm,STATE& state )const
  492. {
  493. return ++T()(evt,fsm,state);
  494. }
  495. };
  496. template <class T>
  497. struct Pre_dec_ : euml_action<Pre_dec_<T> >
  498. {
  499. using euml_action<Pre_dec_<T> >::operator=;
  500. template <class Event,class FSM,class STATE >
  501. struct state_action_result
  502. {
  503. typedef typename get_result_type2<T,Event,FSM,STATE>::type type;
  504. };
  505. template <class EVT,class FSM,class SourceState,class TargetState>
  506. struct transition_action_result
  507. {
  508. typedef typename get_result_type<T,EVT,FSM,SourceState,TargetState>::type type;
  509. };
  510. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  511. template <class EVT,class FSM,class SourceState,class TargetState>
  512. typename ::boost::enable_if<
  513. typename ::boost::mpl::has_key<
  514. typename T::tag_type,action_tag>::type,
  515. typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
  516. operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  517. {
  518. return --T()(evt,fsm,src,tgt);
  519. }
  520. template <class Event,class FSM,class STATE>
  521. typename ::boost::enable_if<
  522. typename ::boost::mpl::has_key<
  523. typename T::tag_type,state_action_tag>::type,
  524. typename state_action_result<Event,FSM,STATE>::type >::type
  525. operator()(Event const& evt,FSM& fsm,STATE& state )const
  526. {
  527. return --T()(evt,fsm,state);
  528. }
  529. };
  530. template <class T>
  531. struct Post_inc_ : euml_action<Post_inc_<T> >
  532. {
  533. using euml_action<Post_inc_<T> >::operator=;
  534. template <class Event,class FSM,class STATE >
  535. struct state_action_result
  536. {
  537. typedef typename ::boost::remove_reference<
  538. typename get_result_type2<T,Event,FSM,STATE>::type>::type type;
  539. };
  540. template <class EVT,class FSM,class SourceState,class TargetState>
  541. struct transition_action_result
  542. {
  543. typedef typename ::boost::remove_reference<
  544. typename get_result_type<T,EVT,FSM,SourceState,TargetState>::type>::type type;
  545. };
  546. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  547. template <class EVT,class FSM,class SourceState,class TargetState>
  548. typename ::boost::enable_if<
  549. typename ::boost::mpl::has_key<
  550. typename T::tag_type,action_tag>::type,
  551. typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
  552. operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  553. {
  554. return T()(evt,fsm,src,tgt)++;
  555. }
  556. template <class Event,class FSM,class STATE>
  557. typename ::boost::enable_if<
  558. typename ::boost::mpl::has_key<
  559. typename T::tag_type,state_action_tag>::type,
  560. typename state_action_result<Event,FSM,STATE>::type >::type
  561. operator()(Event const& evt,FSM& fsm,STATE& state )const
  562. {
  563. return T()(evt,fsm,state)++;
  564. }
  565. };
  566. template <class T>
  567. struct Post_dec_ : euml_action<Post_dec_<T> >
  568. {
  569. using euml_action<Post_dec_<T> >::operator=;
  570. template <class Event,class FSM,class STATE >
  571. struct state_action_result
  572. {
  573. typedef typename ::boost::remove_reference<
  574. typename get_result_type2<T,Event,FSM,STATE>::type>::type type;
  575. };
  576. template <class EVT,class FSM,class SourceState,class TargetState>
  577. struct transition_action_result
  578. {
  579. typedef typename ::boost::remove_reference<
  580. typename get_result_type<T,EVT,FSM,SourceState,TargetState>::type>::type type;
  581. };
  582. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  583. template <class EVT,class FSM,class SourceState,class TargetState>
  584. typename ::boost::enable_if<
  585. typename ::boost::mpl::has_key<
  586. typename T::tag_type,action_tag>::type,
  587. typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
  588. operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  589. {
  590. return T()(evt,fsm,src,tgt)--;
  591. }
  592. template <class Event,class FSM,class STATE>
  593. typename ::boost::enable_if<
  594. typename ::boost::mpl::has_key<
  595. typename T::tag_type,state_action_tag>::type,
  596. typename state_action_result<Event,FSM,STATE>::type >::type
  597. operator()(Event const& evt,FSM& fsm,STATE& state )const
  598. {
  599. return T()(evt,fsm,state)--;
  600. }
  601. };
  602. template <class T1,class T2>
  603. struct Plus_ : euml_action<Plus_<T1,T2> >
  604. {
  605. template <class Event,class FSM,class STATE >
  606. struct state_action_result
  607. {
  608. typedef typename ::boost::remove_reference<
  609. typename get_result_type2<T1,Event,FSM,STATE>::type>::type type;
  610. };
  611. template <class EVT,class FSM,class SourceState,class TargetState>
  612. struct transition_action_result
  613. {
  614. typedef typename ::boost::remove_reference<
  615. typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type>::type type;
  616. };
  617. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  618. template <class EVT,class FSM,class SourceState,class TargetState>
  619. typename ::boost::enable_if<
  620. typename ::boost::mpl::has_key<
  621. typename T1::tag_type,action_tag>::type,
  622. typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
  623. operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  624. {
  625. return T1()(evt,fsm,src,tgt)+T2()(evt,fsm,src,tgt);
  626. }
  627. template <class Event,class FSM,class STATE>
  628. typename ::boost::enable_if<
  629. typename ::boost::mpl::has_key<
  630. typename T1::tag_type,state_action_tag>::type,
  631. typename state_action_result<Event,FSM,STATE>::type >::type
  632. operator()(Event const& evt,FSM& fsm,STATE& state )const
  633. {
  634. return T1()(evt,fsm,state)+T2()(evt,fsm,state);
  635. }
  636. };
  637. template <class T1,class T2>
  638. struct Minus_ : euml_action<Minus_<T1,T2> >
  639. {
  640. template <class Event,class FSM,class STATE >
  641. struct state_action_result
  642. {
  643. typedef typename ::boost::remove_reference<
  644. typename get_result_type2<T1,Event,FSM,STATE>::type>::type type;
  645. };
  646. template <class EVT,class FSM,class SourceState,class TargetState>
  647. struct transition_action_result
  648. {
  649. typedef typename ::boost::remove_reference<
  650. typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type>::type type;
  651. };
  652. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  653. template <class EVT,class FSM,class SourceState,class TargetState>
  654. typename ::boost::enable_if<
  655. typename ::boost::mpl::has_key<
  656. typename T1::tag_type,action_tag>::type,
  657. typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
  658. operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  659. {
  660. return T1()(evt,fsm,src,tgt)-T2()(evt,fsm,src,tgt);
  661. }
  662. template <class Event,class FSM,class STATE>
  663. typename ::boost::enable_if<
  664. typename ::boost::mpl::has_key<
  665. typename T1::tag_type,state_action_tag>::type,
  666. typename state_action_result<Event,FSM,STATE>::type >::type
  667. operator()(Event const& evt,FSM& fsm,STATE& state )const
  668. {
  669. return T1()(evt,fsm,state)-T2()(evt,fsm,state);
  670. }
  671. };
  672. template <class T1,class T2>
  673. struct Multiplies_ : euml_action<Multiplies_<T1,T2> >
  674. {
  675. template <class Event,class FSM,class STATE >
  676. struct state_action_result
  677. {
  678. typedef typename ::boost::remove_reference<
  679. typename get_result_type2<T1,Event,FSM,STATE>::type>::type type;
  680. };
  681. template <class EVT,class FSM,class SourceState,class TargetState>
  682. struct transition_action_result
  683. {
  684. typedef typename ::boost::remove_reference<
  685. typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type>::type type;
  686. };
  687. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  688. template <class EVT,class FSM,class SourceState,class TargetState>
  689. typename ::boost::enable_if<
  690. typename ::boost::mpl::has_key<
  691. typename T1::tag_type,action_tag>::type,
  692. typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
  693. operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  694. {
  695. return T1()(evt,fsm,src,tgt)*T2()(evt,fsm,src,tgt);
  696. }
  697. template <class Event,class FSM,class STATE>
  698. typename ::boost::enable_if<
  699. typename ::boost::mpl::has_key<
  700. typename T1::tag_type,state_action_tag>::type,
  701. typename state_action_result<Event,FSM,STATE>::type >::type
  702. operator()(Event const& evt,FSM& fsm,STATE& state )const
  703. {
  704. return T1()(evt,fsm,state)*T2()(evt,fsm,state);
  705. }
  706. };
  707. template <class T1,class T2>
  708. struct Divides_ : euml_action<Divides_<T1,T2> >
  709. {
  710. template <class Event,class FSM,class STATE >
  711. struct state_action_result
  712. {
  713. typedef typename ::boost::remove_reference<
  714. typename get_result_type2<T1,Event,FSM,STATE>::type>::type type;
  715. };
  716. template <class EVT,class FSM,class SourceState,class TargetState>
  717. struct transition_action_result
  718. {
  719. typedef typename ::boost::remove_reference<
  720. typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type>::type type;
  721. };
  722. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  723. template <class EVT,class FSM,class SourceState,class TargetState>
  724. typename ::boost::enable_if<
  725. typename ::boost::mpl::has_key<
  726. typename T1::tag_type,action_tag>::type,
  727. typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
  728. operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  729. {
  730. return T1()(evt,fsm,src,tgt)/T2()(evt,fsm,src,tgt);
  731. }
  732. template <class Event,class FSM,class STATE>
  733. typename ::boost::enable_if<
  734. typename ::boost::mpl::has_key<
  735. typename T1::tag_type,state_action_tag>::type,
  736. typename state_action_result<Event,FSM,STATE>::type >::type
  737. operator()(Event const& evt,FSM& fsm,STATE& state )const
  738. {
  739. return T1()(evt,fsm,state)/T2()(evt,fsm,state);
  740. }
  741. };
  742. template <class T1,class T2>
  743. struct Modulus_ : euml_action<Modulus_<T1,T2> >
  744. {
  745. template <class Event,class FSM,class STATE >
  746. struct state_action_result
  747. {
  748. typedef typename ::boost::remove_reference<
  749. typename get_result_type2<T1,Event,FSM,STATE>::type>::type type;
  750. };
  751. template <class EVT,class FSM,class SourceState,class TargetState>
  752. struct transition_action_result
  753. {
  754. typedef typename ::boost::remove_reference<
  755. typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type>::type type;
  756. };
  757. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  758. template <class EVT,class FSM,class SourceState,class TargetState>
  759. typename ::boost::enable_if<
  760. typename ::boost::mpl::has_key<
  761. typename T1::tag_type,action_tag>::type,
  762. typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
  763. operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  764. {
  765. return T1()(evt,fsm,src,tgt)%T2()(evt,fsm,src,tgt);
  766. }
  767. template <class Event,class FSM,class STATE>
  768. typename ::boost::enable_if<
  769. typename ::boost::mpl::has_key<
  770. typename T1::tag_type,state_action_tag>::type,
  771. typename state_action_result<Event,FSM,STATE>::type >::type
  772. operator()(Event const& evt,FSM& fsm,STATE& state )const
  773. {
  774. return T1()(evt,fsm,state)%T2()(evt,fsm,state);
  775. }
  776. };
  777. template <class T1,class T2>
  778. struct Bitwise_And_ : euml_action<Bitwise_And_<T1,T2> >
  779. {
  780. template <class Event,class FSM,class STATE >
  781. struct state_action_result
  782. {
  783. typedef typename ::boost::remove_reference<
  784. typename get_result_type2<T1,Event,FSM,STATE>::type>::type type;
  785. };
  786. template <class EVT,class FSM,class SourceState,class TargetState>
  787. struct transition_action_result
  788. {
  789. typedef typename ::boost::remove_reference<
  790. typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type>::type type;
  791. };
  792. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  793. template <class EVT,class FSM,class SourceState,class TargetState>
  794. typename ::boost::enable_if<
  795. typename ::boost::mpl::has_key<
  796. typename T1::tag_type,action_tag>::type,
  797. typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
  798. operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  799. {
  800. return T1()(evt,fsm,src,tgt)&T2()(evt,fsm,src,tgt);
  801. }
  802. template <class Event,class FSM,class STATE>
  803. typename ::boost::enable_if<
  804. typename ::boost::mpl::has_key<
  805. typename T1::tag_type,state_action_tag>::type,
  806. typename state_action_result<Event,FSM,STATE>::type >::type
  807. operator()(Event const& evt,FSM& fsm,STATE& state )const
  808. {
  809. return T1()(evt,fsm,state)&T2()(evt,fsm,state);
  810. }
  811. };
  812. template <class T1,class T2>
  813. struct Bitwise_Or_ : euml_action<Bitwise_Or_<T1,T2> >
  814. {
  815. template <class Event,class FSM,class STATE >
  816. struct state_action_result
  817. {
  818. typedef typename ::boost::remove_reference<
  819. typename get_result_type2<T1,Event,FSM,STATE>::type>::type type;
  820. };
  821. template <class EVT,class FSM,class SourceState,class TargetState>
  822. struct transition_action_result
  823. {
  824. typedef typename ::boost::remove_reference<
  825. typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type>::type type;
  826. };
  827. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  828. template <class EVT,class FSM,class SourceState,class TargetState>
  829. typename ::boost::enable_if<
  830. typename ::boost::mpl::has_key<
  831. typename T1::tag_type,action_tag>::type,
  832. typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
  833. operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  834. {
  835. return T1()(evt,fsm,src,tgt)|T2()(evt,fsm,src,tgt);
  836. }
  837. template <class Event,class FSM,class STATE>
  838. typename ::boost::enable_if<
  839. typename ::boost::mpl::has_key<
  840. typename T1::tag_type,state_action_tag>::type,
  841. typename state_action_result<Event,FSM,STATE>::type >::type
  842. operator()(Event const& evt,FSM& fsm,STATE& state )const
  843. {
  844. return T1()(evt,fsm,state)|T2()(evt,fsm,state);
  845. }
  846. };
  847. template <class T1,class T2>
  848. struct Bitwise_Xor_ : euml_action<Bitwise_Xor_<T1,T2> >
  849. {
  850. template <class Event,class FSM,class STATE >
  851. struct state_action_result
  852. {
  853. typedef typename ::boost::remove_reference<
  854. typename get_result_type2<T1,Event,FSM,STATE>::type>::type type;
  855. };
  856. template <class EVT,class FSM,class SourceState,class TargetState>
  857. struct transition_action_result
  858. {
  859. typedef typename ::boost::remove_reference<
  860. typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type>::type type;
  861. };
  862. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  863. template <class EVT,class FSM,class SourceState,class TargetState>
  864. typename ::boost::enable_if<
  865. typename ::boost::mpl::has_key<
  866. typename T1::tag_type,action_tag>::type,
  867. typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
  868. operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  869. {
  870. return T1()(evt,fsm,src,tgt)^T2()(evt,fsm,src,tgt);
  871. }
  872. template <class Event,class FSM,class STATE>
  873. typename ::boost::enable_if<
  874. typename ::boost::mpl::has_key<
  875. typename T1::tag_type,state_action_tag>::type,
  876. typename state_action_result<Event,FSM,STATE>::type >::type
  877. operator()(Event const& evt,FSM& fsm,STATE& state )const
  878. {
  879. return T1()(evt,fsm,state)^T2()(evt,fsm,state);
  880. }
  881. };
  882. template <class T1,class T2>
  883. struct Subscript_ : euml_action<Subscript_<T1,T2> >
  884. {
  885. template <class T>
  886. struct get_reference
  887. {
  888. typedef typename T::reference type;
  889. };
  890. template <class T>
  891. struct get_mapped_type
  892. {
  893. typedef typename T::value_type::second_type& type;
  894. };
  895. template <class Event,class FSM,class STATE >
  896. struct state_action_result
  897. {
  898. typedef typename ::boost::remove_reference<
  899. typename get_result_type2<T1,Event,FSM,STATE>::type>::type container_type;
  900. typedef typename ::boost::mpl::eval_if<
  901. typename has_key_type<container_type>::type,
  902. get_mapped_type<container_type>,
  903. ::boost::mpl::eval_if<
  904. typename ::boost::is_pointer<container_type>::type,
  905. ::boost::add_reference<typename ::boost::remove_pointer<container_type>::type >,
  906. get_reference<container_type>
  907. >
  908. >::type type;
  909. };
  910. template <class EVT,class FSM,class SourceState,class TargetState>
  911. struct transition_action_result
  912. {
  913. typedef typename ::boost::remove_reference<
  914. typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type>::type container_type;
  915. typedef typename ::boost::mpl::eval_if<
  916. typename has_key_type<container_type>::type,
  917. get_mapped_type<container_type>,
  918. ::boost::mpl::eval_if<
  919. typename ::boost::is_pointer<container_type>::type,
  920. ::boost::add_reference<typename ::boost::remove_pointer<container_type>::type >,
  921. get_reference<container_type>
  922. >
  923. >::type type;
  924. };
  925. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  926. template <class EVT,class FSM,class SourceState,class TargetState>
  927. typename ::boost::enable_if<
  928. typename ::boost::mpl::has_key<
  929. typename T1::tag_type,action_tag>::type,
  930. typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
  931. operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  932. {
  933. return T1()(evt,fsm,src,tgt)[T2()(evt,fsm,src,tgt)];
  934. }
  935. template <class Event,class FSM,class STATE>
  936. typename ::boost::enable_if<
  937. typename ::boost::mpl::has_key<
  938. typename T1::tag_type,state_action_tag>::type,
  939. typename state_action_result<Event,FSM,STATE>::type >::type
  940. operator()(Event const& evt,FSM& fsm,STATE& state )const
  941. {
  942. return T1()(evt,fsm,state)[T2()(evt,fsm,state)];
  943. }
  944. };
  945. template <class T1,class T2>
  946. struct Plus_Assign_ : euml_action<Plus_Assign_<T1,T2> >
  947. {
  948. template <class Event,class FSM,class STATE >
  949. struct state_action_result
  950. {
  951. typedef typename get_result_type2<T1,Event,FSM,STATE>::type type;
  952. };
  953. template <class EVT,class FSM,class SourceState,class TargetState>
  954. struct transition_action_result
  955. {
  956. typedef typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type type;
  957. };
  958. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  959. template <class EVT,class FSM,class SourceState,class TargetState>
  960. typename ::boost::enable_if<
  961. typename ::boost::mpl::has_key<
  962. typename T1::tag_type,action_tag>::type,
  963. typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
  964. operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  965. {
  966. return (T1()(evt,fsm,src,tgt)+=T2()(evt,fsm,src,tgt));
  967. }
  968. template <class Event,class FSM,class STATE>
  969. typename ::boost::enable_if<
  970. typename ::boost::mpl::has_key<
  971. typename T1::tag_type,state_action_tag>::type,
  972. typename state_action_result<Event,FSM,STATE>::type >::type
  973. operator()(Event const& evt,FSM& fsm,STATE& state )const
  974. {
  975. return (T1()(evt,fsm,state)+=T2()(evt,fsm,state));
  976. }
  977. };
  978. template <class T1,class T2>
  979. struct Minus_Assign_ : euml_action<Minus_Assign_<T1,T2> >
  980. {
  981. template <class Event,class FSM,class STATE >
  982. struct state_action_result
  983. {
  984. typedef typename get_result_type2<T1,Event,FSM,STATE>::type type;
  985. };
  986. template <class EVT,class FSM,class SourceState,class TargetState>
  987. struct transition_action_result
  988. {
  989. typedef typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type type;
  990. };
  991. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  992. template <class EVT,class FSM,class SourceState,class TargetState>
  993. typename ::boost::enable_if<
  994. typename ::boost::mpl::has_key<
  995. typename T1::tag_type,action_tag>::type,
  996. typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
  997. operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  998. {
  999. return (T1()(evt,fsm,src,tgt)-=T2()(evt,fsm,src,tgt));
  1000. }
  1001. template <class Event,class FSM,class STATE>
  1002. typename ::boost::enable_if<
  1003. typename ::boost::mpl::has_key<
  1004. typename T1::tag_type,state_action_tag>::type,
  1005. typename state_action_result<Event,FSM,STATE>::type >::type
  1006. operator()(Event const& evt,FSM& fsm,STATE& state )const
  1007. {
  1008. return (T1()(evt,fsm,state)-=T2()(evt,fsm,state));
  1009. }
  1010. };
  1011. template <class T1,class T2>
  1012. struct Multiplies_Assign_ : euml_action<Multiplies_Assign_<T1,T2> >
  1013. {
  1014. template <class Event,class FSM,class STATE >
  1015. struct state_action_result
  1016. {
  1017. typedef typename get_result_type2<T1,Event,FSM,STATE>::type type;
  1018. };
  1019. template <class EVT,class FSM,class SourceState,class TargetState>
  1020. struct transition_action_result
  1021. {
  1022. typedef typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type type;
  1023. };
  1024. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  1025. template <class EVT,class FSM,class SourceState,class TargetState>
  1026. typename ::boost::enable_if<
  1027. typename ::boost::mpl::has_key<
  1028. typename T1::tag_type,action_tag>::type,
  1029. typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
  1030. operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  1031. {
  1032. return (T1()(evt,fsm,src,tgt)*=T2()(evt,fsm,src,tgt));
  1033. }
  1034. template <class Event,class FSM,class STATE>
  1035. typename ::boost::enable_if<
  1036. typename ::boost::mpl::has_key<
  1037. typename T1::tag_type,state_action_tag>::type,
  1038. typename state_action_result<Event,FSM,STATE>::type >::type
  1039. operator()(Event const& evt,FSM& fsm,STATE& state )const
  1040. {
  1041. return (T1()(evt,fsm,state)*=T2()(evt,fsm,state));
  1042. }
  1043. };
  1044. template <class T1,class T2>
  1045. struct Divides_Assign_ : euml_action<Divides_Assign_<T1,T2> >
  1046. {
  1047. template <class Event,class FSM,class STATE >
  1048. struct state_action_result
  1049. {
  1050. typedef typename get_result_type2<T1,Event,FSM,STATE>::type type;
  1051. };
  1052. template <class EVT,class FSM,class SourceState,class TargetState>
  1053. struct transition_action_result
  1054. {
  1055. typedef typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type type;
  1056. };
  1057. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  1058. template <class EVT,class FSM,class SourceState,class TargetState>
  1059. typename ::boost::enable_if<
  1060. typename ::boost::mpl::has_key<
  1061. typename T1::tag_type,action_tag>::type,
  1062. typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
  1063. operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  1064. {
  1065. return (T1()(evt,fsm,src,tgt)/=T2()(evt,fsm,src,tgt));
  1066. }
  1067. template <class Event,class FSM,class STATE>
  1068. typename ::boost::enable_if<
  1069. typename ::boost::mpl::has_key<
  1070. typename T1::tag_type,state_action_tag>::type,
  1071. typename state_action_result<Event,FSM,STATE>::type >::type
  1072. operator()(Event const& evt,FSM& fsm,STATE& state )const
  1073. {
  1074. return (T1()(evt,fsm,state)/=T2()(evt,fsm,state));
  1075. }
  1076. };
  1077. template <class T1,class T2>
  1078. struct Modulus_Assign_ : euml_action<Modulus_Assign_<T1,T2> >
  1079. {
  1080. template <class Event,class FSM,class STATE >
  1081. struct state_action_result
  1082. {
  1083. typedef typename get_result_type2<T1,Event,FSM,STATE>::type type;
  1084. };
  1085. template <class EVT,class FSM,class SourceState,class TargetState>
  1086. struct transition_action_result
  1087. {
  1088. typedef typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type type;
  1089. };
  1090. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  1091. template <class EVT,class FSM,class SourceState,class TargetState>
  1092. typename ::boost::enable_if<
  1093. typename ::boost::mpl::has_key<
  1094. typename T1::tag_type,action_tag>::type,
  1095. typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
  1096. operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  1097. {
  1098. return (T1()(evt,fsm,src,tgt)%=T2()(evt,fsm,src,tgt));
  1099. }
  1100. template <class Event,class FSM,class STATE>
  1101. typename ::boost::enable_if<
  1102. typename ::boost::mpl::has_key<
  1103. typename T1::tag_type,state_action_tag>::type,
  1104. typename state_action_result<Event,FSM,STATE>::type >::type
  1105. operator()(Event const& evt,FSM& fsm,STATE& state )const
  1106. {
  1107. return (T1()(evt,fsm,state)%=T2()(evt,fsm,state));
  1108. }
  1109. };
  1110. template <class T1,class T2>
  1111. struct ShiftLeft_Assign_ : euml_action<ShiftLeft_Assign_<T1,T2> >
  1112. {
  1113. template <class Event,class FSM,class STATE >
  1114. struct state_action_result
  1115. {
  1116. typedef typename get_result_type2<T1,Event,FSM,STATE>::type type;
  1117. };
  1118. template <class EVT,class FSM,class SourceState,class TargetState>
  1119. struct transition_action_result
  1120. {
  1121. typedef typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type type;
  1122. };
  1123. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  1124. template <class EVT,class FSM,class SourceState,class TargetState>
  1125. typename ::boost::enable_if<
  1126. typename ::boost::mpl::has_key<
  1127. typename T1::tag_type,action_tag>::type,
  1128. typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
  1129. operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  1130. {
  1131. return (T1()(evt,fsm,src,tgt)<<=T2()(evt,fsm,src,tgt));
  1132. }
  1133. template <class Event,class FSM,class STATE>
  1134. typename ::boost::enable_if<
  1135. typename ::boost::mpl::has_key<
  1136. typename T1::tag_type,state_action_tag>::type,
  1137. typename state_action_result<Event,FSM,STATE>::type >::type
  1138. operator()(Event const& evt,FSM& fsm,STATE& state )const
  1139. {
  1140. return (T1()(evt,fsm,state)<<=T2()(evt,fsm,state));
  1141. }
  1142. };
  1143. template <class T1,class T2>
  1144. struct ShiftRight_Assign_ : euml_action<ShiftRight_Assign_<T1,T2> >
  1145. {
  1146. template <class Event,class FSM,class STATE >
  1147. struct state_action_result
  1148. {
  1149. typedef typename get_result_type2<T1,Event,FSM,STATE>::type type;
  1150. };
  1151. template <class EVT,class FSM,class SourceState,class TargetState>
  1152. struct transition_action_result
  1153. {
  1154. typedef typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type type;
  1155. };
  1156. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  1157. template <class EVT,class FSM,class SourceState,class TargetState>
  1158. typename ::boost::enable_if<
  1159. typename ::boost::mpl::has_key<
  1160. typename T1::tag_type,action_tag>::type,
  1161. typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
  1162. operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  1163. {
  1164. return (T1()(evt,fsm,src,tgt)>>=T2()(evt,fsm,src,tgt));
  1165. }
  1166. template <class Event,class FSM,class STATE>
  1167. typename ::boost::enable_if<
  1168. typename ::boost::mpl::has_key<
  1169. typename T1::tag_type,state_action_tag>::type,
  1170. typename state_action_result<Event,FSM,STATE>::type >::type
  1171. operator()(Event const& evt,FSM& fsm,STATE& state )const
  1172. {
  1173. return (T1()(evt,fsm,state)>>=T2()(evt,fsm,state));
  1174. }
  1175. };
  1176. template <class T1,class T2>
  1177. struct ShiftLeft_ : euml_action<ShiftLeft_<T1,T2> >
  1178. {
  1179. template <class Event,class FSM,class STATE >
  1180. struct state_action_result
  1181. {
  1182. typedef typename get_result_type2<T1,Event,FSM,STATE>::type type;
  1183. };
  1184. template <class EVT,class FSM,class SourceState,class TargetState>
  1185. struct transition_action_result
  1186. {
  1187. typedef typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type type;
  1188. };
  1189. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  1190. template <class EVT,class FSM,class SourceState,class TargetState>
  1191. typename ::boost::enable_if<
  1192. typename ::boost::mpl::has_key<
  1193. typename T1::tag_type,action_tag>::type,
  1194. typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
  1195. operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  1196. {
  1197. return (T1()(evt,fsm,src,tgt)<<T2()(evt,fsm,src,tgt));
  1198. }
  1199. template <class Event,class FSM,class STATE>
  1200. typename ::boost::enable_if<
  1201. typename ::boost::mpl::has_key<
  1202. typename T1::tag_type,state_action_tag>::type,
  1203. typename state_action_result<Event,FSM,STATE>::type >::type
  1204. operator()(Event const& evt,FSM& fsm,STATE& state )const
  1205. {
  1206. return (T1()(evt,fsm,state)<<T2()(evt,fsm,state));
  1207. }
  1208. };
  1209. template <class T1,class T2>
  1210. struct ShiftRight_ : euml_action<ShiftRight_<T1,T2> >
  1211. {
  1212. template <class Event,class FSM,class STATE >
  1213. struct state_action_result
  1214. {
  1215. typedef typename get_result_type2<T1,Event,FSM,STATE>::type type;
  1216. };
  1217. template <class EVT,class FSM,class SourceState,class TargetState>
  1218. struct transition_action_result
  1219. {
  1220. typedef typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type type;
  1221. };
  1222. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  1223. template <class EVT,class FSM,class SourceState,class TargetState>
  1224. typename ::boost::enable_if<
  1225. typename ::boost::mpl::has_key<
  1226. typename T1::tag_type,action_tag>::type,
  1227. typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
  1228. operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  1229. {
  1230. return (T1()(evt,fsm,src,tgt)>>T2()(evt,fsm,src,tgt));
  1231. }
  1232. template <class Event,class FSM,class STATE>
  1233. typename ::boost::enable_if<
  1234. typename ::boost::mpl::has_key<
  1235. typename T1::tag_type,state_action_tag>::type,
  1236. typename state_action_result<Event,FSM,STATE>::type >::type
  1237. operator()(Event const& evt,FSM& fsm,STATE& state )const
  1238. {
  1239. return (T1()(evt,fsm,state)>>T2()(evt,fsm,state));
  1240. }
  1241. };
  1242. template <class T1,class T2>
  1243. struct Assign_ : euml_action<Assign_<T1,T2> >
  1244. {
  1245. using euml_action< Assign_<T1,T2> >::operator=;
  1246. template <class Event,class FSM,class STATE >
  1247. struct state_action_result
  1248. {
  1249. typedef typename get_result_type2<T1,Event,FSM,STATE>::type type;
  1250. };
  1251. template <class EVT,class FSM,class SourceState,class TargetState>
  1252. struct transition_action_result
  1253. {
  1254. typedef typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type type;
  1255. };
  1256. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  1257. template <class EVT,class FSM,class SourceState,class TargetState>
  1258. typename ::boost::enable_if<
  1259. typename ::boost::mpl::has_key<
  1260. typename T1::tag_type,action_tag>::type,
  1261. typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
  1262. operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  1263. {
  1264. return (T1()(evt,fsm,src,tgt)=T2()(evt,fsm,src,tgt));
  1265. }
  1266. template <class Event,class FSM,class STATE>
  1267. typename ::boost::enable_if<
  1268. typename ::boost::mpl::has_key<
  1269. typename T1::tag_type,state_action_tag>::type,
  1270. typename state_action_result<Event,FSM,STATE>::type >::type
  1271. operator()(Event const& evt,FSM& fsm,STATE& state )const
  1272. {
  1273. return (T1()(evt,fsm,state)=T2()(evt,fsm,state));
  1274. }
  1275. };
  1276. template <class T1>
  1277. struct Unary_Plus_ : euml_action<Unary_Plus_<T1> >
  1278. {
  1279. template <class Event,class FSM,class STATE >
  1280. struct state_action_result
  1281. {
  1282. typedef typename ::boost::remove_reference<
  1283. typename get_result_type2<T1,Event,FSM,STATE>::type>::type type;
  1284. };
  1285. template <class EVT,class FSM,class SourceState,class TargetState>
  1286. struct transition_action_result
  1287. {
  1288. typedef typename ::boost::remove_reference<
  1289. typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type>::type type;
  1290. };
  1291. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  1292. template <class EVT,class FSM,class SourceState,class TargetState>
  1293. typename ::boost::enable_if<
  1294. typename ::boost::mpl::has_key<
  1295. typename T1::tag_type,action_tag>::type,
  1296. typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
  1297. operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  1298. {
  1299. return +T1()(evt,fsm,src,tgt);
  1300. }
  1301. template <class Event,class FSM,class STATE>
  1302. typename ::boost::enable_if<
  1303. typename ::boost::mpl::has_key<
  1304. typename T1::tag_type,state_action_tag>::type,
  1305. typename state_action_result<Event,FSM,STATE>::type >::type
  1306. operator()(Event const& evt,FSM& fsm,STATE& state )const
  1307. {
  1308. return +T1()(evt,fsm,state);
  1309. }
  1310. };
  1311. template <class T1>
  1312. struct Unary_Minus_ : euml_action<Unary_Minus_<T1> >
  1313. {
  1314. template <class Event,class FSM,class STATE >
  1315. struct state_action_result
  1316. {
  1317. typedef typename ::boost::remove_reference<
  1318. typename get_result_type2<T1,Event,FSM,STATE>::type>::type type;
  1319. };
  1320. template <class EVT,class FSM,class SourceState,class TargetState>
  1321. struct transition_action_result
  1322. {
  1323. typedef typename ::boost::remove_reference<
  1324. typename get_result_type<T1,EVT,FSM,SourceState,TargetState>::type>::type type;
  1325. };
  1326. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  1327. template <class EVT,class FSM,class SourceState,class TargetState>
  1328. typename ::boost::enable_if<
  1329. typename ::boost::mpl::has_key<
  1330. typename T1::tag_type,action_tag>::type,
  1331. typename transition_action_result<EVT,FSM,SourceState,TargetState>::type >::type
  1332. operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  1333. {
  1334. return -(T1()(evt,fsm,src,tgt));
  1335. }
  1336. template <class Event,class FSM,class STATE>
  1337. typename ::boost::enable_if<
  1338. typename ::boost::mpl::has_key<
  1339. typename T1::tag_type,state_action_tag>::type,
  1340. typename state_action_result<Event,FSM,STATE>::type >::type
  1341. operator()(Event const& evt,FSM& fsm,STATE& state )const
  1342. {
  1343. return -(T1()(evt,fsm,state));
  1344. }
  1345. };
  1346. template <class T1,class T2>
  1347. struct Less_ : euml_action<Less_<T1,T2> >
  1348. {
  1349. template <class Event,class FSM,class STATE >
  1350. struct state_action_result
  1351. {
  1352. typedef bool type;
  1353. };
  1354. template <class EVT,class FSM,class SourceState,class TargetState>
  1355. struct transition_action_result
  1356. {
  1357. typedef bool type;
  1358. };
  1359. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  1360. template <class EVT,class FSM,class SourceState,class TargetState>
  1361. bool operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  1362. {
  1363. return (T1()(evt,fsm,src,tgt) < T2()(evt,fsm,src,tgt));
  1364. }
  1365. template <class Event,class FSM,class STATE>
  1366. bool operator()(Event const& evt,FSM& fsm,STATE& state)const
  1367. {
  1368. return (T1()(evt,fsm,state) < T2()(evt,fsm,state));
  1369. }
  1370. };
  1371. template <class T1,class T2>
  1372. struct LessEqual_ : euml_action<LessEqual_<T1,T2> >
  1373. {
  1374. template <class Event,class FSM,class STATE >
  1375. struct state_action_result
  1376. {
  1377. typedef bool type;
  1378. };
  1379. template <class EVT,class FSM,class SourceState,class TargetState>
  1380. struct transition_action_result
  1381. {
  1382. typedef bool type;
  1383. };
  1384. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  1385. template <class EVT,class FSM,class SourceState,class TargetState>
  1386. bool operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  1387. {
  1388. return (T1()(evt,fsm,src,tgt) <= T2()(evt,fsm,src,tgt));
  1389. }
  1390. template <class Event,class FSM,class STATE>
  1391. bool operator()(Event const& evt,FSM& fsm,STATE& state)const
  1392. {
  1393. return (T1()(evt,fsm,state) <= T2()(evt,fsm,state));
  1394. }
  1395. };
  1396. template <class T1,class T2>
  1397. struct Greater_ : euml_action<Greater_<T1,T2> >
  1398. {
  1399. template <class Event,class FSM,class STATE >
  1400. struct state_action_result
  1401. {
  1402. typedef bool type;
  1403. };
  1404. template <class EVT,class FSM,class SourceState,class TargetState>
  1405. struct transition_action_result
  1406. {
  1407. typedef bool type;
  1408. };
  1409. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  1410. template <class EVT,class FSM,class SourceState,class TargetState>
  1411. bool operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  1412. {
  1413. return (T1()(evt,fsm,src,tgt) > T2()(evt,fsm,src,tgt));
  1414. }
  1415. template <class Event,class FSM,class STATE>
  1416. bool operator()(Event const& evt,FSM& fsm,STATE& state)const
  1417. {
  1418. return (T1()(evt,fsm,state) > T2()(evt,fsm,state));
  1419. }
  1420. };
  1421. template <class T1,class T2>
  1422. struct GreaterEqual_ : euml_action<GreaterEqual_<T1,T2> >
  1423. {
  1424. template <class Event,class FSM,class STATE >
  1425. struct state_action_result
  1426. {
  1427. typedef bool type;
  1428. };
  1429. template <class EVT,class FSM,class SourceState,class TargetState>
  1430. struct transition_action_result
  1431. {
  1432. typedef bool type;
  1433. };
  1434. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  1435. template <class EVT,class FSM,class SourceState,class TargetState>
  1436. bool operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  1437. {
  1438. return (T1()(evt,fsm,src,tgt) >= T2()(evt,fsm,src,tgt));
  1439. }
  1440. template <class Event,class FSM,class STATE>
  1441. bool operator()(Event const& evt,FSM& fsm,STATE& state)const
  1442. {
  1443. return (T1()(evt,fsm,state) >= T2()(evt,fsm,state));
  1444. }
  1445. };
  1446. template <class T1,class T2>
  1447. struct EqualTo_ : euml_action<EqualTo_<T1,T2> >
  1448. {
  1449. template <class Event,class FSM,class STATE >
  1450. struct state_action_result
  1451. {
  1452. typedef bool type;
  1453. };
  1454. template <class EVT,class FSM,class SourceState,class TargetState>
  1455. struct transition_action_result
  1456. {
  1457. typedef bool type;
  1458. };
  1459. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  1460. template <class EVT,class FSM,class SourceState,class TargetState>
  1461. bool operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  1462. {
  1463. return (T1()(evt,fsm,src,tgt) == T2()(evt,fsm,src,tgt));
  1464. }
  1465. template <class Event,class FSM,class STATE>
  1466. bool operator()(Event const& evt,FSM& fsm,STATE& state)const
  1467. {
  1468. return (T1()(evt,fsm,state) == T2()(evt,fsm,state));
  1469. }
  1470. };
  1471. template <class T1,class T2>
  1472. struct NotEqualTo_ : euml_action<NotEqualTo_<T1,T2> >
  1473. {
  1474. template <class Event,class FSM,class STATE >
  1475. struct state_action_result
  1476. {
  1477. typedef bool type;
  1478. };
  1479. template <class EVT,class FSM,class SourceState,class TargetState>
  1480. struct transition_action_result
  1481. {
  1482. typedef bool type;
  1483. };
  1484. typedef ::boost::mpl::set<state_action_tag,action_tag> tag_type;
  1485. template <class EVT,class FSM,class SourceState,class TargetState>
  1486. bool operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
  1487. {
  1488. return (T1()(evt,fsm,src,tgt) != T2()(evt,fsm,src,tgt));
  1489. }
  1490. template <class Event,class FSM,class STATE>
  1491. bool operator()(Event const& evt,FSM& fsm,STATE& state)const
  1492. {
  1493. return (T1()(evt,fsm,state) != T2()(evt,fsm,state));
  1494. }
  1495. };
  1496. }}}}
  1497. #endif // BOOST_MSM_FRONT_EUML_OPERATOR_H