Packets: Fix VariantParser invalid parser access bug
[senf.git] / Utils / Logger / AreaRegistry.ih
index 362c3f6..58709bf 100644 (file)
@@ -1,8 +1,8 @@
 // $Id$
 //
-// Copyright (C) 2007 
-// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
-// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// Copyright (C) 2007
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
 //     Stefan Bund <g0dil@berlios.de>
 //
 // This program is free software; you can redistribute it and/or modify
 /** \file
     \brief AreaRegistry internal header */
 
-#ifndef IH_AreaRegistry_
-#define IH_AreaRegistry_ 1
+#ifndef IH_SENF_Utils_Logger_AreaRegistry_
+#define IH_SENF_Utils_Logger_AreaRegistry_ 1
 
 // Custom includes
 #include <string>
 #include <vector>
+#include <list>
+#include "Levels.hh"
+#include "TimeSource.hh"
 
 ///////////////////////////////ih.p////////////////////////////////////////
 
 namespace senf {
 namespace log {
+
+    class Target;
+
 namespace detail {
 
     class StreamBase;
@@ -41,20 +47,33 @@ namespace detail {
     /** \brief Internal: Area base class */
     struct AreaBase
     {
-        virtual ~AreaBase() {};
+        virtual ~AreaBase();
         
         std::string fullName() const;
         virtual std::string v_name() const;
 
         void init();
 
-        unsigned streamLimit(StreamBase const & stream) const;
-        void setStreamLimit(StreamBase const & stream, unsigned value) const;
+        unsigned limit(StreamBase const & stream) const;
+        void updateRoutingCache(Target & target, StreamBase const & stream, unsigned limit) const; 
+        void removeRoutingCache(Target & target, StreamBase const & stream) const; 
+        void write(time_type timestamp, StreamBase const & stream, unsigned level,
+              std::string msg) const;
 
     private:
-        typedef std::vector<unsigned> StreamLimits;
-        // mutable since this is a cache and may therefore change at unexpected places ...
-        mutable StreamLimits streamLimits_;
+        struct RouteEntry {
+            RouteEntry(unsigned limit_, Target * target_) : limit(limit_), target(target_) {}
+            unsigned limit;
+            Target * target;
+        };
+        typedef std::list<RouteEntry> Routes;
+        struct CacheEntry {
+            CacheEntry() : limit (DISABLED::value), routes() {}
+            unsigned limit;
+            Routes routes;
+        };
+        typedef std::vector<CacheEntry> RoutingCache;
+        mutable RoutingCache routingCache_;
     };
 
 }}}