AreaRegistry.ih
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 internal header */
16 
17 #ifndef IH_SENF_Utils_Logger_AreaRegistry_
18 #define IH_SENF_Utils_Logger_AreaRegistry_ 1
19 
20 // Custom includes
21 #include <string>
22 #include <vector>
23 #include <list>
24 #include "Levels.hh"
25 #include "TimeSource.hh"
26 
27 //-/////////////////////////////////////////////////////////////////////////////////////////////////
28 
29 namespace senf {
30 namespace log {
31 
32  class Target;
33 
34 namespace detail {
35 
36  struct StreamBase;
37 
38  /** \brief Internal: Area base class */
39  struct AreaBase
40  {
41  AreaBase();
42  virtual ~AreaBase();
43 
44  std::string fullName() const;
45  virtual std::string v_name() const;
46 
47  void init();
48  bool alive() const;
49 
50  unsigned limit(StreamBase const & stream) const;
51  void updateRoutingCache(Target & target, StreamBase const & stream, unsigned limit) const;
52  void removeRoutingCache(Target & target, StreamBase const & stream) const;
53  void write(time_type timestamp, StreamBase const & stream, unsigned level,
54  std::string const & msg) const;
55 
56  private:
57  struct RouteEntry {
58  RouteEntry(unsigned limit_, Target * target_) : limit(limit_), target(target_) {}
59  unsigned limit;
60  Target * target;
61  };
62  typedef std::list<RouteEntry> Routes;
63  struct CacheEntry {
64  CacheEntry() : limit (DISABLED::value), routes() {}
65  unsigned limit;
66  Routes routes;
67  };
68  typedef std::vector<CacheEntry> RoutingCache;
69  mutable RoutingCache routingCache_;
70  bool alive_;
71  };
72 
73 }}}
74 
75 
76 //-/////////////////////////////////////////////////////////////////////////////////////////////////
77 #endif
78 
79 
80 // Local Variables:
81 // mode: c++
82 // fill-column: 100
83 // comment-column: 40
84 // c-file-style: "senf"
85 // indent-tabs-mode: nil
86 // ispell-local-dictionary: "american"
87 // compile-command: "scons -u test"
88 // End: