transition.hpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #ifndef BOOST_FSM_TRANSITION_INCLUDED
  2. #define BOOST_FSM_TRANSITION_INCLUDED
  3. // Copyright Aleksey Gurtovoy 2002-2004
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. // See http://www.boost.org/libs/mpl for documentation.
  10. // $Id$
  11. // $Date$
  12. // $Revision$
  13. #include <cassert>
  14. namespace fsm { namespace aux {
  15. // represent a signle transition between states |From| and |To|
  16. template<
  17. typename T
  18. , typename From
  19. , typename Event
  20. , typename To
  21. , bool (T::* transition_func)(Event const&)
  22. >
  23. struct transition
  24. {
  25. typedef T fsm_t;
  26. typedef From from_state_t;
  27. typedef Event event_t;
  28. typedef To to_state_t;
  29. typedef typename Event::base_t base_event_t;
  30. static bool do_transition(T& x, base_event_t const& e)
  31. {
  32. assert(dynamic_cast<event_t const*>(&e) == &e);
  33. return (x.*transition_func)(static_cast<event_t const &>(e));
  34. }
  35. };
  36. }}
  37. #endif // BOOST_FSM_TRANSITION_INCLUDED