Target.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 Target inline non-template implementation */
16 
17 #include "Target.ih"
18 
19 // Custom includes
20 #include "AreaRegistry.hh"
21 
22 #define prefix_ inline
23 //-/////////////////////////////////////////////////////////////////////////////////////////////////
24 
25 //-/////////////////////////////////////////////////////////////////////////////////////////////////
26 // senf::log::Target
27 
28 prefix_ void senf::log::Target::route(action_t action, int index)
29 {
30  route(nullptr, nullptr, NONE::value, action, index);
31 }
32 
33 prefix_ void senf::log::Target::unroute(action_t action)
34 {
35  unroute(nullptr, nullptr, NONE::value, action);
36 }
37 
38 prefix_ senf::log::Target::iterator senf::log::Target::begin()
39  const
40 {
41  return rib_.begin();
42 }
43 
44 prefix_ senf::log::Target::iterator senf::log::Target::end()
45  const
46 {
47  return rib_.end();
48 }
49 
50 prefix_ senf::log::Target::RoutingEntry const & senf::log::Target::operator[](size_type i)
51  const
52 {
53  return rib_[i];
54 }
55 
56 prefix_ senf::log::Target::size_type senf::log::Target::size()
57  const
58 {
59  return rib_.size();
60 }
61 
62 prefix_ bool senf::log::Target::empty()
63  const
64 {
65  return rib_.empty();
66 }
67 
68 //-/////////////////////////////////////////////////////////////////////////////////////////////////
69 // senf::log::Target::RoutingEntry
70 
71 prefix_ senf::log::Target::RoutingEntry::RoutingEntry(detail::StreamBase const * stream,
72  detail::AreaBase const * area,
73  unsigned level, action_t action)
74  : stream_(stream), area_(area), level_(level), action_(action)
75 {}
76 
77 prefix_ senf::log::Target::RoutingEntry::RoutingEntry()
78  : stream_(nullptr), area_(nullptr), level_(0), action_(ACCEPT)
79 {}
80 
81 prefix_ bool senf::log::Target::RoutingEntry::operator==(RoutingEntry const & other)
82  const
83 {
84  return
85  stream_ == other.stream_ &&
86  area_ == other.area_ &&
87  level_ == other.level_ &&
88  action_ == other.action_;
89 }
90 
91 prefix_ std::string senf::log::Target::RoutingEntry::stream()
92  const
93 {
94  return stream_ ? stream_->v_name() : "";
95 }
96 
97 prefix_ std::string senf::log::Target::RoutingEntry::area()
98  const
99 {
100  return area_ ? area_->v_name() : "";
101 }
102 
103 prefix_ unsigned senf::log::Target::RoutingEntry::level()
104  const
105 {
106  return level_;
107 }
108 
109 prefix_ senf::log::Target::action_t senf::log::Target::RoutingEntry::action()
110  const
111 {
112  return action_;
113 }
114 
115 //-/////////////////////////////////////////////////////////////////////////////////////////////////
116 // senf::log::detail::TargetRegistry
117 
118 prefix_ void senf::log::detail::TargetRegistry::routed()
119 {
120  fallbackRouting_ = false;
121 }
122 
123 prefix_ bool senf::log::detail::TargetRegistry::fallbackRouting()
124 {
125  return fallbackRouting_;
126 }
127 
128 prefix_ senf::console::ScopedDirectory<> & senf::log::detail::TargetRegistry::consoleDir()
129 {
130  return consoleDir_();
131 }
132 
133 //-/////////////////////////////////////////////////////////////////////////////////////////////////
134 // private members
135 
136 prefix_ void senf::log::detail::TargetRegistry::unregisterTarget(Target * target)
137 {
138  targets_.erase(target);
139 }
140 
141 //-/////////////////////////////////////////////////////////////////////////////////////////////////
142 #undef prefix_
143 
144 
145 // Local Variables:
146 // mode: c++
147 // fill-column: 100
148 // comment-column: 40
149 // c-file-style: "senf"
150 // indent-tabs-mode: nil
151 // ispell-local-dictionary: "american"
152 // compile-command: "scons -u test"
153 // End: