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