Search:

SENF Extensible Network Framework

  • Home
  • Download
  • Wiki
  • BerliOS
  • ChangeLog
  • Browse SVN
  • Bug Tracker
  • Overview
  • Examples
  • HowTos
  • Glossary
  • PPI
  • Packets
  • Scheduler
  • Socket
  • Utils
  • Console
  • Daemon
  • Logger
  • Termlib
  • Main Page
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

Config.ih

Go to the documentation of this file.
00001 // $Id: Config.ih 1742 2010-11-04 14:51:56Z g0dil $
00002 //
00003 // Copyright (C) 2007
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     Stefan Bund <g0dil@berlios.de>
00007 //
00008 // This program is free software; you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation; either version 2 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the
00020 // Free Software Foundation, Inc.,
00021 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00026 #ifndef IH_SENF_Utils_Logger_Config_
00027 #define IH_SENF_Utils_Logger_Config_ 1
00028 
00029 // Custom includes
00030 #include <boost/preprocessor/expand.hpp>
00031 #include <boost/preprocessor/seq/for_each.hpp>
00032 #include <boost/preprocessor/seq/to_tuple.hpp>
00033 #include <boost/preprocessor/seq/fold_right.hpp>
00034 #include <boost/preprocessor/seq/pop_back.hpp>
00035 #include <boost/preprocessor/if.hpp>
00036 #include <boost/preprocessor/facilities/is_empty.hpp>
00037 #include <senf/Utils/preprocessor.hh>
00038 
00039 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00040 
00041 namespace senf {
00042 namespace log {
00043 namespace detail {
00044 
00045     struct na {};
00046 
00048     template <class Stream, class Area, class QueryStream=Stream, bool Query=true>
00049     struct Config
00050     {
00051         typedef typename Config<na, Area, Stream, Query>::compileLimit compileLimit;
00052     };
00053 
00054 #   ifndef DOXYGEN
00055 
00056     template <class Area, class QueryStream, bool Query>
00057     struct Config<na, Area, QueryStream, Query>
00058     {
00059         typedef typename Config<QueryStream, na, QueryStream, Query>::compileLimit compileLimit;
00060     };
00061 
00062     template <class Stream, class QueryStream, bool Query>
00063     struct Config<Stream, na, QueryStream, Query>
00064     {
00065         typedef typename Config<na, na, QueryStream, Query>::compileLimit compileLimit;
00066     };
00067 
00068     template <class QueryStream, bool Query>
00069     struct Config<na, na, QueryStream, Query>
00070     {
00071         typedef typename QueryStream::compileLimit compileLimit;
00072     };
00073 
00074 #   endif
00075 
00076 }}}
00077 
00078 #define SENF_LOG_CHECK_NA_
00079 
00080 #define SENF_LOG_CAT(a,b) SENF_LOG_CAT_I(a,b)
00081 #define SENF_LOG_CAT_I(a,b) a ## b
00082 
00083 #define SENF_LOG_IS_NA(elt) BOOST_PP_IS_EMPTY( SENF_LOG_CAT(SENF_LOG_CHECK_NA, elt) )
00084 
00085 #define SENF_LOG_SEQ_TO_NAME_(s,state,elem)                                                       \
00086     BOOST_PP_IF( SENF_LOG_IS_NA(elem), senf::log::detail::na, state::elem )
00087 
00088 #define SENF_LOG_SEQ_TO_NAME(seq)                                                                 \
00089     BOOST_PP_SEQ_FOLD_LEFT(SENF_LOG_SEQ_TO_NAME_, , seq)
00090 
00091 #define SENF_LOG_PREDECL_(s, state, elem)                                                         \
00092     namespace elem { state }
00093 
00094 #define SENF_LOG_PREDECL_long(seq)                                                                \
00095     BOOST_PP_SEQ_FOLD_RIGHT( SENF_LOG_PREDECL_,                                                   \
00096                              class SENF_PP_SEQ_BACK(seq);,                                        \
00097                              BOOST_PP_SEQ_POP_BACK(seq) )
00098 
00099 #define SENF_LOG_PREDECL_short(seq)                                                               \
00100    BOOST_PP_IF( SENF_LOG_IS_NA( SENF_PP_SEQ_BACK(seq) ), ; , class SENF_PP_SEQ_BACK(seq); )
00101 
00102 #define SENF_LOG_PREDECL(seq)                                                                     \
00103     BOOST_PP_CAT(SENF_LOG_PREDECL_,                                                               \
00104                  BOOST_PP_IF(BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(seq)),long,short))(seq)
00105 
00106 #define SENF_LOG_NIL(x)
00107 
00108 #define SENF_LOG_CONF_DEFINE(stream, area, level)                                                 \
00109     SENF_LOG_PREDECL(stream)                                                                      \
00110     SENF_LOG_PREDECL(area)                                                                        \
00111     namespace senf { namespace log { namespace detail {                                           \
00112         template <class QueryStream>                                                              \
00113         struct Config< SENF_LOG_SEQ_TO_NAME(stream),                                              \
00114                        SENF_LOG_SEQ_TO_NAME(area),                                                \
00115                        QueryStream,                                                               \
00116                        true >                                                                     \
00117         { typedef senf::log::level compileLimit; };                                               \
00118     }}}
00119 
00120 #ifdef SENF_LOG_CONF
00121 
00122 #   define SLC_elt(r, data, elt) \
00123         SENF_LOG_CONF_DEFINE elt
00124 
00125     BOOST_PP_SEQ_FOR_EACH(SLC_elt, none, SENF_LOG_CONF)
00126 
00127 #   undef SLC_elt
00128 
00129 #endif
00130 
00131 
00132 
00133 
00134 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00135 #endif
00136 
00137 
00138 // Local Variables:
00139 // mode: c++
00140 // fill-column: 100
00141 // comment-column: 40
00142 // c-file-style: "senf"
00143 // indent-tabs-mode: nil
00144 // ispell-local-dictionary: "american"
00145 // compile-command: "scons -u test"
00146 // End:

Contact: senf-dev@lists.berlios.de | © 2006-2010 Fraunhofer Institute for Open Communication Systems, Network Research