ipod_functors.hpp 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. // Copyright 2010 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 IPOD_FUNCTORS_HPP
  11. #define IPOD_FUNCTORS_HPP
  12. #include <boost/msm/front/euml/euml.hpp>
  13. BOOST_MSM_EUML_ACTION(NotHolding_Entry)
  14. {
  15. template <class Event,class FSM,class STATE>
  16. void operator()(Event const&,FSM&,STATE& )
  17. {
  18. std::cout << "entering: NotHolding" << std::endl;
  19. }
  20. };
  21. BOOST_MSM_EUML_ACTION(Holding_Entry)
  22. {
  23. template <class Event,class FSM,class STATE>
  24. void operator()(Event const&,FSM&,STATE& )
  25. {
  26. std::cout << "entering: Holding" << std::endl;
  27. }
  28. };
  29. BOOST_MSM_EUML_ACTION(NotPlaying_Entry)
  30. {
  31. template <class Event,class FSM,class STATE>
  32. void operator()(Event const&,FSM&,STATE& )
  33. {
  34. std::cout << "entering: NotPlaying" << std::endl;
  35. }
  36. };
  37. BOOST_MSM_EUML_ACTION(NoMenuMode_Entry)
  38. {
  39. template <class Event,class FSM,class STATE>
  40. void operator()(Event const&,FSM&,STATE& )
  41. {
  42. std::cout << "entering: NoMenuMode" << std::endl;
  43. }
  44. };
  45. BOOST_MSM_EUML_ACTION(NoOnOffButton_Entry)
  46. {
  47. template <class Event,class FSM,class STATE>
  48. void operator()(Event const&,FSM&,STATE& )
  49. {
  50. std::cout << "entering: NoOnOffButton" << std::endl;
  51. }
  52. };
  53. BOOST_MSM_EUML_ACTION(OffDown_Entry)
  54. {
  55. template <class Event,class FSM,class STATE>
  56. void operator()(Event const&,FSM&,STATE& )
  57. {
  58. std::cout << "entering: OffDown" << std::endl;
  59. }
  60. };
  61. BOOST_MSM_EUML_ACTION(PlayerOff_Entry)
  62. {
  63. template <class Event,class FSM,class STATE>
  64. void operator()(Event const&,FSM&,STATE& )
  65. {
  66. std::cout << "entering: PlayerOff" << std::endl;
  67. }
  68. };
  69. BOOST_MSM_EUML_ACTION(CheckMiddleButton_Entry)
  70. {
  71. template <class Event,class FSM,class STATE>
  72. void operator()(Event const&,FSM&,STATE& )
  73. {
  74. std::cout << "entering: CheckMiddleButton" << std::endl;
  75. }
  76. };
  77. BOOST_MSM_EUML_ACTION(Playing_Entry)
  78. {
  79. template <class Event,class FSM,class STATE>
  80. void operator()(Event const&,FSM& fsm,STATE& )
  81. {
  82. std::cout << "entering: Playing" << std::endl;
  83. std::cout << "playing song:" << fsm.get_attribute(m_SongIndex) << std::endl;
  84. }
  85. };
  86. BOOST_MSM_EUML_ACTION(WaitingForNextPrev_Entry)
  87. {
  88. template <class Event,class FSM,class STATE>
  89. void operator()(Event const&,FSM&,STATE& )
  90. {
  91. std::cout << "entering: WaitingForNextPrev" << std::endl;
  92. }
  93. };
  94. BOOST_MSM_EUML_ACTION(Paused_Entry)
  95. {
  96. template <class Event,class FSM,class STATE>
  97. void operator()(Event const&,FSM&,STATE& )
  98. {
  99. std::cout << "entering: Paused" << std::endl;
  100. }
  101. };
  102. BOOST_MSM_EUML_ACTION(WaitingForEnd_Entry)
  103. {
  104. template <class Event,class FSM,class STATE>
  105. void operator()(Event const&,FSM&,STATE& )
  106. {
  107. std::cout << "entering: OffDown" << std::endl;
  108. }
  109. };
  110. BOOST_MSM_EUML_ACTION(NoForward_Entry)
  111. {
  112. template <class Event,class FSM,class STATE>
  113. void operator()(Event const&,FSM&,STATE& )
  114. {
  115. std::cout << "entering: NoForward" << std::endl;
  116. }
  117. };
  118. BOOST_MSM_EUML_ACTION(ForwardPressed_Entry)
  119. {
  120. template <class Event,class FSM,class STATE>
  121. void operator()(Event const&,FSM&,STATE& )
  122. {
  123. std::cout << "entering: ForwardPressed" << std::endl;
  124. }
  125. };
  126. BOOST_MSM_EUML_ACTION(ForwardPressed_Exit)
  127. {
  128. template <class Event,class FSM,class STATE>
  129. void operator()(Event const&,FSM&,STATE& )
  130. {
  131. std::cout << "leaving: ForwardPressed" << std::endl;
  132. }
  133. };
  134. BOOST_MSM_EUML_ACTION(FastForward_Entry)
  135. {
  136. template <class Event,class FSM,class STATE>
  137. void operator()(Event const&,FSM&,STATE& )
  138. {
  139. std::cout << "entering: FastForward" << std::endl;
  140. }
  141. };
  142. BOOST_MSM_EUML_ACTION(FastForward_Exit)
  143. {
  144. template <class Event,class FSM,class STATE>
  145. void operator()(Event const&,FSM&,STATE& )
  146. {
  147. std::cout << "leaving: FastForward" << std::endl;
  148. }
  149. };
  150. BOOST_MSM_EUML_ACTION(StdDisplay_Entry)
  151. {
  152. template <class Event,class FSM,class STATE>
  153. void operator()(Event const&,FSM&,STATE& )
  154. {
  155. std::cout << "entering: StdDisplay" << std::endl;
  156. }
  157. };
  158. BOOST_MSM_EUML_ACTION(SetPosition_Entry)
  159. {
  160. template <class Event,class FSM,class STATE>
  161. void operator()(Event const&,FSM&,STATE& )
  162. {
  163. std::cout << "entering: SetPosition" << std::endl;
  164. }
  165. };
  166. BOOST_MSM_EUML_ACTION(SetMark_Entry)
  167. {
  168. template <class Event,class FSM,class STATE>
  169. void operator()(Event const&,FSM&,STATE& )
  170. {
  171. std::cout << "entering: SetMark" << std::endl;
  172. }
  173. };
  174. BOOST_MSM_EUML_ACTION(PlayingExit_Entry)
  175. {
  176. template <class Event,class FSM,class STATE>
  177. void operator()(Event const&,FSM&,STATE& )
  178. {
  179. std::cout << "entering: PlayingExit" << std::endl;
  180. }
  181. };
  182. BOOST_MSM_EUML_ACTION(WaitingForSongChoice_Entry)
  183. {
  184. template <class Event,class FSM,class STATE>
  185. void operator()(Event const&,FSM&,STATE& )
  186. {
  187. std::cout << "entering: WaitingForSongChoice" << std::endl;
  188. }
  189. };
  190. BOOST_MSM_EUML_ACTION(StartCurrentSong_Entry)
  191. {
  192. template <class Event,class FSM,class STATE>
  193. void operator()(Event const&,FSM&,STATE& )
  194. {
  195. std::cout << "entering: StartCurrentSong" << std::endl;
  196. }
  197. };
  198. BOOST_MSM_EUML_ACTION(MenuExit_Entry)
  199. {
  200. template <class Event,class FSM,class STATE>
  201. void operator()(Event const&,FSM&,STATE& )
  202. {
  203. std::cout << "entering: MenuExit" << std::endl;
  204. }
  205. };
  206. BOOST_MSM_EUML_ACTION(show_selected_song)
  207. {
  208. template <class FSM,class EVT,class SourceState,class TargetState>
  209. void operator()(EVT const& ,FSM& fsm,SourceState& ,TargetState& )
  210. {
  211. std::cout << "selecting song:" << fsm.get_attribute(m_SongIndex) << std::endl;
  212. }
  213. };
  214. BOOST_MSM_EUML_ACTION(do_fast_forward)
  215. {
  216. template <class FSM,class EVT,class SourceState,class TargetState>
  217. void operator()(EVT const& ,FSM& fsm,SourceState& ,TargetState& )
  218. {
  219. std::cout << "moving song forward..." << std::endl;
  220. }
  221. };
  222. BOOST_MSM_EUML_ACTION(show_playing_song)
  223. {
  224. template <class FSM,class EVT,class SourceState,class TargetState>
  225. void operator()(EVT const& ,FSM& fsm,SourceState& ,TargetState& )
  226. {
  227. std::cout << "playing song:" << fsm.get_attribute(m_SongIndex) << std::endl;
  228. }
  229. };
  230. BOOST_MSM_EUML_ACTION(show_player_off)
  231. {
  232. template <class FSM,class EVT,class SourceState,class TargetState>
  233. void operator()(EVT const& ,FSM& fsm,SourceState& ,TargetState& )
  234. {
  235. std::cout << "turning player off" << std::endl;
  236. }
  237. };
  238. BOOST_MSM_EUML_ACTION(show_player_on)
  239. {
  240. template <class FSM,class EVT,class SourceState,class TargetState>
  241. void operator()(EVT const& ,FSM& fsm,SourceState& ,TargetState& )
  242. {
  243. std::cout << "turning player on" << std::endl;
  244. }
  245. };
  246. #endif