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 sinks/frontend_requirements.hpp
|
Chris@16
|
9 * \author Andrey Semashev
|
Chris@16
|
10 * \date 22.04.2007
|
Chris@16
|
11 *
|
Chris@16
|
12 * The header contains definition of requirement tags that sink backend may declare
|
Chris@16
|
13 * with regard to frontends. These requirements ensure that a backend will not
|
Chris@16
|
14 * be used with an incompatible frontend.
|
Chris@16
|
15 */
|
Chris@16
|
16
|
Chris@16
|
17 #ifndef BOOST_LOG_SINKS_FRONTEND_REQUIREMENTS_HPP_INCLUDED_
|
Chris@16
|
18 #define BOOST_LOG_SINKS_FRONTEND_REQUIREMENTS_HPP_INCLUDED_
|
Chris@16
|
19
|
Chris@16
|
20 #include <boost/mpl/aux_/na.hpp>
|
Chris@16
|
21 #include <boost/mpl/placeholders.hpp>
|
Chris@16
|
22 #include <boost/mpl/inherit.hpp>
|
Chris@16
|
23 #include <boost/mpl/inherit_linearly.hpp>
|
Chris@16
|
24 #include <boost/mpl/vector.hpp>
|
Chris@16
|
25 #include <boost/preprocessor/repetition/enum_params.hpp>
|
Chris@16
|
26 #include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
|
Chris@16
|
27 #include <boost/type_traits/is_base_of.hpp>
|
Chris@16
|
28 #include <boost/log/detail/config.hpp>
|
Chris@16
|
29 #include <boost/log/detail/header.hpp>
|
Chris@16
|
30
|
Chris@16
|
31 #ifdef BOOST_HAS_PRAGMA_ONCE
|
Chris@16
|
32 #pragma once
|
Chris@16
|
33 #endif
|
Chris@16
|
34
|
Chris@16
|
35 #ifndef BOOST_LOG_COMBINE_REQUIREMENTS_LIMIT
|
Chris@16
|
36 //! The macro specifies the maximum number of requirements that can be combined with the \c combine_requirements metafunction
|
Chris@16
|
37 #define BOOST_LOG_COMBINE_REQUIREMENTS_LIMIT 5
|
Chris@16
|
38 #endif
|
Chris@16
|
39
|
Chris@16
|
40 namespace boost {
|
Chris@16
|
41
|
Chris@16
|
42 BOOST_LOG_OPEN_NAMESPACE
|
Chris@16
|
43
|
Chris@16
|
44 namespace sinks {
|
Chris@16
|
45
|
Chris@16
|
46 /*!
|
Chris@16
|
47 * The sink backend expects pre-synchronized calls, all needed synchronization is implemented
|
Chris@16
|
48 * in the frontend (IOW, only one thread is feeding records to the backend concurrently, but
|
Chris@16
|
49 * it is possible for several threads to write sequentially). Note that if a frontend supports
|
Chris@16
|
50 * synchronized record feeding, it will also report capable of concurrent record feeding.
|
Chris@16
|
51 */
|
Chris@16
|
52 struct synchronized_feeding {};
|
Chris@16
|
53
|
Chris@16
|
54 #if !defined(BOOST_LOG_NO_THREADS)
|
Chris@16
|
55
|
Chris@16
|
56 /*!
|
Chris@16
|
57 * The sink backend ensures all needed synchronization, it is capable to handle multithreaded calls
|
Chris@16
|
58 */
|
Chris@16
|
59 struct concurrent_feeding : synchronized_feeding {};
|
Chris@16
|
60
|
Chris@16
|
61 #else // !defined(BOOST_LOG_NO_THREADS)
|
Chris@16
|
62
|
Chris@16
|
63 // If multithreading is disabled, threading models become redundant
|
Chris@16
|
64 typedef synchronized_feeding concurrent_feeding;
|
Chris@16
|
65
|
Chris@16
|
66 #endif // !defined(BOOST_LOG_NO_THREADS)
|
Chris@16
|
67
|
Chris@16
|
68 /*!
|
Chris@16
|
69 * The sink backend requires the frontend to perform log record formatting before feeding
|
Chris@16
|
70 */
|
Chris@16
|
71 struct formatted_records {};
|
Chris@16
|
72
|
Chris@16
|
73 /*!
|
Chris@16
|
74 * The sink backend supports flushing
|
Chris@16
|
75 */
|
Chris@16
|
76 struct flushing {};
|
Chris@16
|
77
|
Chris@16
|
78 #ifdef BOOST_LOG_DOXYGEN_PASS
|
Chris@16
|
79
|
Chris@16
|
80 /*!
|
Chris@16
|
81 * The metafunction combines multiple requirement tags into one type. The resulting type will
|
Chris@16
|
82 * satisfy all specified requirements (i.e. \c has_requirement metafunction will return positive result).
|
Chris@16
|
83 */
|
Chris@16
|
84 template< typename... RequirementsT >
|
Chris@16
|
85 struct combine_requirements;
|
Chris@16
|
86
|
Chris@16
|
87 #else
|
Chris@16
|
88
|
Chris@16
|
89 template< BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_LOG_COMBINE_REQUIREMENTS_LIMIT, typename ReqT, mpl::na) >
|
Chris@16
|
90 struct combine_requirements :
|
Chris@16
|
91 mpl::inherit_linearly<
|
Chris@16
|
92 mpl::vector< BOOST_PP_ENUM_PARAMS(BOOST_LOG_COMBINE_REQUIREMENTS_LIMIT, ReqT) >,
|
Chris@16
|
93 mpl::inherit2< mpl::_1, mpl::_2 >
|
Chris@16
|
94 >
|
Chris@16
|
95 {
|
Chris@16
|
96 };
|
Chris@16
|
97
|
Chris@16
|
98 #endif // BOOST_LOG_DOXYGEN_PASS
|
Chris@16
|
99
|
Chris@16
|
100 /*!
|
Chris@16
|
101 * A helper metafunction to check if a requirement is satisfied. The \c TestedT template argument
|
Chris@16
|
102 * should be the type combining one or several requirements and \c RequiredT is the requirement
|
Chris@16
|
103 * to test against. The metafunction will yield a positive result if \c TestedT supports \c RequiredT.
|
Chris@16
|
104 */
|
Chris@16
|
105 template< typename TestedT, typename RequiredT >
|
Chris@16
|
106 struct has_requirement :
|
Chris@16
|
107 public is_base_of< RequiredT, TestedT >
|
Chris@16
|
108 {
|
Chris@16
|
109 };
|
Chris@16
|
110
|
Chris@16
|
111 } // namespace sinks
|
Chris@16
|
112
|
Chris@16
|
113 BOOST_LOG_CLOSE_NAMESPACE // namespace log
|
Chris@16
|
114
|
Chris@16
|
115 } // namespace boost
|
Chris@16
|
116
|
Chris@16
|
117 #include <boost/log/detail/footer.hpp>
|
Chris@16
|
118
|
Chris@16
|
119 #endif // BOOST_LOG_SINKS_FRONTEND_REQUIREMENTS_HPP_INCLUDED_
|