StreamRegistry.cci
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
14 /** \file
15  \brief StreamRegistry inline non-template implementation */
16 
17 #include "StreamRegistry.ih"
18 
19 // Custom includes
20 #include <senf/Utils/TypeInfo.hh>
21 
22 #define prefix_ inline
23 //-/////////////////////////////////////////////////////////////////////////////////////////////////
24 
25 //-/////////////////////////////////////////////////////////////////////////////////////////////////
26 // senf::log::StreamRegistry
27 
28 prefix_ senf::log::StreamRegistry::StreamRegistry()
29 {}
30 
31 prefix_ senf::log::StreamRegistry::iterator senf::log::StreamRegistry::begin()
32 {
33  return boost::make_transform_iterator(registry_.begin(),
34  ::__gnu_cxx::select1st<Registry::value_type>());
35 }
36 
37 prefix_ senf::log::StreamRegistry::iterator senf::log::StreamRegistry::end()
38 {
39  return boost::make_transform_iterator(registry_.end(),
40  ::__gnu_cxx::select1st<Registry::value_type>());
41 }
42 
43 prefix_ void senf::log::StreamRegistry::registerStream(detail::StreamBase const & stream)
44 {
45  registry_.insert( std::make_pair(stream.v_name(), &stream) );
46 }
47 
48 prefix_ senf::log::detail::StreamBase const *
49 senf::log::StreamRegistry::lookup(std::string const & name)
50 {
51  Registry::iterator i (registry_.find(name));
52  return i == registry_.end() ? 0 : i->second;
53 }
54 
55 //-/////////////////////////////////////////////////////////////////////////////////////////////////
56 // senf::log::detail::StreamBase
57 
58 prefix_ senf::log::detail::StreamBase::StreamBase()
59  : index( nStreams++ )
60 {}
61 
62 prefix_ std::string senf::log::detail::StreamBase::fullName()
63  const
64 {
65  return prettyName(typeid(*this));
66 }
67 
68 prefix_ std::string senf::log::detail::StreamBase::v_name()
69  const
70 {
71  return fullName();
72 }
73 
74 prefix_ void senf::log::detail::StreamBase::init()
75 {
76  senf::log::StreamRegistry::instance().registerStream(*this);
77 }
78 
79 //-/////////////////////////////////////////////////////////////////////////////////////////////////
80 #undef prefix_
81 
82 
83 // Local Variables:
84 // mode: c++
85 // fill-column: 100
86 // comment-column: 40
87 // c-file-style: "senf"
88 // indent-tabs-mode: nil
89 // ispell-local-dictionary: "american"
90 // compile-command: "scons -u test"
91 // End: