features.hpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. * Copyright Andrey Semashev 2007 - 2015.
  3. * Distributed under the Boost Software License, Version 1.0.
  4. * (See accompanying file LICENSE_1_0.txt or copy at
  5. * http://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. /*!
  8. * \file sources/features.hpp
  9. * \author Andrey Semashev
  10. * \date 17.07.2009
  11. *
  12. * The header contains definition of a features list class template.
  13. */
  14. #ifndef BOOST_LOG_SOURCES_FEATURES_HPP_INCLUDED_
  15. #define BOOST_LOG_SOURCES_FEATURES_HPP_INCLUDED_
  16. #include <boost/mpl/lambda.hpp>
  17. #include <boost/log/detail/config.hpp>
  18. #ifdef BOOST_HAS_PRAGMA_ONCE
  19. #pragma once
  20. #endif
  21. #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  22. #include <boost/preprocessor/repetition/enum_params.hpp>
  23. #include <boost/preprocessor/repetition/enum_binary_params.hpp>
  24. #include <boost/preprocessor/repetition/enum_shifted_params.hpp>
  25. #include <boost/preprocessor/facilities/intercept.hpp>
  26. //! The macro defines the maximum number of features that can be specified for a logger
  27. #ifndef BOOST_LOG_FEATURES_LIMIT
  28. #define BOOST_LOG_FEATURES_LIMIT 10
  29. #endif // BOOST_LOG_FEATURES_LIMIT
  30. #endif
  31. #include <boost/log/detail/header.hpp>
  32. namespace boost {
  33. BOOST_LOG_OPEN_NAMESPACE
  34. namespace sources {
  35. #if defined(BOOST_LOG_DOXYGEN_PASS) || !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  36. /*!
  37. * \brief A type sequence of logger features
  38. *
  39. * This class template can be used to specify logger features in a \c basic_composite_logger instantiation.
  40. */
  41. template< typename... FeaturesT >
  42. struct features
  43. {
  44. };
  45. namespace aux {
  46. //! The metafunction produces the inherited features hierarchy with \c RootT as the ultimate base type
  47. template< typename RootT, typename FeaturesT >
  48. struct inherit_features;
  49. template< typename RootT, typename FeatureT0, typename... FeaturesT >
  50. struct inherit_features< RootT, features< FeatureT0, FeaturesT... > >
  51. {
  52. typedef typename mpl::lambda<
  53. FeatureT0
  54. >::type::BOOST_NESTED_TEMPLATE apply<
  55. typename inherit_features<
  56. RootT,
  57. features< FeaturesT... >
  58. >::type
  59. >::type type;
  60. };
  61. template< typename RootT, typename FeatureT0 >
  62. struct inherit_features< RootT, features< FeatureT0 > >
  63. {
  64. typedef typename mpl::lambda<
  65. FeatureT0
  66. >::type::BOOST_NESTED_TEMPLATE apply<
  67. RootT
  68. >::type type;
  69. };
  70. template< typename RootT >
  71. struct inherit_features< RootT, features< > >
  72. {
  73. typedef RootT type;
  74. };
  75. } // namespace aux
  76. #else
  77. //! A type sequence of logger features
  78. template< BOOST_PP_ENUM_BINARY_PARAMS(BOOST_LOG_FEATURES_LIMIT, typename FeatureT, = void BOOST_PP_INTERCEPT) >
  79. struct features
  80. {
  81. };
  82. namespace aux {
  83. template< typename RootT, typename FeaturesT >
  84. struct inherit_features;
  85. template< typename RootT, BOOST_PP_ENUM_PARAMS(BOOST_LOG_FEATURES_LIMIT, typename FeatureT) >
  86. struct inherit_features< RootT, features< BOOST_PP_ENUM_PARAMS(BOOST_LOG_FEATURES_LIMIT, FeatureT) > >
  87. {
  88. typedef typename mpl::lambda<
  89. FeatureT0
  90. >::type::BOOST_NESTED_TEMPLATE apply<
  91. typename inherit_features<
  92. RootT,
  93. features< BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_LOG_FEATURES_LIMIT, FeatureT) >
  94. >::type
  95. >::type type;
  96. };
  97. template< typename RootT, typename FeatureT0 >
  98. struct inherit_features< RootT, features< FeatureT0, BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_LOG_FEATURES_LIMIT, void BOOST_PP_INTERCEPT) > >
  99. {
  100. typedef typename mpl::lambda<
  101. FeatureT0
  102. >::type::BOOST_NESTED_TEMPLATE apply<
  103. RootT
  104. >::type type;
  105. };
  106. template< typename RootT >
  107. struct inherit_features< RootT, features< BOOST_PP_ENUM_PARAMS(BOOST_LOG_FEATURES_LIMIT, void BOOST_PP_INTERCEPT) > >
  108. {
  109. typedef RootT type;
  110. };
  111. } // namespace aux
  112. #endif
  113. } // namespace sources
  114. BOOST_LOG_CLOSE_NAMESPACE // namespace log
  115. } // namespace boost
  116. #include <boost/log/detail/footer.hpp>
  117. #endif // BOOST_LOG_SOURCES_FEATURES_HPP_INCLUDED_