fix doc example typo
[boost.git] / boost / statechart / state.hpp
blobab9ea0aa1a99c03a2300d14cda90ea0027314b23
1 #ifndef BOOST_STATECHART_STATE_HPP_INCLUDED
2 #define BOOST_STATECHART_STATE_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 //////////////////////////////////////////////////////////////////////////////
11 #include <boost/statechart/simple_state.hpp>
13 #include <boost/mpl/list.hpp>
17 namespace boost
19 namespace statechart
24 template< class MostDerived,
25 class Context,
26 class InnerInitial = mpl::list<>,
27 history_mode historyMode = has_no_history >
28 class state : public simple_state<
29 MostDerived, Context, InnerInitial, historyMode >
31 typedef simple_state< MostDerived, Context, InnerInitial, historyMode >
32 base_type;
34 protected:
35 //////////////////////////////////////////////////////////////////////////
36 struct my_context
38 my_context( typename base_type::context_ptr_type pContext ) :
39 pContext_( pContext )
43 typename base_type::context_ptr_type pContext_;
46 typedef state my_base;
48 state( my_context ctx )
50 this->set_context( ctx.pContext_ );
53 ~state() {}
55 public:
56 //////////////////////////////////////////////////////////////////////////
57 // The following declarations should be private.
58 // They are only public because many compilers lack template friends.
59 //////////////////////////////////////////////////////////////////////////
60 // See base class for documentation
61 typedef typename base_type::outermost_context_base_type
62 outermost_context_base_type;
63 typedef typename base_type::inner_context_ptr_type inner_context_ptr_type;
64 typedef typename base_type::context_ptr_type context_ptr_type;
65 typedef typename base_type::inner_initial_list inner_initial_list;
67 static void initial_deep_construct(
68 outermost_context_base_type & outermostContextBase )
70 deep_construct( &outermostContextBase, outermostContextBase );
73 // See base class for documentation
74 static void deep_construct(
75 const context_ptr_type & pContext,
76 outermost_context_base_type & outermostContextBase )
78 const inner_context_ptr_type pInnerContext(
79 shallow_construct( pContext, outermostContextBase ) );
80 base_type::template deep_construct_inner< inner_initial_list >(
81 pInnerContext, outermostContextBase );
84 static inner_context_ptr_type shallow_construct(
85 const context_ptr_type & pContext,
86 outermost_context_base_type & outermostContextBase )
88 const inner_context_ptr_type pInnerContext(
89 new MostDerived( my_context( pContext ) ) );
90 outermostContextBase.add( pInnerContext );
91 return pInnerContext;
97 } // namespace statechart
98 } // namespace boost
102 #endif