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