X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FLogger%2FTarget.ih;h=01d07281f768aad8db4358647dcb0101c7583001;hb=456ee576285b76aa46240f8001f426757810dcc1;hp=115c71ed14dbd48400b169cc30144f4210f99971;hpb=044a1bfb46ce16c3daac307b8c684604b43dd4cf;p=senf.git diff --git a/Utils/Logger/Target.ih b/Utils/Logger/Target.ih index 115c71e..01d0728 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 @@ -27,6 +27,9 @@ #define IH_Target_ 1 // Custom includes +#include +#include +#include ///////////////////////////////ih.p//////////////////////////////////////// @@ -44,20 +47,113 @@ namespace detail { void write(StreamBase const & stream, AreaBase const & area, unsigned level, std::string msg); + void routed(); + bool fallbackRouting(); + private: + TargetRegistry(); + void registerTarget(Target * target); void unregisterTarget(Target * target); typedef std::set Targets; Targets targets_; + + bool fallbackRouting_; friend class senf::log::Target; + friend class senf::singleton; }; /** \brief Internal: Write log message */ 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////////////////////////////////////////