4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 // Stefan Bund <g0dil@berlios.de>
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.
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.
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.
24 \brief Parameters internal header */
26 #ifndef IH_Parameters_
27 #define IH_Parameters_ 1
31 #include <boost/preprocessor/seq/for_each_i.hpp>
32 #include <boost/preprocessor/facilities/apply.hpp>
33 #include <boost/preprocessor/punctuation/comma_if.hpp>
34 #include <boost/mpl/vector.hpp>
35 #include <boost/mpl/fold.hpp>
36 #include "Defaults.hh"
43 ///////////////////////////////ih.p////////////////////////////////////////
45 #ifndef _senf_LOG_STREAM
46 # define _senf_LOG_STREAM std::cerr
49 typedef senf::log::Debug SENFLogDefaultStream;
50 typedef senf::log::DefaultArea SENFLogDefaultArea;
51 typedef senf::log::NONE SENFLogDefaultLevel;
59 template <class Base, class Param, unsigned N>
60 struct Parameters_ {};
62 senf::mpl::rv<1> Parameters_select_(StreamBase *);
63 template <class Base, class Param>
64 struct Parameters_<Base,Param,1> : public Base
65 { typedef Param stream; };
67 senf::mpl::rv<2> Parameters_select_(AreaBase *);
68 template <class Base, class Param>
69 struct Parameters_<Base,Param,2> : public Base
70 { typedef Param area; };
72 senf::mpl::rv<3> Parameters_select_(LevelBase *);
73 template <class Base, class Param>
74 struct Parameters_<Base,Param,3> : public Base
75 { typedef Param level; };
77 senf::mpl::rv<4> Parameters_select_(void *);
79 struct Parameters_<Base,void,4> : public Base
82 senf::mpl::rv<5> Parameters_select_(AliasBase *);
83 template <class Base, class Param>
84 struct Parameters_<Base,Param,5>
85 : public Param::template apply<Base>::type
89 struct Parameters : public Base
92 static bool const compile_enabled = senf::log::Enabled<
93 typename Base::stream,
95 typename Base::level>::value;
97 static bool enabled() { return compile_enabled; }
98 static std::ostream & log_stream() { return _senf_LOG_STREAM; }
103 struct Parameters_Merge_
105 template <class Base, class Param>
110 SENF_MPL_RV(Parameters_select_(static_cast<Param*>(0)))> type;
116 #define SENF_LOG_MERGE_ARG(r, data, i, elem) BOOST_PP_COMMA_IF(i) elem
118 #define SENF_LOG_MERGE_PARAMETERS_I(base, args) \
120 boost::mpl::vector< BOOST_PP_SEQ_FOR_EACH_I(SENF_LOG_MERGE_ARG, _, args) >, \
122 senf::log::detail::Parameters_Merge_ >::type
124 #define SENF_LOG_MERGE_PARAMETERS(args) \
125 senf::log::detail::Parameters< SENF_LOG_MERGE_PARAMETERS_I( \
126 senf::log::detail::empty, \
127 (SENFLogDefaultStream)(SENFLogDefaultArea)(SENFLogDefaultLevel)args) >
129 #define SENF_LOG_MERGE_PARAMETERS_TPL(args) \
130 senf::log::detail::Parameters< typename SENF_LOG_MERGE_PARAMETERS_I( \
131 senf::log::detail::empty, \
132 (SENFLogDefaultStream)(SENFLogDefaultArea)(SENFLogDefaultLevel)args) >
134 ///////////////////////////////ih.e////////////////////////////////////////
141 // comment-column: 40
142 // c-file-style: "senf"
143 // indent-tabs-mode: nil
144 // ispell-local-dictionary: "american"
145 // compile-command: "scons -u test"