Config.ih
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
14 /** \file
15  \brief Config internal header */
16 
17 #ifndef IH_SENF_Utils_Logger_Config_
18 #define IH_SENF_Utils_Logger_Config_ 1
19 
20 // Custom includes
21 #include <boost/preprocessor/expand.hpp>
22 #include <boost/preprocessor/seq/for_each.hpp>
23 #include <boost/preprocessor/seq/to_tuple.hpp>
24 #include <boost/preprocessor/seq/fold_right.hpp>
25 #include <boost/preprocessor/seq/pop_back.hpp>
26 #include <boost/preprocessor/if.hpp>
27 #include <boost/preprocessor/facilities/is_empty.hpp>
28 #include <senf/Utils/preprocessor.hh>
29 
30 //-/////////////////////////////////////////////////////////////////////////////////////////////////
31 
32 namespace senf {
33 namespace log {
34 namespace detail {
35 
36  struct na {};
37 
38  /// Internal: Compile time configuration for given \a Stream and \a Area
39  template <class Stream, class Area, class QueryStream=Stream, bool Query=true>
40  struct Config
41  {
42  typedef typename Config<na, Area, Stream, Query>::compileLimit compileLimit;
43  };
44 
45 # ifndef DOXYGEN
46 
47  template <class Area, class QueryStream, bool Query>
48  struct Config<na, Area, QueryStream, Query>
49  {
50  typedef typename Config<QueryStream, na, QueryStream, Query>::compileLimit compileLimit;
51  };
52 
53  template <class Stream, class QueryStream, bool Query>
54  struct Config<Stream, na, QueryStream, Query>
55  {
56  typedef typename Config<na, na, QueryStream, Query>::compileLimit compileLimit;
57  };
58 
59  template <class QueryStream, bool Query>
60  struct Config<na, na, QueryStream, Query>
61  {
62  typedef typename QueryStream::compileLimit compileLimit;
63  };
64 
65 # endif
66 
67 }}}
68 
69 #define SENF_LOG_CHECK_NA_
70 
71 #define SENF_LOG_CAT(a,b) SENF_LOG_CAT_I(a,b)
72 #define SENF_LOG_CAT_I(a,b) a ## b
73 
74 #define SENF_LOG_IS_NA(elt) BOOST_PP_IS_EMPTY( SENF_LOG_CAT(SENF_LOG_CHECK_NA, elt) )
75 
76 #define SENF_LOG_SEQ_TO_NAME_(s,state,elem) \
77  BOOST_PP_IF( SENF_LOG_IS_NA(elem), senf::log::detail::na, state::elem )
78 
79 #define SENF_LOG_SEQ_TO_NAME(seq) \
80  BOOST_PP_SEQ_FOLD_LEFT(SENF_LOG_SEQ_TO_NAME_, , seq)
81 
82 #define SENF_LOG_PREDECL_(s, state, elem) \
83  namespace elem { state }
84 
85 #define SENF_LOG_PREDECL_long(seq) \
86  BOOST_PP_SEQ_FOLD_RIGHT( SENF_LOG_PREDECL_, \
87  struct SENF_PP_SEQ_BACK(seq);, \
88  BOOST_PP_SEQ_POP_BACK(seq) )
89 
90 #define SENF_LOG_PREDECL_short(seq) \
91  BOOST_PP_IF( SENF_LOG_IS_NA( SENF_PP_SEQ_BACK(seq) ), ; , struct SENF_PP_SEQ_BACK(seq); )
92 
93 #define SENF_LOG_PREDECL(seq) \
94  BOOST_PP_CAT(SENF_LOG_PREDECL_, \
95  BOOST_PP_IF(BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(seq)),long,short))(seq)
96 
97 #define SENF_LOG_NIL(x)
98 
99 #define SENF_LOG_CONF_DEFINE(stream, area, level) \
100  SENF_LOG_PREDECL(stream) \
101  SENF_LOG_PREDECL(area) \
102  namespace senf { namespace log { namespace detail { \
103  template <class QueryStream> \
104  struct Config< SENF_LOG_SEQ_TO_NAME(stream), \
105  SENF_LOG_SEQ_TO_NAME(area), \
106  QueryStream, \
107  true > \
108  { typedef senf::log::level compileLimit; }; \
109  }}}
110 
111 #ifdef SENF_LOG_CONF
112 
113 # define SLC_elt(r, data, elt) \
114  SENF_LOG_CONF_DEFINE elt
115 
116  BOOST_PP_SEQ_FOR_EACH(SLC_elt, none, SENF_LOG_CONF)
117 
118 # undef SLC_elt
119 
120 #endif
121 
122 
123 
124 
125 //-/////////////////////////////////////////////////////////////////////////////////////////////////
126 #endif
127 
128 
129 // Local Variables:
130 // mode: c++
131 // fill-column: 100
132 // comment-column: 40
133 // c-file-style: "senf"
134 // indent-tabs-mode: nil
135 // ispell-local-dictionary: "american"
136 // compile-command: "scons -u test"
137 // End: