85380a24b59883d202a6c0ba6b70c9b324fa92f9
[senf.git] / senf / Utils / Logger / AreaRegistry.cci
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 AreaRegistry inline non-template implementation */
25
26 #include "AreaRegistry.ih"
27
28 // Custom includes
29 #include <senf/Utils/TypeInfo.hh>
30 #include "Levels.hh"
31 #include "StreamRegistry.hh"
32
33 #define prefix_ inline
34 ///////////////////////////////cci.p///////////////////////////////////////
35
36 ///////////////////////////////////////////////////////////////////////////
37 // senf::log::AreaRegistry
38
39 prefix_ std::string const &
40 senf::log::AreaRegistry::SelectName::operator()(Registry::value_type const & v)
41     const
42 {
43     return v.first;
44 }
45
46 prefix_ senf::log::AreaRegistry::AreaRegistry()
47 {}
48
49 prefix_ senf::log::AreaRegistry::iterator senf::log::AreaRegistry::begin()
50 {
51     return boost::make_transform_iterator(registry_.begin(), SelectName());
52 }
53
54 prefix_ senf::log::AreaRegistry::iterator senf::log::AreaRegistry::end()
55 {
56     return boost::make_transform_iterator(registry_.end(), SelectName());
57 }
58
59 prefix_ void senf::log::AreaRegistry::registerArea(detail::AreaBase const & area)
60 {
61     registry_.insert( std::make_pair(area.v_name(), &area) );
62 }
63
64 prefix_ senf::log::detail::AreaBase const *
65 senf::log::AreaRegistry::lookup(std::string const & name)
66 {
67     Registry::iterator i (registry_.find(name));
68     return i == registry_.end() ? 0 : i->second;
69 }
70
71 ///////////////////////////////////////////////////////////////////////////
72 // senf::log::detail::AreaBase
73
74 prefix_ std::string senf::log::detail::AreaBase::fullName()
75     const
76 {
77     return prettyName(typeid(*this));
78 }
79
80 prefix_ std::string senf::log::detail::AreaBase::v_name()
81     const
82 {
83     return fullName();
84 }
85
86 prefix_ void senf::log::detail::AreaBase::init()
87 {
88     senf::log::AreaRegistry::instance().registerArea(*this);
89 }
90
91 prefix_ bool senf::log::detail::AreaBase::alive()
92     const
93 {
94     return alive_;
95 }
96
97 prefix_ unsigned senf::log::detail::AreaBase::limit(StreamBase const & stream)
98     const
99 {
100     return stream.index >= routingCache_.size() ?
101         DISABLED::value : routingCache_[stream.index].limit;
102 }
103
104 ///////////////////////////////cci.e///////////////////////////////////////
105 #undef prefix_
106
107 \f
108 // Local Variables:
109 // mode: c++
110 // fill-column: 100
111 // comment-column: 40
112 // c-file-style: "senf"
113 // indent-tabs-mode: nil
114 // ispell-local-dictionary: "american"
115 // compile-command: "scons -u test"
116 // End: