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
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
15 \brief Config internal header */
17 #ifndef IH_SENF_Utils_Logger_Config_
18 #define IH_SENF_Utils_Logger_Config_ 1
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>
30 //-/////////////////////////////////////////////////////////////////////////////////////////////////
38 /// Internal: Compile time configuration for given \a Stream and \a Area
39 template <class Stream, class Area, class QueryStream=Stream, bool Query=true>
42 typedef typename Config<na, Area, Stream, Query>::compileLimit compileLimit;
47 template <class Area, class QueryStream, bool Query>
48 struct Config<na, Area, QueryStream, Query>
50 typedef typename Config<QueryStream, na, QueryStream, Query>::compileLimit compileLimit;
53 template <class Stream, class QueryStream, bool Query>
54 struct Config<Stream, na, QueryStream, Query>
56 typedef typename Config<na, na, QueryStream, Query>::compileLimit compileLimit;
59 template <class QueryStream, bool Query>
60 struct Config<na, na, QueryStream, Query>
62 typedef typename QueryStream::compileLimit compileLimit;
69 #define SENF_LOG_CHECK_NA_
71 #define SENF_LOG_CAT(a,b) SENF_LOG_CAT_I(a,b)
72 #define SENF_LOG_CAT_I(a,b) a ## b
74 #define SENF_LOG_IS_NA(elt) BOOST_PP_IS_EMPTY( SENF_LOG_CAT(SENF_LOG_CHECK_NA, elt) )
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 )
79 #define SENF_LOG_SEQ_TO_NAME(seq) \
80 BOOST_PP_SEQ_FOLD_LEFT(SENF_LOG_SEQ_TO_NAME_, , seq)
82 #define SENF_LOG_PREDECL_(s, state, elem) \
83 namespace elem { state }
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) )
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); )
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)
97 #define SENF_LOG_NIL(x)
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), \
108 { typedef senf::log::level compileLimit; }; \
113 # define SLC_elt(r, data, elt) \
114 SENF_LOG_CONF_DEFINE elt
116 BOOST_PP_SEQ_FOR_EACH(SLC_elt, none, SENF_LOG_CONF)
125 //-/////////////////////////////////////////////////////////////////////////////////////////////////
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"