NEW FILE HEADER / COPYRIGHT FORMAT
[senf.git] / Utils / Logger / Target.cti
1 // $Id$
2 //
3 // Copyright (C) 2007 
4 // Fraunhofer Institute for Open Communication Systems (FOKUS) 
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY 
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 #ifndef DOXYGEN
40
41 template <class Stream>
42 prefix_ void senf::log::Target::route(action_t action, int index)
43 {
44     route(&Stream::instance(), 0, NONE::value, action, index);
45 }
46
47 template <class Stream, class Level>
48 prefix_ void senf::log::Target::
49 route(action_t action, int index,
50       typename boost::enable_if< boost::is_convertible<Level*, detail::LevelBase *> >::type *)
51 {
52     route(&Stream::instance(), 0, Level::value, action, index);
53 }
54
55 template <class Stream, class Area>
56 prefix_ void senf::log::Target::
57 route(action_t action, int index,
58       typename boost::enable_if< boost::is_convertible<Area*, detail::AreaBase *> >::type *)
59 {
60     route(&Stream::instance(), &Area::instance(), NONE::value, action, index);
61 }
62
63 template <class Stream, class AreaClass>
64 prefix_ void senf::log::Target::
65 route(action_t action, int index,
66       typename boost::enable_if< boost::is_convertible<typename AreaClass::SENFLogArea *, detail::AreaBase *> >::type *)
67 {
68     route(&Stream::instance(), &AreaClass::SENFLogArea::instance(), NONE::value, action, index);
69 }
70
71 template <class Stream, class Area, class Level>
72 prefix_ void senf::log::Target::
73 route(action_t action, int index,
74       typename boost::enable_if< boost::is_convertible<Area *, detail::AreaBase *> >::type *)
75 {
76     route(&Stream::instance(), &Area::instance(), Level::value, action, index);
77 }
78
79 template <class Stream, class AreaClass, class Level>
80 prefix_ void senf::log::Target::
81 route(action_t action, int index,
82       typename boost::enable_if< boost::is_convertible<typename AreaClass::SENFLogArea *, detail::AreaBase *> >::type *)
83 {
84     route(&Stream::instance(), &AreaClass::SENFLogArea::instance(), Level::value, action, index);
85 }
86
87 // senf::log::target::ununroute
88
89 template <class Stream>
90 prefix_ void senf::log::Target::unroute(action_t action)
91 {
92     unroute(&Stream::instance(), 0, NONE::value, action);
93 }
94
95 template <class Stream, class Level>
96 prefix_ void senf::log::Target::
97 unroute(action_t action,
98       typename boost::enable_if< boost::is_convertible<Level*, detail::LevelBase *> >::type *)
99 {
100     unroute(&Stream::instance(), 0, Level::value, action);
101 }
102
103 template <class Stream, class Area>
104 prefix_ void senf::log::Target::
105 unroute(action_t action,
106       typename boost::enable_if< boost::is_convertible<Area*, detail::AreaBase *> >::type *)
107 {
108     unroute(&Stream::instance(), &Area::instance(), NONE::value, action);
109 }
110
111 template <class Stream, class AreaClass>
112 prefix_ void senf::log::Target::
113 unroute(action_t action,
114       typename boost::enable_if< boost::is_convertible<typename AreaClass::SENFLogArea *, detail::AreaBase *> >::type *)
115 {
116     unroute(&Stream::instance(), &AreaClass::SENFLogArea::instance(), NONE::value, action);
117 }
118
119 template <class Stream, class Area, class Level>
120 prefix_ void senf::log::Target::
121 unroute(action_t action,
122       typename boost::enable_if< boost::is_convertible<Area *, detail::AreaBase *> >::type *)
123 {
124     unroute(&Stream::instance(), &Area::instance(), Level::value, action);
125 }
126
127 template <class Stream, class AreaClass, class Level>
128 prefix_ void senf::log::Target::
129 unroute(action_t action,
130       typename boost::enable_if< boost::is_convertible<typename AreaClass::SENFLogArea *, detail::AreaBase *> >::type *)
131 {
132     unroute(&Stream::instance(), &AreaClass::SENFLogArea::instance(), Level::value, action);
133 }
134
135 #endif 
136
137 ///////////////////////////////////////////////////////////////////////////
138 // namespace senf::log::detail members
139
140 template <class Stream, class Area, class Level>
141 prefix_ void senf::log::detail::write(std::string msg)
142 {
143     TargetRegistry::instance().write(Stream::instance(), Area::instance(), Level::value, msg);
144 }
145
146 template <class Source>
147 prefix_ void senf::log::timeSource()
148 {
149     timeSource(std::auto_ptr<Source>(new Source()));
150 }
151
152 ///////////////////////////////cti.e///////////////////////////////////////
153 #undef prefix_
154
155 \f
156 // Local Variables:
157 // mode: c++
158 // fill-column: 100
159 // comment-column: 40
160 // c-file-style: "senf"
161 // indent-tabs-mode: nil
162 // ispell-local-dictionary: "american"
163 // compile-command: "scons -u test"
164 // End: