Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:52:32

0001 #ifndef BOOST_STATECHART_STATE_HPP_INCLUDED
0002 #define BOOST_STATECHART_STATE_HPP_INCLUDED
0003 //////////////////////////////////////////////////////////////////////////////
0004 // Copyright 2002-2006 Andreas Huber Doenni
0005 // Distributed under the Boost Software License, Version 1.0. (See accompany-
0006 // ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0007 //////////////////////////////////////////////////////////////////////////////
0008 
0009 
0010 
0011 #include <boost/statechart/simple_state.hpp>
0012 
0013 #include <boost/mpl/list.hpp>
0014 
0015 
0016 
0017 namespace boost
0018 {
0019 namespace statechart
0020 {
0021 
0022 
0023 
0024 template< class MostDerived,
0025           class Context,
0026           class InnerInitial = mpl::list<>,
0027           history_mode historyMode = has_no_history >
0028 class state : public simple_state<
0029   MostDerived, Context, InnerInitial, historyMode >
0030 {
0031   typedef simple_state< MostDerived, Context, InnerInitial, historyMode >
0032     base_type;
0033 
0034   protected:
0035     //////////////////////////////////////////////////////////////////////////
0036     struct my_context
0037     {
0038       my_context( typename base_type::context_ptr_type pContext ) :
0039         pContext_( pContext )
0040       {
0041       }
0042 
0043       typename base_type::context_ptr_type pContext_;
0044     };
0045 
0046     typedef state my_base;
0047 
0048     state( my_context ctx )
0049     {
0050       this->set_context( ctx.pContext_ );
0051     }
0052 
0053     ~state() {}
0054 
0055   public:
0056     //////////////////////////////////////////////////////////////////////////
0057     // The following declarations should be private.
0058     // They are only public because many compilers lack template friends.
0059     //////////////////////////////////////////////////////////////////////////
0060     // See base class for documentation
0061     typedef typename base_type::outermost_context_base_type
0062       outermost_context_base_type;
0063     typedef typename base_type::inner_context_ptr_type inner_context_ptr_type;
0064     typedef typename base_type::context_ptr_type context_ptr_type;
0065     typedef typename base_type::inner_initial_list inner_initial_list;
0066 
0067     static void initial_deep_construct(
0068       outermost_context_base_type & outermostContextBase )
0069     {
0070       deep_construct( &outermostContextBase, outermostContextBase );
0071     }
0072 
0073     // See base class for documentation
0074     static void deep_construct(
0075       const context_ptr_type & pContext,
0076       outermost_context_base_type & outermostContextBase )
0077     {
0078       const inner_context_ptr_type pInnerContext(
0079         shallow_construct( pContext, outermostContextBase ) );
0080       base_type::template deep_construct_inner< inner_initial_list >(
0081         pInnerContext, outermostContextBase );
0082     }
0083 
0084     static inner_context_ptr_type shallow_construct(
0085       const context_ptr_type & pContext,
0086       outermost_context_base_type & outermostContextBase )
0087     {
0088       const inner_context_ptr_type pInnerContext(
0089         new MostDerived( my_context( pContext ) ) );
0090       outermostContextBase.add( pInnerContext );
0091       return pInnerContext;
0092     }
0093 };
0094 
0095 
0096 
0097 } // namespace statechart
0098 } // namespace boost
0099 
0100 
0101 
0102 #endif