state.hpp 802 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #ifndef BOOST_FSM_STATE_INCLUDED
  2. #define BOOST_FSM_STATE_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 <boost/mpl/integral_c.hpp>
  14. namespace fsm { namespace aux {
  15. namespace mpl = boost::mpl;
  16. // represent a FSM state
  17. template<
  18. typename T
  19. , long State
  20. , void (T::* invariant_func)() const
  21. >
  22. struct state
  23. : mpl::integral_c<long,State>
  24. {
  25. static long do_check_invariant(T const& x)
  26. {
  27. if (invariant_func) (x.*invariant_func)();
  28. return State;
  29. }
  30. };
  31. }}
  32. #endif // BOOST_FSM_STATE_INCLUDED