]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/statechart/detail/constructor.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / statechart / detail / constructor.hpp
1 #ifndef BOOST_STATECHART_DETAIL_CONSTRUCTOR_HPP_INCLUDED
2 #define BOOST_STATECHART_DETAIL_CONSTRUCTOR_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/mpl/eval_if.hpp>
12 #include <boost/mpl/identity.hpp>
13 #include <boost/mpl/equal_to.hpp>
14 #include <boost/mpl/size.hpp>
15 #include <boost/mpl/front.hpp>
16 #include <boost/mpl/advance.hpp>
17 #include <boost/mpl/find.hpp>
18 #include <boost/mpl/push_front.hpp>
19 #include <boost/mpl/pop_front.hpp>
20 #include <boost/mpl/erase.hpp>
21 #include <boost/mpl/reverse.hpp>
22 #include <boost/mpl/long.hpp>
23
24
25
26 namespace boost
27 {
28 namespace statechart
29 {
30 namespace detail
31 {
32
33
34
35 template< class ContextList, class OutermostContextBase >
36 struct constructor;
37
38 //////////////////////////////////////////////////////////////////////////////
39 template< class ContextList, class OutermostContextBase >
40 struct outer_constructor
41 {
42 typedef typename mpl::front< ContextList >::type to_construct;
43 typedef typename to_construct::context_ptr_type context_ptr_type;
44 typedef typename to_construct::inner_context_ptr_type
45 inner_context_ptr_type;
46
47 typedef typename to_construct::inner_initial_list inner_initial_list;
48 typedef typename mpl::pop_front< ContextList >::type inner_context_list;
49 typedef typename mpl::front< inner_context_list >::type::orthogonal_position
50 inner_orthogonal_position;
51 typedef typename mpl::advance<
52 typename mpl::begin< inner_initial_list >::type,
53 inner_orthogonal_position >::type to_construct_iter;
54
55 typedef typename mpl::erase<
56 inner_initial_list,
57 to_construct_iter,
58 typename mpl::end< inner_initial_list >::type
59 >::type first_inner_initial_list;
60
61 typedef typename mpl::erase<
62 inner_initial_list,
63 typename mpl::begin< inner_initial_list >::type,
64 typename mpl::next< to_construct_iter >::type
65 >::type last_inner_initial_list;
66
67 static void construct(
68 const context_ptr_type & pContext,
69 OutermostContextBase & outermostContextBase )
70 {
71 const inner_context_ptr_type pInnerContext =
72 to_construct::shallow_construct( pContext, outermostContextBase );
73 to_construct::template deep_construct_inner<
74 first_inner_initial_list >( pInnerContext, outermostContextBase );
75 constructor< inner_context_list, OutermostContextBase >::construct(
76 pInnerContext, outermostContextBase );
77 to_construct::template deep_construct_inner<
78 last_inner_initial_list >( pInnerContext, outermostContextBase );
79 }
80 };
81
82 //////////////////////////////////////////////////////////////////////////////
83 template< class ContextList, class OutermostContextBase >
84 struct inner_constructor
85 {
86 typedef typename mpl::front< ContextList >::type to_construct;
87 typedef typename to_construct::context_ptr_type context_ptr_type;
88
89 static void construct(
90 const context_ptr_type & pContext,
91 OutermostContextBase & outermostContextBase )
92 {
93 to_construct::deep_construct( pContext, outermostContextBase );
94 }
95 };
96
97 //////////////////////////////////////////////////////////////////////////////
98 template< class ContextList, class OutermostContextBase >
99 struct constructor_impl : public mpl::eval_if<
100 mpl::equal_to< mpl::size< ContextList >, mpl::long_< 1 > >,
101 mpl::identity< inner_constructor< ContextList, OutermostContextBase > >,
102 mpl::identity< outer_constructor< ContextList, OutermostContextBase > > >
103 {
104 };
105
106
107 //////////////////////////////////////////////////////////////////////////////
108 template< class ContextList, class OutermostContextBase >
109 struct constructor :
110 constructor_impl< ContextList, OutermostContextBase >::type {};
111
112 //////////////////////////////////////////////////////////////////////////////
113 template< class CommonContext, class DestinationState >
114 struct make_context_list
115 {
116 typedef typename mpl::reverse< typename mpl::push_front<
117 typename mpl::erase<
118 typename DestinationState::context_type_list,
119 typename mpl::find<
120 typename DestinationState::context_type_list,
121 CommonContext
122 >::type,
123 typename mpl::end<
124 typename DestinationState::context_type_list
125 >::type
126 >::type,
127 DestinationState
128 >::type >::type type;
129 };
130
131
132
133 } // namespace detail
134 } // namespace statechart
135 } // namespace boost
136
137
138
139 #endif