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