X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FLogger%2FTarget.ih;h=c96eb328837924b6233faf24b7150c3a8b92db7f;hb=412024ed31a4ab4eaea7a4165a434f8efebee325;hp=0506fc5d23e90f5b7b569b0b5027593816f786dd;hpb=82ad2ed94c12c3e53097fef92978de8c28239fab;p=senf.git diff --git a/Utils/Logger/Target.ih b/Utils/Logger/Target.ih index 0506fc5..c96eb32 100644 --- a/Utils/Logger/Target.ih +++ b/Utils/Logger/Target.ih @@ -1,8 +1,8 @@ // $Id$ // -// Copyright (C) 2007 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer NETwork research (NET) +// 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 @@ -23,12 +23,13 @@ /** \file \brief Target internal header */ -#ifndef IH_Target_ -#define IH_Target_ 1 +#ifndef IH_SENF_Utils_Logger_Target_ +#define IH_SENF_Utils_Logger_Target_ 1 // Custom includes #include -#include +#include +#include ///////////////////////////////ih.p//////////////////////////////////////// @@ -46,7 +47,8 @@ namespace detail { void write(StreamBase const & stream, AreaBase const & area, unsigned level, std::string msg); - void timeSource(std::auto_ptr source); + void routed(); + bool fallbackRouting(); private: TargetRegistry(); @@ -56,7 +58,8 @@ namespace detail { typedef std::set Targets; Targets targets_; - boost::scoped_ptr timeSource_; + + bool fallbackRouting_; friend class senf::log::Target; friend class senf::singleton; @@ -66,6 +69,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////////////////////////////////////////