X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FLogger%2FTarget.ih;h=c6d4efb7fa11030081418748d1707fd47ed97fd4;hb=41eff772147b6df1961d9029ba6815b553b4f81d;hp=668bacccf98f0c42b37cc402a34ec53ffef19686;hpb=17e24d84603667395e9ffa786a9cdbb722bf9c1f;p=senf.git diff --git a/Utils/Logger/Target.ih b/Utils/Logger/Target.ih index 668bacc..c6d4efb 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,14 @@ /** \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 +#include "../Console/LazyDirectory.hh" ///////////////////////////////ih.p//////////////////////////////////////// @@ -44,9 +46,7 @@ namespace detail { using senf::singleton::instance; void write(StreamBase const & stream, AreaBase const & area, unsigned level, - std::string msg); - - void timeSource(std::auto_ptr source); + std::string const & msg); void routed(); bool fallbackRouting(); @@ -54,14 +54,15 @@ namespace detail { private: TargetRegistry(); - void registerTarget(Target * target); + void registerTarget(Target * target, std::string const & name); void unregisterTarget(Target * target); typedef std::set Targets; Targets targets_; - boost::scoped_ptr timeSource_; bool fallbackRouting_; + + console::LazyDirectory consoleDir_; friend class senf::log::Target; friend class senf::singleton; @@ -69,7 +70,92 @@ namespace detail { /** \brief Internal: Write log message */ template - void write(std::string msg); + void write(std::string const & 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 }}}