switch to new MPL based Fraunhofer FOKUS Public License
[senf.git] / senf / Utils / Logger / Target.cci
1 // $Id$
2 //
3 // Copyright (C) 2007
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 //
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at 
9 // http://senf.berlios.de/license.html
10 //
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on, 
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
14 //
15 // Software distributed under the License is distributed on an "AS IS" basis, 
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
17 // for the specific language governing rights and limitations under the License.
18 //
19 // The Original Code is Fraunhofer FOKUS code.
20 //
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V. 
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
24 //
25 // Contributor(s):
26 //   Stefan Bund <g0dil@berlios.de>
27
28 /** \file
29     \brief Target inline non-template implementation */
30
31 #include "Target.ih"
32
33 // Custom includes
34 #include "AreaRegistry.hh"
35
36 #define prefix_ inline
37 //-/////////////////////////////////////////////////////////////////////////////////////////////////
38
39 //-/////////////////////////////////////////////////////////////////////////////////////////////////
40 // senf::log::Target
41
42 prefix_ void senf::log::Target::route(action_t action, int index)
43 {
44     route(0, 0, NONE::value, action, index);
45 }
46
47 prefix_ void senf::log::Target::unroute(action_t action)
48 {
49     unroute(0, 0, NONE::value, action);
50 }
51
52 prefix_ senf::log::Target::iterator senf::log::Target::begin()
53     const
54 {
55     return rib_.begin();
56 }
57
58 prefix_ senf::log::Target::iterator senf::log::Target::end()
59     const
60 {
61     return rib_.end();
62 }
63
64 prefix_ senf::log::Target::RoutingEntry const & senf::log::Target::operator[](size_type i)
65     const
66 {
67     return rib_[i];
68 }
69
70 prefix_ senf::log::Target::size_type senf::log::Target::size()
71     const
72 {
73     return rib_.size();
74 }
75
76 prefix_ bool senf::log::Target::empty()
77     const
78 {
79     return rib_.empty();
80 }
81
82 //-/////////////////////////////////////////////////////////////////////////////////////////////////
83 // senf::log::Target::RoutingEntry
84
85 prefix_ senf::log::Target::RoutingEntry::RoutingEntry(detail::StreamBase const * stream,
86                                                       detail::AreaBase const * area,
87                                                       unsigned level, action_t action)
88     : stream_(stream), area_(area), level_(level), action_(action)
89 {}
90
91 prefix_ senf::log::Target::RoutingEntry::RoutingEntry()
92     : stream_(0), area_(0), level_(0), action_(ACCEPT)
93 {}
94
95 prefix_ bool senf::log::Target::RoutingEntry::operator==(RoutingEntry const & other)
96     const
97 {
98     return
99         stream_ == other.stream_ &&
100         area_ == other.area_ &&
101         level_ == other.level_ &&
102         action_ == other.action_;
103 }
104
105 prefix_ std::string senf::log::Target::RoutingEntry::stream()
106     const
107 {
108     return stream_ ? stream_->v_name() : "";
109 }
110
111 prefix_ std::string senf::log::Target::RoutingEntry::area()
112     const
113 {
114     return area_ ? area_->v_name() : "";
115 }
116
117 prefix_ unsigned senf::log::Target::RoutingEntry::level()
118     const
119 {
120     return level_;
121 }
122
123 prefix_ senf::log::Target::action_t senf::log::Target::RoutingEntry::action()
124     const
125 {
126     return action_;
127 }
128
129 //-/////////////////////////////////////////////////////////////////////////////////////////////////
130 // senf::log::detail::TargetRegistry
131
132 prefix_ void senf::log::detail::TargetRegistry::routed()
133 {
134     fallbackRouting_ = false;
135 }
136
137 prefix_ bool senf::log::detail::TargetRegistry::fallbackRouting()
138 {
139     return fallbackRouting_;
140 }
141
142 prefix_ senf::console::ScopedDirectory<> & senf::log::detail::TargetRegistry::consoleDir()
143 {
144     return consoleDir_();
145 }
146
147 //-/////////////////////////////////////////////////////////////////////////////////////////////////
148 // private members
149
150 prefix_ void senf::log::detail::TargetRegistry::unregisterTarget(Target * target)
151 {
152     targets_.erase(target);
153 }
154
155 //-/////////////////////////////////////////////////////////////////////////////////////////////////
156 #undef prefix_
157
158 \f
159 // Local Variables:
160 // mode: c++
161 // fill-column: 100
162 // comment-column: 40
163 // c-file-style: "senf"
164 // indent-tabs-mode: nil
165 // ispell-local-dictionary: "american"
166 // compile-command: "scons -u test"
167 // End: