sl@0: #ifndef BOOST_STATECHART_STATE_HPP_INCLUDED sl@0: #define BOOST_STATECHART_STATE_HPP_INCLUDED sl@0: ////////////////////////////////////////////////////////////////////////////// sl@0: // Copyright 2002-2006 Andreas Huber Doenni sl@0: // Distributed under the Boost Software License, Version 1.0. (See accompany- sl@0: // ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) sl@0: ////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: sl@0: sl@0: #include sl@0: sl@0: #include sl@0: sl@0: sl@0: sl@0: namespace boost sl@0: { sl@0: namespace statechart sl@0: { sl@0: sl@0: sl@0: sl@0: template< class MostDerived, sl@0: class Context, sl@0: class InnerInitial = mpl::list<>, sl@0: history_mode historyMode = has_no_history > sl@0: class state : public simple_state< sl@0: MostDerived, Context, InnerInitial, historyMode > sl@0: { sl@0: typedef simple_state< MostDerived, Context, InnerInitial, historyMode > sl@0: base_type; sl@0: sl@0: protected: sl@0: ////////////////////////////////////////////////////////////////////////// sl@0: struct my_context sl@0: { sl@0: my_context( typename base_type::context_ptr_type pContext ) : sl@0: pContext_( pContext ) sl@0: { sl@0: } sl@0: sl@0: typename base_type::context_ptr_type pContext_; sl@0: }; sl@0: sl@0: typedef state my_base; sl@0: sl@0: state( my_context ctx ) sl@0: { sl@0: this->set_context( ctx.pContext_ ); sl@0: } sl@0: sl@0: ~state() {} sl@0: sl@0: public: sl@0: ////////////////////////////////////////////////////////////////////////// sl@0: // The following declarations should be private. sl@0: // They are only public because many compilers lack template friends. sl@0: ////////////////////////////////////////////////////////////////////////// sl@0: // See base class for documentation sl@0: typedef typename base_type::outermost_context_base_type sl@0: outermost_context_base_type; sl@0: typedef typename base_type::inner_context_ptr_type inner_context_ptr_type; sl@0: typedef typename base_type::context_ptr_type context_ptr_type; sl@0: typedef typename base_type::inner_initial_list inner_initial_list; sl@0: sl@0: static void initial_deep_construct( sl@0: outermost_context_base_type & outermostContextBase ) sl@0: { sl@0: deep_construct( &outermostContextBase, outermostContextBase ); sl@0: } sl@0: sl@0: // See base class for documentation sl@0: static void deep_construct( sl@0: const context_ptr_type & pContext, sl@0: outermost_context_base_type & outermostContextBase ) sl@0: { sl@0: const inner_context_ptr_type pInnerContext( sl@0: shallow_construct( pContext, outermostContextBase ) ); sl@0: base_type::template deep_construct_inner< inner_initial_list >( sl@0: pInnerContext, outermostContextBase ); sl@0: } sl@0: sl@0: static inner_context_ptr_type shallow_construct( sl@0: const context_ptr_type & pContext, sl@0: outermost_context_base_type & outermostContextBase ) sl@0: { sl@0: const inner_context_ptr_type pInnerContext( sl@0: new MostDerived( my_context( pContext ) ) ); sl@0: outermostContextBase.add( pInnerContext ); sl@0: return pInnerContext; sl@0: } sl@0: }; sl@0: sl@0: sl@0: sl@0: } // namespace statechart sl@0: } // namespace boost sl@0: sl@0: sl@0: sl@0: #endif