Chris@16
|
1 /*
|
Chris@101
|
2 * Copyright Andrey Semashev 2007 - 2015.
|
Chris@16
|
3 * Distributed under the Boost Software License, Version 1.0.
|
Chris@16
|
4 * (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
5 * http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
6 */
|
Chris@16
|
7 /*!
|
Chris@16
|
8 * \file value_ref_visitation.hpp
|
Chris@16
|
9 * \author Andrey Semashev
|
Chris@16
|
10 * \date 28.07.2012
|
Chris@16
|
11 *
|
Chris@16
|
12 * \brief This header is the Boost.Log library implementation, see the library documentation
|
Chris@16
|
13 * at http://www.boost.org/doc/libs/release/libs/log/doc/html/index.html. In this file
|
Chris@16
|
14 * internal configuration macros are defined.
|
Chris@16
|
15 */
|
Chris@16
|
16
|
Chris@16
|
17 #ifndef BOOST_LOG_DETAIL_VALUE_REF_VISITATION_HPP_INCLUDED_
|
Chris@16
|
18 #define BOOST_LOG_DETAIL_VALUE_REF_VISITATION_HPP_INCLUDED_
|
Chris@16
|
19
|
Chris@16
|
20 #include <boost/mpl/at.hpp>
|
Chris@16
|
21 #include <boost/mpl/begin.hpp>
|
Chris@16
|
22 #include <boost/mpl/end.hpp>
|
Chris@16
|
23 #include <boost/mpl/advance.hpp>
|
Chris@16
|
24 #include <boost/mpl/erase.hpp>
|
Chris@16
|
25 #include <boost/mpl/size.hpp>
|
Chris@16
|
26 #include <boost/preprocessor/arithmetic/inc.hpp>
|
Chris@16
|
27 #include <boost/preprocessor/repetition/repeat_from_to.hpp>
|
Chris@16
|
28 #include <boost/preprocessor/iteration/iterate.hpp>
|
Chris@16
|
29 #include <boost/log/detail/config.hpp>
|
Chris@16
|
30 #include <boost/log/detail/header.hpp>
|
Chris@16
|
31
|
Chris@16
|
32 #ifndef BOOST_LOG_VALUE_REF_VISITATION_UNROLL_COUNT
|
Chris@16
|
33 #define BOOST_LOG_VALUE_REF_VISITATION_UNROLL_COUNT 8
|
Chris@16
|
34 #endif
|
Chris@16
|
35
|
Chris@16
|
36 namespace boost {
|
Chris@16
|
37
|
Chris@16
|
38 BOOST_LOG_OPEN_NAMESPACE
|
Chris@16
|
39
|
Chris@16
|
40 namespace aux {
|
Chris@16
|
41
|
Chris@16
|
42 template< typename SequenceT, typename VisitorT, unsigned int SizeV = mpl::size< SequenceT >::value >
|
Chris@16
|
43 struct apply_visitor_dispatch
|
Chris@16
|
44 {
|
Chris@16
|
45 typedef typename VisitorT::result_type result_type;
|
Chris@16
|
46
|
Chris@16
|
47 static BOOST_FORCEINLINE result_type call(const void* p, unsigned int type_index, VisitorT& visitor)
|
Chris@16
|
48 {
|
Chris@16
|
49 typedef typename mpl::begin< SequenceT >::type begin_type;
|
Chris@16
|
50 typedef typename mpl::advance_c< begin_type, SizeV / 2u >::type middle_type;
|
Chris@16
|
51 if (type_index < (SizeV / 2u))
|
Chris@16
|
52 {
|
Chris@16
|
53 typedef typename mpl::erase< SequenceT, middle_type, typename mpl::end< SequenceT >::type >::type new_sequence;
|
Chris@16
|
54 typedef apply_visitor_dispatch< new_sequence, VisitorT > new_dispatch;
|
Chris@16
|
55 return new_dispatch::call(p, type_index, visitor);
|
Chris@16
|
56 }
|
Chris@16
|
57 else
|
Chris@16
|
58 {
|
Chris@16
|
59 typedef typename mpl::erase< SequenceT, begin_type, middle_type >::type new_sequence;
|
Chris@16
|
60 typedef apply_visitor_dispatch< new_sequence, VisitorT > new_dispatch;
|
Chris@16
|
61 return new_dispatch::call(p, type_index - (SizeV / 2u), visitor);
|
Chris@16
|
62 }
|
Chris@16
|
63 }
|
Chris@16
|
64 };
|
Chris@16
|
65
|
Chris@16
|
66 #define BOOST_LOG_AUX_CASE_ENTRY(z, i, data)\
|
Chris@16
|
67 case i: return visitor(*static_cast< typename mpl::at_c< SequenceT, i >::type const* >(p));
|
Chris@16
|
68
|
Chris@16
|
69 #define BOOST_PP_FILENAME_1 <boost/log/detail/value_ref_visitation.hpp>
|
Chris@16
|
70 #define BOOST_PP_ITERATION_LIMITS (1, BOOST_PP_INC(BOOST_LOG_VALUE_REF_VISITATION_VTABLE_SIZE))
|
Chris@16
|
71 #include BOOST_PP_ITERATE()
|
Chris@16
|
72
|
Chris@16
|
73 #undef BOOST_LOG_AUX_CASE_ENTRY
|
Chris@16
|
74
|
Chris@16
|
75 } // namespace aux
|
Chris@16
|
76
|
Chris@16
|
77 BOOST_LOG_CLOSE_NAMESPACE // namespace log
|
Chris@16
|
78
|
Chris@16
|
79 } // namespace boost
|
Chris@16
|
80
|
Chris@16
|
81 #include <boost/log/detail/footer.hpp>
|
Chris@16
|
82
|
Chris@16
|
83 #endif // BOOST_LOG_DETAIL_VALUE_REF_VISITATION_HPP_INCLUDED_
|
Chris@16
|
84
|
Chris@16
|
85 #ifdef BOOST_PP_IS_ITERATING
|
Chris@16
|
86
|
Chris@16
|
87 #define BOOST_LOG_AUX_SWITCH_SIZE BOOST_PP_ITERATION()
|
Chris@16
|
88
|
Chris@16
|
89 template< typename SequenceT, typename VisitorT >
|
Chris@16
|
90 struct apply_visitor_dispatch< SequenceT, VisitorT, BOOST_LOG_AUX_SWITCH_SIZE >
|
Chris@16
|
91 {
|
Chris@16
|
92 typedef typename VisitorT::result_type result_type;
|
Chris@16
|
93
|
Chris@16
|
94 static BOOST_FORCEINLINE result_type call(const void* p, unsigned int type_index, VisitorT& visitor)
|
Chris@16
|
95 {
|
Chris@16
|
96 switch (type_index)
|
Chris@16
|
97 {
|
Chris@16
|
98 BOOST_PP_REPEAT_FROM_TO(1, BOOST_LOG_AUX_SWITCH_SIZE, BOOST_LOG_AUX_CASE_ENTRY, ~)
|
Chris@16
|
99 default:
|
Chris@16
|
100 return visitor(*static_cast< typename mpl::at_c< SequenceT, 0 >::type const* >(p));
|
Chris@16
|
101 }
|
Chris@16
|
102 }
|
Chris@16
|
103 };
|
Chris@16
|
104
|
Chris@16
|
105 #undef BOOST_LOG_AUX_SWITCH_SIZE
|
Chris@16
|
106
|
Chris@16
|
107 #endif // BOOST_PP_IS_ITERATING
|