10b9e4a349677b0a656d7daae872b158b00c4b0a
[senf.git] / Utils / Logger / Config.ih
1 // $Id$
2 //
3 // Copyright (C) 2007 
4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 //     Stefan Bund <g0dil@berlios.de>
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
23 /** \file
24     \brief Config internal header */
25
26 #ifndef IH_Config_
27 #define IH_Config_ 1
28
29 // Custom includes
30 #include <boost/preprocessor/expand.hpp>
31 #include <boost/preprocessor/seq/for_each.hpp>
32 #include <boost/preprocessor/seq/to_tuple.hpp>
33 #include <boost/preprocessor/seq/fold_right.hpp>
34 #include <boost/preprocessor/seq/pop_back.hpp>
35 #include <boost/preprocessor/if.hpp>
36 #include "../preprocessor.hh"
37
38 ///////////////////////////////ih.p////////////////////////////////////////
39
40 namespace senf {
41 namespace log {
42 namespace detail {
43
44     template <class Stream, class Area>
45     struct Config
46     {
47         typedef typename Config<Stream,void>::compileLimit compileLimit;
48     };
49
50     template <class Stream>
51     struct Config<Stream, void>
52     {
53         typedef typename Stream::compileLimit compileLimit;
54     };
55
56 }}}
57
58 #define SENF_LOG_SEQ_TO_NAME_(s,data,elem) ::elem
59
60 #define SENF_LOG_SEQ_TO_NAME(seq)                                                                 \
61     BOOST_PP_SEQ_FOR_EACH(SENF_LOG_SEQ_TO_NAME_, none, seq)
62
63 #define SENF_LOG_PREDECL_(s, state, elem)                                                         \
64     namespace elem { state }
65
66 #define SENF_LOG_PREDECL(seq)                                                                     \
67     BOOST_PP_SEQ_FOLD_RIGHT( SENF_LOG_PREDECL_,                                                   \
68                              class SENF_PP_SEQ_BACK(seq);,                                        \
69                              BOOST_PP_SEQ_POP_BACK(seq) )
70
71 #define SENF_LOG_NIL(x)
72
73 #define SENF_LOG_CONF_DEFINE(stream, area, level)                                                 \
74     SENF_LOG_PREDECL(stream)                                                                      \
75     BOOST_PP_IF(BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(area)),                                            \
76                 SENF_LOG_PREDECL,                                                                 \
77                 SENF_LOG_NIL)(area)                                                               \
78     namespace senf { namespace log { namespace detail {                                           \
79         template <>                                                                               \
80         struct Config< SENF_LOG_SEQ_TO_NAME(stream),                                              \
81                        BOOST_PP_IF(BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(area)),                         \
82                                    SENF_LOG_SEQ_TO_NAME(area),                                    \
83                                    void) >                                                        \
84         { typedef senf::log::level compileLimit; };                                               \
85     }}}
86
87 #ifdef SENF_LOG_CONF
88
89 #   define SLC_elt(s, state, elt)                                                                  \
90         SENF_LOG_CONF_DEFINE elt
91
92     // Need to use fold here to not exhaust the maximum FOR nesting depth ...
93     BOOST_PP_SEQ_FOLD_LEFT(SLC_elt, none, SENF_LOG_CONF)
94
95 #   undef SLC_elt
96
97 #endif
98
99
100
101
102 ///////////////////////////////ih.e////////////////////////////////////////
103 #endif
104
105 \f
106 // Local Variables:
107 // mode: c++
108 // fill-column: 100
109 // comment-column: 40
110 // c-file-style: "senf"
111 // indent-tabs-mode: nil
112 // ispell-local-dictionary: "american"
113 // compile-command: "scons -u test"
114 // End: