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 sources/features.hpp
|
Chris@16
|
9 * \author Andrey Semashev
|
Chris@16
|
10 * \date 17.07.2009
|
Chris@16
|
11 *
|
Chris@16
|
12 * The header contains definition of a features list class template.
|
Chris@16
|
13 */
|
Chris@16
|
14
|
Chris@16
|
15 #ifndef BOOST_LOG_SOURCES_FEATURES_HPP_INCLUDED_
|
Chris@16
|
16 #define BOOST_LOG_SOURCES_FEATURES_HPP_INCLUDED_
|
Chris@16
|
17
|
Chris@16
|
18 #include <boost/mpl/lambda.hpp>
|
Chris@16
|
19 #include <boost/log/detail/config.hpp>
|
Chris@16
|
20
|
Chris@16
|
21 #ifdef BOOST_HAS_PRAGMA_ONCE
|
Chris@16
|
22 #pragma once
|
Chris@16
|
23 #endif
|
Chris@16
|
24
|
Chris@16
|
25 #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
Chris@16
|
26
|
Chris@16
|
27 #include <boost/preprocessor/repetition/enum_params.hpp>
|
Chris@101
|
28 #include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
Chris@16
|
29 #include <boost/preprocessor/repetition/enum_shifted_params.hpp>
|
Chris@16
|
30 #include <boost/preprocessor/facilities/intercept.hpp>
|
Chris@16
|
31
|
Chris@16
|
32 //! The macro defines the maximum number of features that can be specified for a logger
|
Chris@16
|
33 #ifndef BOOST_LOG_FEATURES_LIMIT
|
Chris@16
|
34 #define BOOST_LOG_FEATURES_LIMIT 10
|
Chris@16
|
35 #endif // BOOST_LOG_FEATURES_LIMIT
|
Chris@16
|
36
|
Chris@16
|
37 #endif
|
Chris@16
|
38
|
Chris@16
|
39 #include <boost/log/detail/header.hpp>
|
Chris@16
|
40
|
Chris@16
|
41 namespace boost {
|
Chris@16
|
42
|
Chris@16
|
43 BOOST_LOG_OPEN_NAMESPACE
|
Chris@16
|
44
|
Chris@16
|
45 namespace sources {
|
Chris@16
|
46
|
Chris@16
|
47 #if defined(BOOST_LOG_DOXYGEN_PASS) || !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
Chris@16
|
48
|
Chris@16
|
49 /*!
|
Chris@16
|
50 * \brief A type sequence of logger features
|
Chris@16
|
51 *
|
Chris@16
|
52 * This class template can be used to specify logger features in a \c basic_composite_logger instantiation.
|
Chris@16
|
53 */
|
Chris@16
|
54 template< typename... FeaturesT >
|
Chris@16
|
55 struct features
|
Chris@16
|
56 {
|
Chris@16
|
57 };
|
Chris@16
|
58
|
Chris@16
|
59 namespace aux {
|
Chris@16
|
60
|
Chris@16
|
61 //! The metafunction produces the inherited features hierarchy with \c RootT as the ultimate base type
|
Chris@16
|
62 template< typename RootT, typename FeaturesT >
|
Chris@16
|
63 struct inherit_features;
|
Chris@16
|
64
|
Chris@16
|
65 template< typename RootT, typename FeatureT0, typename... FeaturesT >
|
Chris@16
|
66 struct inherit_features< RootT, features< FeatureT0, FeaturesT... > >
|
Chris@16
|
67 {
|
Chris@16
|
68 typedef typename mpl::lambda<
|
Chris@16
|
69 FeatureT0
|
Chris@16
|
70 >::type::BOOST_NESTED_TEMPLATE apply<
|
Chris@16
|
71 typename inherit_features<
|
Chris@16
|
72 RootT,
|
Chris@16
|
73 features< FeaturesT... >
|
Chris@16
|
74 >::type
|
Chris@16
|
75 >::type type;
|
Chris@16
|
76 };
|
Chris@16
|
77
|
Chris@16
|
78 template< typename RootT, typename FeatureT0 >
|
Chris@16
|
79 struct inherit_features< RootT, features< FeatureT0 > >
|
Chris@16
|
80 {
|
Chris@16
|
81 typedef typename mpl::lambda<
|
Chris@16
|
82 FeatureT0
|
Chris@16
|
83 >::type::BOOST_NESTED_TEMPLATE apply<
|
Chris@16
|
84 RootT
|
Chris@16
|
85 >::type type;
|
Chris@16
|
86 };
|
Chris@16
|
87
|
Chris@16
|
88 template< typename RootT >
|
Chris@16
|
89 struct inherit_features< RootT, features< > >
|
Chris@16
|
90 {
|
Chris@16
|
91 typedef RootT type;
|
Chris@16
|
92 };
|
Chris@16
|
93
|
Chris@16
|
94 } // namespace aux
|
Chris@16
|
95
|
Chris@16
|
96 #else
|
Chris@16
|
97
|
Chris@16
|
98 //! A type sequence of logger features
|
Chris@16
|
99 template< BOOST_PP_ENUM_BINARY_PARAMS(BOOST_LOG_FEATURES_LIMIT, typename FeatureT, = void BOOST_PP_INTERCEPT) >
|
Chris@16
|
100 struct features
|
Chris@16
|
101 {
|
Chris@16
|
102 };
|
Chris@16
|
103
|
Chris@16
|
104 namespace aux {
|
Chris@16
|
105
|
Chris@16
|
106 template< typename RootT, typename FeaturesT >
|
Chris@16
|
107 struct inherit_features;
|
Chris@16
|
108
|
Chris@16
|
109 template< typename RootT, BOOST_PP_ENUM_PARAMS(BOOST_LOG_FEATURES_LIMIT, typename FeatureT) >
|
Chris@16
|
110 struct inherit_features< RootT, features< BOOST_PP_ENUM_PARAMS(BOOST_LOG_FEATURES_LIMIT, FeatureT) > >
|
Chris@16
|
111 {
|
Chris@16
|
112 typedef typename mpl::lambda<
|
Chris@16
|
113 FeatureT0
|
Chris@16
|
114 >::type::BOOST_NESTED_TEMPLATE apply<
|
Chris@16
|
115 typename inherit_features<
|
Chris@16
|
116 RootT,
|
Chris@16
|
117 features< BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_LOG_FEATURES_LIMIT, FeatureT) >
|
Chris@16
|
118 >::type
|
Chris@16
|
119 >::type type;
|
Chris@16
|
120 };
|
Chris@16
|
121
|
Chris@16
|
122 template< typename RootT, typename FeatureT0 >
|
Chris@16
|
123 struct inherit_features< RootT, features< FeatureT0, BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_LOG_FEATURES_LIMIT, void BOOST_PP_INTERCEPT) > >
|
Chris@16
|
124 {
|
Chris@16
|
125 typedef typename mpl::lambda<
|
Chris@16
|
126 FeatureT0
|
Chris@16
|
127 >::type::BOOST_NESTED_TEMPLATE apply<
|
Chris@16
|
128 RootT
|
Chris@16
|
129 >::type type;
|
Chris@16
|
130 };
|
Chris@16
|
131
|
Chris@16
|
132 template< typename RootT >
|
Chris@16
|
133 struct inherit_features< RootT, features< BOOST_PP_ENUM_PARAMS(BOOST_LOG_FEATURES_LIMIT, void BOOST_PP_INTERCEPT) > >
|
Chris@16
|
134 {
|
Chris@16
|
135 typedef RootT type;
|
Chris@16
|
136 };
|
Chris@16
|
137
|
Chris@16
|
138 } // namespace aux
|
Chris@16
|
139
|
Chris@16
|
140 #endif
|
Chris@16
|
141
|
Chris@16
|
142 } // namespace sources
|
Chris@16
|
143
|
Chris@16
|
144 BOOST_LOG_CLOSE_NAMESPACE // namespace log
|
Chris@16
|
145
|
Chris@16
|
146 } // namespace boost
|
Chris@16
|
147
|
Chris@16
|
148 #include <boost/log/detail/footer.hpp>
|
Chris@16
|
149
|
Chris@16
|
150 #endif // BOOST_LOG_SOURCES_FEATURES_HPP_INCLUDED_
|