Utils/Logger: Implement targets
[senf.git] / Utils / Logger / Target.cti
1 // $Id$
2 //
3 // Copyright (C) 2007 
4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer NETwork research (NET)
6 //     Stefan Bund <g0dil@berlios.de>
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
23 /** \file
24     \brief Target inline template implementation */
25
26 //#include "Target.ih"
27
28 // Custom includes
29 #include "Levels.hh"
30
31 #define prefix_ inline
32 ///////////////////////////////cti.p///////////////////////////////////////
33
34 ///////////////////////////////////////////////////////////////////////////
35 // senf::log::Target
36
37 template <class Stream>
38 prefix_ void senf::log::Target::route()
39 {
40     route(&Stream::instance(), 0, NONE::value);
41 }
42
43 template <class Stream, class Arg0>
44 prefix_ void senf::log::Target::route()
45 {
46     route<Arg0>(&Stream::instance(), static_cast<Arg0*>(0));
47 }
48
49 template <class Stream, class Area, class Level>
50 prefix_ void senf::log::Target::route()
51 {
52     route(&Stream::instance(), &Area::instance(), Level::value);
53 }
54
55 ////////////////////////////////////////
56 // private members
57
58 template <class Area>
59 prefix_ void senf::log::Target::route(detail::StreamBase const * stream,
60                                       detail::AreaBase const *)
61 {
62     route(stream, &Area::instance(), NONE::value);
63 }
64
65 template <class Level>
66 prefix_ void senf::log::Target::route(detail::StreamBase const * stream,
67                                       detail::LevelBase const *)
68 {
69     route(stream, 0, Level::value);
70 }
71
72 ///////////////////////////////////////////////////////////////////////////
73 // namespace senf::log members
74
75 template <class Stream, class Area, class Level>
76 prefix_ void senf::log::write(std::string msg)
77 {
78     TargetRegistry::instance().write(Stream::instance(), Area::instance(), Level::value, msg);
79 }
80
81 ///////////////////////////////cti.e///////////////////////////////////////
82 #undef prefix_
83
84 \f
85 // Local Variables:
86 // mode: c++
87 // fill-column: 100
88 // comment-column: 40
89 // c-file-style: "senf"
90 // indent-tabs-mode: nil
91 // ispell-local-dictionary: "american"
92 // compile-command: "scons -u test"
93 // End: