Add 'unflatten' to doxygen/dot processing
[senf.git] / Utils / Logger / Target.ih
index d80902e..4b81e2e 100644 (file)
 /** \file
     \brief Target internal header */
 
-#ifndef IH_Target_
-#define IH_Target_ 1
+#ifndef IH_SENF_Utils_Logger_Target_
+#define IH_SENF_Utils_Logger_Target_ 1
 
 // Custom includes
 #include <memory>
-#include <boost/scoped_ptr.hpp>
 #include <boost/type_traits/is_same.hpp>
 #include <boost/static_assert.hpp>
+#include <boost/shared_ptr.hpp>
+#include "../Console/LazyDirectory.hh"
+#include "../Console/Parse.hh"
 
 ///////////////////////////////ih.p////////////////////////////////////////
 
 namespace senf {
+
+    namespace console { class DirectoryNode; }
+
 namespace log {
 namespace detail {
 
+    struct LogParameters {
+        StreamBase const * stream;
+        AreaBase const * area;
+        unsigned level;
+        void clear();
+        void setDefaults();
+        static LogParameters defaultParameters();
+    };
+
+    std::ostream & operator<<(std::ostream & os, LogParameters const & pm);
+
+    void senf_console_parse_argument(console::ParseCommandInfo::TokensRange const & tokens, 
+                                     LogParameters & out);
+
     /** \brief Internal: Target registry */
     class TargetRegistry
         : public senf::singleton<TargetRegistry>
     {
     public:
+        enum Level { 
+            VERBOSE = senf::log::VERBOSE::value, 
+            NOTICE = senf::log::NOTICE::value, 
+            MESSAGE = senf::log::MESSAGE::value, 
+            IMPORTANT = senf::log::IMPORTANT::value, 
+            CRITICAL = senf::log::CRITICAL::value, 
+            FATAL = senf::log::FATAL::value
+        };
+
         using senf::singleton<TargetRegistry>::instance;
 
         void write(StreamBase const & stream, AreaBase const & area, unsigned level, 
-                   std::string msg);
-
-        void timeSource(std::auto_ptr<TimeSource> source);
+                   std::string const & msg);
 
         void routed();
         bool fallbackRouting();
 
+        senf::console::ScopedDirectory<> & consoleDir();
+
+        void dynamicTarget(std::auto_ptr<Target> target);
+
     private:
         TargetRegistry();
+        ~TargetRegistry();
         
-        void registerTarget(Target * target);
+        void registerTarget(Target * target, std::string const & name);
         void unregisterTarget(Target * target);
 
+        void consoleAreas(std::ostream & os);
+        void consoleStreams(std::ostream & os);
+        void consoleWrite(LogParameters parameters, std::string const & msg);
+        void consoleRemoveTarget(Target * target);
+        boost::shared_ptr<senf::console::DirectoryNode> consoleSelf(std::ostream & os);
+
         typedef std::set<Target *> Targets;
         Targets targets_;
-        boost::scoped_ptr<TimeSource> timeSource_;
 
         bool fallbackRouting_;
+
+        console::LazyDirectory consoleDir_;
+
+        Targets dynamicTargets_;
         
         friend class senf::log::Target;
         friend class senf::singleton<TargetRegistry>;
@@ -71,7 +111,7 @@ namespace detail {
 
     /** \brief Internal: Write log message */
     template <class Stream, class Area, class Level>
-    void write(std::string msg);
+    void write(std::string const & msg);
 
 #ifndef DOXYGEN
 
@@ -87,7 +127,7 @@ namespace detail {
     // For g++ 4.0 (at least) we need to provide the fully scoped name for this default value.
     // no idea why. It works without the scope in 4.1
     template < class T, class A2, class A1,
-               unsigned type = SENF_MPL_RV( senf::Log::detail::RouteParameterCheck_(static_cast<T*>(0)) ) >
+               unsigned type = SENF_MPL_RV( senf::log::detail::RouteParameterCheck_(static_cast<T*>(0)) ) >
     struct RouteParameters
     {};
 
@@ -113,7 +153,7 @@ namespace detail {
         : public RouteParameters<A2,A1,mpl::nil>
     {
         typedef RouteParameters<A2,A1,mpl::nil> base;
-        BOOST_STATIC_ASSERT( boost::is_same<typename base::Stream, mpl::nil>::value );
+        BOOST_STATIC_ASSERT(( boost::is_same<typename base::Stream, mpl::nil>::value ));
         typedef T Stream;
     };
 
@@ -122,7 +162,7 @@ namespace detail {
         : public RouteParameters<A2,A1,mpl::nil>
     {
         typedef RouteParameters<A2,A1,mpl::nil> base;
-        BOOST_STATIC_ASSERT( boost::is_same<typename base::Area, mpl::nil>::value );
+        BOOST_STATIC_ASSERT(( boost::is_same<typename base::Area, mpl::nil>::value ));
         typedef T Area;
     };
 
@@ -131,7 +171,7 @@ namespace detail {
         : public RouteParameters<A2,A1,mpl::nil>
     {
         typedef RouteParameters<A2,A1,mpl::nil> base;
-        BOOST_STATIC_ASSERT( boost::is_same<typename base::Area, mpl::nil>::value );
+        BOOST_STATIC_ASSERT(( boost::is_same<typename base::Area, mpl::nil>::value ));
         typedef typename T::SENFLogArea Area;
     };
 
@@ -140,7 +180,7 @@ namespace detail {
         : public RouteParameters<A2,A1,mpl::nil>
     {
         typedef RouteParameters<A2,A1,mpl::nil> base;
-        BOOST_STATIC_ASSERT( boost::is_same<typename base::Level, NilLevel>::value );
+        BOOST_STATIC_ASSERT(( boost::is_same<typename base::Level, NilLevel>::value ));
         typedef T Level;
     };