Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #ifndef BOOST_STATECHART_DETAIL_CONSTRUCTOR_HPP_INCLUDED
0002 #define BOOST_STATECHART_DETAIL_CONSTRUCTOR_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/mpl/eval_if.hpp>
0012 #include <boost/mpl/identity.hpp>
0013 #include <boost/mpl/equal_to.hpp>
0014 #include <boost/mpl/size.hpp>
0015 #include <boost/mpl/front.hpp>
0016 #include <boost/mpl/advance.hpp>
0017 #include <boost/mpl/find.hpp>
0018 #include <boost/mpl/push_front.hpp>
0019 #include <boost/mpl/pop_front.hpp>
0020 #include <boost/mpl/erase.hpp>
0021 #include <boost/mpl/reverse.hpp>
0022 #include <boost/mpl/long.hpp>
0023 
0024 
0025 
0026 namespace boost
0027 {
0028 namespace statechart
0029 {
0030 namespace detail
0031 {
0032 
0033 
0034 
0035 template< class ContextList, class OutermostContextBase >
0036 struct constructor;
0037 
0038 //////////////////////////////////////////////////////////////////////////////
0039 template< class ContextList, class OutermostContextBase >
0040 struct outer_constructor
0041 {
0042   typedef typename mpl::front< ContextList >::type to_construct;
0043   typedef typename to_construct::context_ptr_type context_ptr_type;
0044   typedef typename to_construct::inner_context_ptr_type
0045     inner_context_ptr_type;
0046 
0047   typedef typename to_construct::inner_initial_list inner_initial_list;
0048   typedef typename mpl::pop_front< ContextList >::type inner_context_list;
0049   typedef typename mpl::front< inner_context_list >::type::orthogonal_position
0050     inner_orthogonal_position;
0051   typedef typename mpl::advance<
0052     typename mpl::begin< inner_initial_list >::type,
0053     inner_orthogonal_position >::type to_construct_iter;
0054 
0055   typedef typename mpl::erase<
0056     inner_initial_list,
0057     to_construct_iter,
0058     typename mpl::end< inner_initial_list >::type
0059   >::type first_inner_initial_list;
0060 
0061   typedef typename mpl::erase<
0062     inner_initial_list,
0063     typename mpl::begin< inner_initial_list >::type,
0064     typename mpl::next< to_construct_iter >::type
0065   >::type last_inner_initial_list;
0066 
0067   static void construct(
0068     const context_ptr_type & pContext,
0069     OutermostContextBase & outermostContextBase )
0070   {
0071     const inner_context_ptr_type pInnerContext =
0072       to_construct::shallow_construct( pContext, outermostContextBase );
0073     to_construct::template deep_construct_inner<
0074       first_inner_initial_list >( pInnerContext, outermostContextBase );
0075     constructor< inner_context_list, OutermostContextBase >::construct(
0076       pInnerContext, outermostContextBase );
0077     to_construct::template deep_construct_inner<
0078       last_inner_initial_list >( pInnerContext, outermostContextBase );
0079   }
0080 };
0081 
0082 //////////////////////////////////////////////////////////////////////////////
0083 template< class ContextList, class OutermostContextBase >
0084 struct inner_constructor
0085 {
0086   typedef typename mpl::front< ContextList >::type to_construct;
0087   typedef typename to_construct::context_ptr_type context_ptr_type;
0088 
0089   static void construct(
0090     const context_ptr_type & pContext,
0091     OutermostContextBase & outermostContextBase )
0092   {
0093     to_construct::deep_construct( pContext, outermostContextBase );
0094   }
0095 };
0096 
0097 //////////////////////////////////////////////////////////////////////////////
0098 template< class ContextList, class OutermostContextBase >
0099 struct constructor_impl : public mpl::eval_if<
0100   mpl::equal_to< mpl::size< ContextList >, mpl::long_< 1 > >,
0101   mpl::identity< inner_constructor< ContextList, OutermostContextBase > >,
0102   mpl::identity< outer_constructor< ContextList, OutermostContextBase > > >
0103 {
0104 };
0105 
0106 
0107 //////////////////////////////////////////////////////////////////////////////
0108 template< class ContextList, class OutermostContextBase >
0109 struct constructor :
0110   constructor_impl< ContextList, OutermostContextBase >::type {};
0111 
0112 //////////////////////////////////////////////////////////////////////////////
0113 template< class CommonContext, class DestinationState >
0114 struct make_context_list
0115 {
0116   typedef typename mpl::reverse< typename mpl::push_front<
0117     typename mpl::erase<
0118       typename DestinationState::context_type_list,
0119       typename mpl::find<
0120         typename DestinationState::context_type_list,
0121         CommonContext
0122       >::type,
0123       typename mpl::end<
0124         typename DestinationState::context_type_list
0125       >::type
0126     >::type,
0127     DestinationState
0128   >::type >::type type;
0129 };
0130 
0131 
0132 
0133 } // namespace detail
0134 } // namespace statechart
0135 } // namespace boost
0136 
0137 
0138 
0139 #endif