2312dc64f2c08e8a939e210c0541a2473bf715e9
[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 // senf::log::Target::route
38
39 template <class Stream>
40 prefix_ void senf::log::Target::route(action_t action, int index)
41 {
42     route(&Stream::instance(), 0, NONE::value, action, index);
43 }
44
45 template <class Stream, class Level>
46 prefix_ void senf::log::Target::
47 route(action_t action, int index,
48       typename boost::enable_if< boost::is_convertible<Level*, detail::LevelBase *> >::type *)
49 {
50     route(&Stream::instance(), 0, Level::value, action, index);
51 }
52
53 template <class Stream, class Area>
54 prefix_ void senf::log::Target::
55 route(action_t action, int index,
56       typename boost::enable_if< boost::is_convertible<Area*, detail::AreaBase *> >::type *)
57 {
58     route(&Stream::instance(), &Area::instance(), NONE::value, action, index);
59 }
60
61 template <class Stream, class AreaClass>
62 prefix_ void senf::log::Target::
63 route(action_t action, int index,
64       typename boost::enable_if< boost::is_convertible<typename AreaClass::SENFLogArea *, detail::AreaBase *> >::type *)
65 {
66     route(&Stream::instance(), &AreaClass::SENFLogArea::instance(), NONE::value, action, index);
67 }
68
69 template <class Stream, class Area, class Level>
70 prefix_ void senf::log::Target::
71 route(action_t action, int index,
72       typename boost::enable_if< boost::is_convertible<Area *, detail::AreaBase *> >::type *)
73 {
74     route(&Stream::instance(), &Area::instance(), Level::value, action, index);
75 }
76
77 template <class Stream, class AreaClass, class Level>
78 prefix_ void senf::log::Target::
79 route(action_t action, int index,
80       typename boost::enable_if< boost::is_convertible<typename AreaClass::SENFLogArea *, detail::AreaBase *> >::type *)
81 {
82     route(&Stream::instance(), &AreaClass::SENFLogArea::instance(), Level::value, action, index);
83 }
84
85 // senf::log::target::ununroute
86
87 template <class Stream>
88 prefix_ void senf::log::Target::unroute(action_t action)
89 {
90     unroute(&Stream::instance(), 0, NONE::value, action);
91 }
92
93 template <class Stream, class Level>
94 prefix_ void senf::log::Target::
95 unroute(action_t action,
96       typename boost::enable_if< boost::is_convertible<Level*, detail::LevelBase *> >::type *)
97 {
98     unroute(&Stream::instance(), 0, Level::value, action);
99 }
100
101 template <class Stream, class Area>
102 prefix_ void senf::log::Target::
103 unroute(action_t action,
104       typename boost::enable_if< boost::is_convertible<Area*, detail::AreaBase *> >::type *)
105 {
106     unroute(&Stream::instance(), &Area::instance(), NONE::value, action);
107 }
108
109 template <class Stream, class AreaClass>
110 prefix_ void senf::log::Target::
111 unroute(action_t action,
112       typename boost::enable_if< boost::is_convertible<typename AreaClass::SENFLogArea *, detail::AreaBase *> >::type *)
113 {
114     unroute(&Stream::instance(), &AreaClass::SENFLogArea::instance(), NONE::value, action);
115 }
116
117 template <class Stream, class Area, class Level>
118 prefix_ void senf::log::Target::
119 unroute(action_t action,
120       typename boost::enable_if< boost::is_convertible<Area *, detail::AreaBase *> >::type *)
121 {
122     unroute(&Stream::instance(), &Area::instance(), Level::value, action);
123 }
124
125 template <class Stream, class AreaClass, class Level>
126 prefix_ void senf::log::Target::
127 unroute(action_t action,
128       typename boost::enable_if< boost::is_convertible<typename AreaClass::SENFLogArea *, detail::AreaBase *> >::type *)
129 {
130     unroute(&Stream::instance(), &AreaClass::SENFLogArea::instance(), Level::value, action);
131 }
132
133 ///////////////////////////////////////////////////////////////////////////
134 // namespace senf::log members
135
136 template <class Stream, class Area, class Level>
137 prefix_ void senf::log::write(std::string msg)
138 {
139     TargetRegistry::instance().write(Stream::instance(), Area::instance(), Level::value, msg);
140 }
141
142 ///////////////////////////////cti.e///////////////////////////////////////
143 #undef prefix_
144
145 \f
146 // Local Variables:
147 // mode: c++
148 // fill-column: 100
149 // comment-column: 40
150 // c-file-style: "senf"
151 // indent-tabs-mode: nil
152 // ispell-local-dictionary: "american"
153 // compile-command: "scons -u test"
154 // End: