InnermostDefault.hpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #ifndef BOOST_STATECHART_TEST_INNERMOST_DEFAULT_HPP_INCLUDED
  2. #define BOOST_STATECHART_TEST_INNERMOST_DEFAULT_HPP_INCLUDED
  3. //////////////////////////////////////////////////////////////////////////////
  4. // Copyright 2004-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/state.hpp>
  9. namespace sc = boost::statechart;
  10. //////////////////////////////////////////////////////////////////////////////
  11. template< class MostDerived, class Context >
  12. struct InnermostDefault : sc::state< MostDerived, Context >
  13. {
  14. typedef sc::state< MostDerived, Context > base_type;
  15. typedef typename base_type::my_context my_context;
  16. typedef InnermostDefault my_base;
  17. InnermostDefault( my_context ctx ) : base_type( ctx )
  18. {
  19. this->outermost_context().template ActualEntry< MostDerived >();
  20. }
  21. ~InnermostDefault()
  22. {
  23. this->outermost_context().template ActualDestructor< MostDerived >();
  24. }
  25. void exit()
  26. {
  27. this->outermost_context().template ActualExitFunction< MostDerived >();
  28. }
  29. };
  30. //////////////////////////////////////////////////////////////////////////////
  31. template< class Context >
  32. struct Default0 : InnermostDefault<
  33. Default0< Context >, typename Context::template orthogonal< 0 > >
  34. {
  35. typedef InnermostDefault<
  36. Default0, typename Context::template orthogonal< 0 > > base_type;
  37. typedef typename base_type::my_context my_context;
  38. Default0( my_context ctx ) : base_type( ctx ) {}
  39. };
  40. //////////////////////////////////////////////////////////////////////////////
  41. template< class Context >
  42. struct Default1 : InnermostDefault<
  43. Default1< Context >, typename Context::template orthogonal< 1 > >
  44. {
  45. typedef InnermostDefault<
  46. Default1, typename Context::template orthogonal< 1 > > base_type;
  47. typedef typename base_type::my_context my_context;
  48. Default1( my_context ctx ) : base_type( ctx ) {}
  49. };
  50. //////////////////////////////////////////////////////////////////////////////
  51. template< class Context >
  52. struct Default2 : InnermostDefault<
  53. Default2< Context >, typename Context::template orthogonal< 2 > >
  54. {
  55. typedef InnermostDefault<
  56. Default2, typename Context::template orthogonal< 2 > > base_type;
  57. typedef typename base_type::my_context my_context;
  58. Default2( my_context ctx ) : base_type( ctx ) {}
  59. };
  60. #endif