the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at master 102 lines 3.0 kB view raw
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////////////////////////////////////////////////////////////////////////////// 8 9 10 11#include <boost/statechart/simple_state.hpp> 12 13#include <boost/mpl/list.hpp> 14 15 16 17namespace boost 18{ 19namespace statechart 20{ 21 22 23 24template< class MostDerived, 25 class Context, 26 class InnerInitial = mpl::list<>, 27 history_mode historyMode = has_no_history > 28class state : public simple_state< 29 MostDerived, Context, InnerInitial, historyMode > 30{ 31 typedef simple_state< MostDerived, Context, InnerInitial, historyMode > 32 base_type; 33 34 protected: 35 ////////////////////////////////////////////////////////////////////////// 36 struct my_context 37 { 38 my_context( typename base_type::context_ptr_type pContext ) : 39 pContext_( pContext ) 40 { 41 } 42 43 typename base_type::context_ptr_type pContext_; 44 }; 45 46 typedef state my_base; 47 48 state( my_context ctx ) 49 { 50 this->set_context( ctx.pContext_ ); 51 } 52 53 ~state() {} 54 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; 66 67 static void initial_deep_construct( 68 outermost_context_base_type & outermostContextBase ) 69 { 70 deep_construct( &outermostContextBase, outermostContextBase ); 71 } 72 73 // See base class for documentation 74 static void deep_construct( 75 const context_ptr_type & pContext, 76 outermost_context_base_type & outermostContextBase ) 77 { 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 ); 82 } 83 84 static inner_context_ptr_type shallow_construct( 85 const context_ptr_type & pContext, 86 outermost_context_base_type & outermostContextBase ) 87 { 88 const inner_context_ptr_type pInnerContext( 89 new MostDerived( my_context( pContext ) ) ); 90 outermostContextBase.add( pInnerContext ); 91 return pInnerContext; 92 } 93}; 94 95 96 97} // namespace statechart 98} // namespace boost 99 100 101 102#endif