// $Id$ // // Copyright (C) 2007 // Fraunhofer Institute for Open Communication Systems (FOKUS) // Competence Center NETwork research (NET), St. Augustin, GERMANY // Stefan Bund // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the // Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file \brief Parameters internal header */ #ifndef IH_SENF_Utils_Logger_Parameters_ #define IH_SENF_Utils_Logger_Parameters_ 1 // Custom includes #include #include #include #include #include #include #include #include #include #include #include "Config.hh" #include "Target.hh" //-///////////////////////////////////////////////////////////////////////////////////////////////// namespace senf { namespace log { class DefaultArea; class Debug; class NONE; namespace detail { class StreamBase; class AreaBase; class LevelBase; class AliasBase; /// Internal: Parameter extractor template struct Parameters_ {}; #ifndef DOXYGEN senf::mpl::rv<1> Parameters_select_(StreamBase *); template struct Parameters_ : public Base { typedef Param stream; }; senf::mpl::rv<2> Parameters_select_(AreaBase *); template struct Parameters_ : public Base { typedef Param area; typedef Param area_base; }; senf::mpl::rv<3> Parameters_select_(LevelBase *); template struct Parameters_ : public Base { typedef Param level; }; senf::mpl::rv<4> Parameters_select_(void *); template struct Parameters_ : public Base {}; senf::mpl::rv<5> Parameters_select_(AliasBase *); template struct Parameters_ : public Param::template apply::type {}; // This trick makes any class with a SENFLogArea typedef member usable as area. A typedef of // this name is created by SENF_LOG_CLASS_AREA() template senf::mpl::rv<6> Parameters_select_( T *, typename boost::disable_if< boost::is_convertible >::type * = 0, typename boost::disable_if< boost::is_convertible >::type * = 0, typename boost::disable_if< boost::is_convertible >::type * = 0, typename boost::disable_if< boost::is_convertible >::type * = 0); template struct Parameters_ : public Base { typedef typename Param::SENFLogArea area; typedef Param area_base; }; #endif /// Internal: Log message parameter collection template struct Parameters : public Base { typedef typename boost::mpl::if_c< Base::level::value == NONE::value, typename Base::stream::defaultLevel, typename Base::level >::type level; static bool const compileEnabled = senf::log::Enabled< typename Base::stream, typename Base::area_base, level>::value; static bool enabled() { return compileEnabled && ( senf::log::detail::TargetRegistry::instance().fallbackRouting() || Base::area::instance().limit(Base::stream::instance()) <= level::value ); } }; /// Internal: Empty base class struct empty {}; /// Internal: Merge log message parameter list struct Parameters_Merge { /// Internal: Embedded mpl template meta-function template struct apply { typedef Parameters_< Base, Param, SENF_MPL_RV(Parameters_select_(static_cast(0)))> type; }; }; }}} typedef senf::log::Debug SENFLogDefaultStream; typedef senf::log::DefaultArea SENFLogDefaultArea; typedef senf::log::NONE SENFLogDefaultLevel; #define SENF_LOG_MERGE_ARG(r, data, i, elem) BOOST_PP_COMMA_IF(i) elem #define SENF_LOG_MERGE_PARAMETERS_I(base, args) \ boost::mpl::fold< \ boost::mpl::vector< BOOST_PP_SEQ_FOR_EACH_I(SENF_LOG_MERGE_ARG, _, args) >, \ base, \ senf::log::detail::Parameters_Merge >::type #define SENF_LOG_MERGE_PARAMETERS(args) \ senf::log::detail::Parameters< SENF_LOG_MERGE_PARAMETERS_I( \ senf::log::detail::empty, \ (SENFLogDefaultStream)(SENFLogDefaultArea)(SENFLogDefaultLevel)args) > #define SENF_LOG_MERGE_PARAMETERS_TPL(args) \ senf::log::detail::Parameters< typename SENF_LOG_MERGE_PARAMETERS_I( \ senf::log::detail::empty, \ (SENFLogDefaultStream)(SENFLogDefaultArea)(SENFLogDefaultLevel)args) > //-///////////////////////////////////////////////////////////////////////////////////////////////// #endif // Local Variables: // mode: c++ // fill-column: 100 // comment-column: 40 // c-file-style: "senf" // indent-tabs-mode: nil // ispell-local-dictionary: "american" // compile-command: "scons -u test" // End: