internal_row.hpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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_INTERNAL_ROW_HPP
  11. #define BOOST_MSM_INTERNAL_ROW_HPP
  12. #include <boost/type_traits/is_base_of.hpp>
  13. #include <boost/mpl/bool.hpp>
  14. #include <boost/fusion/include/at_key.hpp>
  15. #include <boost/msm/back/common_types.hpp>
  16. #include <boost/msm/row_tags.hpp>
  17. #include <boost/msm/front/detail/row2_helper.hpp>
  18. namespace boost { namespace msm { namespace front
  19. {
  20. template<
  21. class Event
  22. , typename CalledForAction
  23. , void (CalledForAction::*action)(Event const&)
  24. >
  25. struct a_internal
  26. {
  27. typedef sm_a_i_row_tag row_type_tag;
  28. typedef Event Evt;
  29. template <class FSM,class SourceState,class TargetState,class AllStates>
  30. static ::boost::msm::back::HandledEnum action_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt,
  31. AllStates& all_states)
  32. {
  33. // in this front-end, we don't need to know source and target states
  34. ::boost::msm::front::detail::row2_action_helper<CalledForAction,Event,action>::call_helper
  35. (fsm,evt,src,tgt,all_states,
  36. ::boost::mpl::bool_< ::boost::is_base_of<CalledForAction,FSM>::type::value>());
  37. return ::boost::msm::back::HANDLED_TRUE;
  38. }
  39. };
  40. template<
  41. class Event
  42. , typename CalledForAction
  43. , void (CalledForAction::*action)(Event const&)
  44. , typename CalledForGuard
  45. , bool (CalledForGuard::*guard)(Event const&)
  46. >
  47. struct internal
  48. {
  49. typedef sm_i_row_tag row_type_tag;
  50. typedef Event Evt;
  51. template <class FSM,class SourceState,class TargetState,class AllStates>
  52. static ::boost::msm::back::HandledEnum action_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt,
  53. AllStates& all_states)
  54. {
  55. // in this front-end, we don't need to know source and target states
  56. ::boost::msm::front::detail::row2_action_helper<CalledForAction,Event,action>::call_helper
  57. (fsm,evt,src,tgt,all_states,
  58. ::boost::mpl::bool_< ::boost::is_base_of<CalledForAction,FSM>::type::value>());
  59. return ::boost::msm::back::HANDLED_TRUE;
  60. }
  61. template <class FSM,class SourceState,class TargetState,class AllStates>
  62. static bool guard_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt,
  63. AllStates& all_states)
  64. {
  65. // in this front-end, we don't need to know source and target states
  66. return ::boost::msm::front::detail::row2_guard_helper<CalledForGuard,Event,guard>::call_helper
  67. (fsm,evt,src,tgt,all_states,
  68. ::boost::mpl::bool_< ::boost::is_base_of<CalledForGuard,FSM>::type::value>());
  69. }
  70. };
  71. template<
  72. class Event
  73. , typename CalledForGuard
  74. , bool (CalledForGuard::*guard)(Event const&)
  75. >
  76. struct g_internal
  77. {
  78. typedef sm_g_i_row_tag row_type_tag;
  79. typedef Event Evt;
  80. template <class FSM,class SourceState,class TargetState,class AllStates>
  81. static bool guard_call(FSM& fsm,Event const& evt,SourceState& src,TargetState& tgt,
  82. AllStates& all_states)
  83. {
  84. // in this front-end, we don't need to know source and target states
  85. return ::boost::msm::front::detail::row2_guard_helper<CalledForGuard,Event,guard>::call_helper
  86. (fsm,evt,src,tgt,all_states,
  87. ::boost::mpl::bool_< ::boost::is_base_of<CalledForGuard,FSM>::type::value>());
  88. }
  89. };
  90. template<
  91. class Event
  92. >
  93. struct _internal
  94. {
  95. typedef sm__i_row_tag row_type_tag;
  96. typedef Event Evt;
  97. };
  98. }}}
  99. #endif //BOOST_MSM_INTERNAL_ROW_HPP