// $Id$ // // Copyright (C) 2007 // Fraunhofer Institute for Open Communication Systems (FOKUS) // // The contents of this file are subject to the Fraunhofer FOKUS Public License // Version 1.0 (the "License"); you may not use this file except in compliance // with the License. You may obtain a copy of the License at // http://senf.berlios.de/license.html // // The Fraunhofer FOKUS Public License Version 1.0 is based on, // but modifies the Mozilla Public License Version 1.1. // See the full license text for the amendments. // // Software distributed under the License is distributed on an "AS IS" basis, // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License // for the specific language governing rights and limitations under the License. // // The Original Code is Fraunhofer FOKUS code. // // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V. // (registered association), Hansastraße 27 c, 80686 Munich, Germany. // All Rights Reserved. // // Contributor(s): // Stefan Bund /** \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: