Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:39:25

0001 /*
0002  *          Copyright Andrey Semashev 2007 - 2015.
0003  * Distributed under the Boost Software License, Version 1.0.
0004  *    (See accompanying file LICENSE_1_0.txt or copy at
0005  *          http://www.boost.org/LICENSE_1_0.txt)
0006  */
0007 /*!
0008  * \file   sinks/frontend_requirements.hpp
0009  * \author Andrey Semashev
0010  * \date   22.04.2007
0011  *
0012  * The header contains definition of requirement tags that sink backend may declare
0013  * with regard to frontends. These requirements ensure that a backend will not
0014  * be used with an incompatible frontend.
0015  */
0016 
0017 #ifndef BOOST_LOG_SINKS_FRONTEND_REQUIREMENTS_HPP_INCLUDED_
0018 #define BOOST_LOG_SINKS_FRONTEND_REQUIREMENTS_HPP_INCLUDED_
0019 
0020 #include <boost/type_traits/is_base_of.hpp>
0021 #include <boost/log/detail/config.hpp>
0022 #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
0023 #include <boost/mpl/aux_/na.hpp>
0024 #include <boost/mpl/placeholders.hpp>
0025 #include <boost/mpl/inherit.hpp>
0026 #include <boost/mpl/inherit_linearly.hpp>
0027 #include <boost/mpl/vector.hpp>
0028 #include <boost/preprocessor/repetition/enum_params.hpp>
0029 #include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
0030 #endif
0031 #include <boost/log/detail/header.hpp>
0032 
0033 #ifdef BOOST_HAS_PRAGMA_ONCE
0034 #pragma once
0035 #endif
0036 
0037 #ifndef BOOST_LOG_COMBINE_REQUIREMENTS_LIMIT
0038 //! The macro specifies the maximum number of requirements that can be combined with the \c combine_requirements metafunction
0039 #define BOOST_LOG_COMBINE_REQUIREMENTS_LIMIT 5
0040 #endif
0041 
0042 namespace boost {
0043 
0044 BOOST_LOG_OPEN_NAMESPACE
0045 
0046 namespace sinks {
0047 
0048 /*!
0049  * The sink backend expects pre-synchronized calls, all needed synchronization is implemented
0050  * in the frontend (IOW, only one thread is feeding records to the backend concurrently, but
0051  * it is possible for several threads to write sequentially). Note that if a frontend supports
0052  * synchronized record feeding, it will also report capable of concurrent record feeding.
0053  */
0054 struct synchronized_feeding {};
0055 
0056 #if !defined(BOOST_LOG_NO_THREADS)
0057 
0058 /*!
0059  * The sink backend ensures all needed synchronization, it is capable to handle multithreaded calls
0060  */
0061 struct concurrent_feeding : synchronized_feeding {};
0062 
0063 #else // !defined(BOOST_LOG_NO_THREADS)
0064 
0065 //  If multithreading is disabled, threading models become redundant
0066 typedef synchronized_feeding concurrent_feeding;
0067 
0068 #endif // !defined(BOOST_LOG_NO_THREADS)
0069 
0070 /*!
0071  * The sink backend requires the frontend to perform log record formatting before feeding
0072  */
0073 struct formatted_records {};
0074 
0075 /*!
0076  * The sink backend supports flushing
0077  */
0078 struct flushing {};
0079 
0080 #if defined(BOOST_LOG_DOXYGEN_PASS)
0081 
0082 /*!
0083  * The metafunction combines multiple requirement tags into one type. The resulting type will
0084  * satisfy all specified requirements (i.e. \c has_requirement metafunction will return positive result).
0085  */
0086 template< typename... RequirementsT >
0087 struct combine_requirements;
0088 
0089 #elif !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
0090 
0091 namespace aux {
0092 
0093 template< typename... RequirementsT >
0094 struct combined_requirements :
0095     public RequirementsT...
0096 {
0097 };
0098 
0099 } // namespace aux
0100 
0101 template< typename... RequirementsT >
0102 struct combine_requirements
0103 {
0104     typedef sinks::aux::combined_requirements< RequirementsT... > type;
0105 };
0106 
0107 #else
0108 
0109 template< BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_LOG_COMBINE_REQUIREMENTS_LIMIT, typename ReqT, mpl::na) >
0110 struct combine_requirements :
0111     mpl::inherit_linearly<
0112         mpl::vector< BOOST_PP_ENUM_PARAMS(BOOST_LOG_COMBINE_REQUIREMENTS_LIMIT, ReqT) >,
0113         mpl::inherit2< mpl::_1, mpl::_2 >
0114     >
0115 {
0116 };
0117 
0118 #endif // BOOST_LOG_DOXYGEN_PASS
0119 
0120 /*!
0121  * A helper metafunction to check if a requirement is satisfied. The \c TestedT template argument
0122  * should be the type combining one or several requirements and \c RequiredT is the requirement
0123  * to test against. The metafunction will yield a positive result if \c TestedT supports \c RequiredT.
0124  */
0125 template< typename TestedT, typename RequiredT >
0126 struct has_requirement :
0127     public is_base_of< RequiredT, TestedT >
0128 {
0129 };
0130 
0131 } // namespace sinks
0132 
0133 BOOST_LOG_CLOSE_NAMESPACE // namespace log
0134 
0135 } // namespace boost
0136 
0137 #include <boost/log/detail/footer.hpp>
0138 
0139 #endif // BOOST_LOG_SINKS_FRONTEND_REQUIREMENTS_HPP_INCLUDED_