active_state_switching_policies.hpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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_ACTIVE_STATE_SWITCHING_POLICIES_H
  11. #define BOOST_MSM_ACTIVE_STATE_SWITCHING_POLICIES_H
  12. namespace boost { namespace msm
  13. {
  14. // policy classes
  15. // Default: new active state set after the transition (after entry)
  16. struct active_state_switch_after_entry
  17. {
  18. static int after_guard(int current_state,int){return current_state;}
  19. static int after_exit(int current_state,int){return current_state;}
  20. static int after_action(int current_state,int){return current_state;}
  21. static int after_entry(int,int next_state){return next_state;}
  22. };
  23. // new state set before the transition starts
  24. struct active_state_switch_before_transition
  25. {
  26. static int after_guard(int,int next_state){return next_state;}
  27. static int after_exit(int,int next_state){return next_state;}
  28. static int after_action(int,int next_state){return next_state;}
  29. static int after_entry(int,int next_state){return next_state;}
  30. };
  31. // new state set after exit action completed
  32. struct active_state_switch_after_exit
  33. {
  34. static int after_guard(int current_state,int){return current_state;}
  35. static int after_exit(int,int next_state){return next_state;}
  36. static int after_action(int,int next_state){return next_state;}
  37. static int after_entry(int,int next_state){return next_state;}
  38. };
  39. // new state set after transition action completed
  40. struct active_state_switch_after_transition_action
  41. {
  42. static int after_guard(int current_state,int){return current_state;}
  43. static int after_exit(int current_state,int){return current_state;}
  44. static int after_action(int,int next_state){return next_state;}
  45. static int after_entry(int,int next_state){return next_state;}
  46. };
  47. } }//boost::msm
  48. #endif //BOOST_MSM_ACTIVE_STATE_SWITCHING_POLICIES_H