PPI: Add simple connector type compatibility check
[senf.git] / Utils / Logger / Config.ih
index dae740d..1ead3fc 100644 (file)
@@ -1,8 +1,8 @@
 // $Id$
 //
-// Copyright (C) 2007 
-// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
-// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// Copyright (C) 2007
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
 //     Stefan Bund <g0dil@berlios.de>
 //
 // This program is free software; you can redistribute it and/or modify
 #include <boost/preprocessor/expand.hpp>
 #include <boost/preprocessor/seq/for_each.hpp>
 #include <boost/preprocessor/seq/to_tuple.hpp>
-#include "Defaults.hh"
+#include <boost/preprocessor/seq/fold_right.hpp>
+#include <boost/preprocessor/seq/pop_back.hpp>
+#include <boost/preprocessor/if.hpp>
+#include "../preprocessor.hh"
 
 ///////////////////////////////ih.p////////////////////////////////////////
 
@@ -38,37 +41,72 @@ namespace senf {
 namespace log {
 namespace detail {
 
+    struct na {};
+
+    /// Internal: Compile time configuration for given \a Stream and \a Area
     template <class Stream, class Area>
     struct Config
     {
-        typedef typename Config<Stream,void>::compileLimit compileLimit;
+        typedef typename Config<Stream,na>::compileLimit compileLimit;
     };
 
+#   ifndef DOXYGEN
+
     template <class Stream>
-    struct Config<Stream, void>
+    struct Config<Stream, na>
     {
         typedef typename Stream::compileLimit compileLimit;
     };
 
-#   define SENF_LOG_CONF_DEFINE(stream, area, level)                                              \
-           template <>                                                                            \
-           struct Config<stream, area>                                                            \
-           { typedef senf::log::level compileLimit; };
+#   endif
+
+}}}
 
-#   ifdef SENF_LOG_CONF
+#define SENF_LOG_SEQ_TO_NAME_(s,state,elem) state::elem
 
-#       define _ void
-#       define SLC_elt(r, data, elt) \
-            BOOST_PP_EXPAND(SENF_LOG_CONF_DEFINE BOOST_PP_SEQ_TO_TUPLE(elt))
+#define SENF_LOG_SEQ_TO_NAME(seq)                                                                 \
+    BOOST_PP_SEQ_FOLD_LEFT(SENF_LOG_SEQ_TO_NAME_, , seq)
 
-        BOOST_PP_SEQ_FOR_EACH(SLC_elt, x, SENF_LOG_CONF)
+#define SENF_LOG_PREDECL_(s, state, elem)                                                         \
+    namespace elem { state }
 
-#       undef SLC_elt
-#       undef _
+#define SENF_LOG_PREDECL_long(seq)                                                                \
+    BOOST_PP_SEQ_FOLD_RIGHT( SENF_LOG_PREDECL_,                                                   \
+                             class SENF_PP_SEQ_BACK(seq);,                                        \
+                             BOOST_PP_SEQ_POP_BACK(seq) )
 
-#   endif
+#define SENF_LOG_PREDECL_short(seq)                                                               \
+        class SENF_PP_SEQ_BACK(seq);
+
+#define SENF_LOG_PREDECL(seq)                                                                     \
+    BOOST_PP_CAT(SENF_LOG_PREDECL_,                                                               \
+                 BOOST_PP_IF(BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(seq)),long,short))(seq)
+
+#define SENF_LOG_NIL(x)
+
+#define SENF_LOG_CONF_DEFINE(stream, area, level)                                                 \
+    SENF_LOG_PREDECL(stream)                                                                      \
+    SENF_LOG_PREDECL(area)                                                                        \
+    namespace senf { namespace log { namespace detail {                                           \
+        template <>                                                                               \
+        struct Config< SENF_LOG_SEQ_TO_NAME(stream),                                              \
+                       SENF_LOG_SEQ_TO_NAME(area) >                                               \
+        { typedef senf::log::level compileLimit; };                                               \
+    }}}
+
+#ifdef SENF_LOG_CONF
+
+#   define _ senf::log::detail::na
+#   define SLC_elt(r, data, elt) \
+        SENF_LOG_CONF_DEFINE elt
+
+    BOOST_PP_SEQ_FOR_EACH(SLC_elt, none, SENF_LOG_CONF)
+
+#   undef SLC_elt
+#   undef _
+
+#endif
 
-}}}