X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FLogger%2FTarget.ih;h=9ef0e0ef8655c4205876115ee2eb073599ea9c7b;hb=e879290346fe5242d7df2d70ee552d264081492f;hp=b0b61d984163aef5adb5308d6cb81431d6f866c5;hpb=a1a6c76a214ad1935032826713cabaf9ac57bf07;p=senf.git diff --git a/Utils/Logger/Target.ih b/Utils/Logger/Target.ih index b0b61d9..9ef0e0e 100644 --- a/Utils/Logger/Target.ih +++ b/Utils/Logger/Target.ih @@ -29,6 +29,8 @@ // Custom includes #include #include +#include +#include ///////////////////////////////ih.p//////////////////////////////////////// @@ -71,6 +73,91 @@ namespace detail { template void write(std::string msg); +#ifndef DOXYGEN + + // This code takes the routing target template arguments in any order and sorts them + // by type (Stream, Area and Level). + + senf::mpl::rv<0u> RouteParameterCheck_(...); + senf::mpl::rv<1u> RouteParameterCheck_(StreamBase *); + senf::mpl::rv<2u> RouteParameterCheck_(AreaBase *); + template senf::mpl::rv<3u> RouteParameterCheck_(T*, typename T::SENFLogArea * = 0); + senf::mpl::rv<4u> RouteParameterCheck_(LevelBase *); + + // For g++ 4.0 (at least) we need to provide the fully scoped name for this default value. + // no idea why. It works without the scope in 4.1 + template < class T, class A2, class A1, + unsigned type = SENF_MPL_RV( senf::log::detail::RouteParameterCheck_(static_cast(0)) ) > + struct RouteParameters + {}; + + template + struct RouteParameters + : public RouteParameters + {}; + + struct NilLevel { + static unsigned const value = NONE::value; + }; + + template <> + struct RouteParameters + { + typedef mpl::nil Stream; + typedef mpl::nil Area; + typedef NilLevel Level; + }; + + template + struct RouteParameters + : public RouteParameters + { + typedef RouteParameters base; + BOOST_STATIC_ASSERT(( boost::is_same::value )); + typedef T Stream; + }; + + template + struct RouteParameters + : public RouteParameters + { + typedef RouteParameters base; + BOOST_STATIC_ASSERT(( boost::is_same::value )); + typedef T Area; + }; + + template + struct RouteParameters + : public RouteParameters + { + typedef RouteParameters base; + BOOST_STATIC_ASSERT(( boost::is_same::value )); + typedef typename T::SENFLogArea Area; + }; + + template + struct RouteParameters + : public RouteParameters + { + typedef RouteParameters base; + BOOST_STATIC_ASSERT(( boost::is_same::value )); + typedef T Level; + }; + + template + struct InstanceP + { + static RV * value() { return & T::instance(); } + }; + + template + struct InstanceP + { + static RV * value() { return 0; } + }; + +#endif + }}} ///////////////////////////////ih.e////////////////////////////////////////