termination.hpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #ifndef BOOST_STATECHART_TERMINATION_HPP_INCLUDED
  2. #define BOOST_STATECHART_TERMINATION_HPP_INCLUDED
  3. //////////////////////////////////////////////////////////////////////////////
  4. // Copyright 2002-2006 Andreas Huber Doenni
  5. // Distributed under the Boost Software License, Version 1.0. (See accompany-
  6. // ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. //////////////////////////////////////////////////////////////////////////////
  8. #include <boost/statechart/result.hpp>
  9. namespace boost
  10. {
  11. namespace statechart
  12. {
  13. class event_base;
  14. //////////////////////////////////////////////////////////////////////////////
  15. template< class Event >
  16. class termination
  17. {
  18. public:
  19. //////////////////////////////////////////////////////////////////////////
  20. // The following declarations should be private.
  21. // They are only public because many compilers lack template friends.
  22. //////////////////////////////////////////////////////////////////////////
  23. template< class State, class EventBase, class IdType >
  24. static detail::reaction_result react(
  25. State & stt, const EventBase &, const IdType & eventType )
  26. {
  27. if ( eventType == Event::static_type() )
  28. {
  29. return detail::result_utility::get_result( stt.terminate() );
  30. }
  31. else
  32. {
  33. return detail::no_reaction;
  34. }
  35. }
  36. };
  37. template<>
  38. class termination< event_base >
  39. {
  40. public:
  41. //////////////////////////////////////////////////////////////////////////
  42. // The following declarations should be private.
  43. // They are only public because many compilers lack template friends.
  44. //////////////////////////////////////////////////////////////////////////
  45. template< class State, class EventBase, class IdType >
  46. static detail::reaction_result react(
  47. State & stt, const EventBase &, const IdType & )
  48. {
  49. return detail::result_utility::get_result( stt.terminate() );
  50. }
  51. };
  52. } // namespace statechart
  53. } // namespace boost
  54. #endif