LogStream.h
Go to the documentation of this file.
00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
00002 
00003 // -- BEGIN LICENSE BLOCK ----------------------------------------------
00004 // This file is part of FZIs ic_workspace.
00005 //
00006 // This program is free software licensed under the LGPL
00007 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
00008 // You can find a copy of this license in LICENSE folder in the top
00009 // directory of the source code.
00010 //
00011 // © Copyright 2014 FZI Forschungszentrum Informatik, Karlsruhe, Germany
00012 //
00013 // -- END LICENSE BLOCK ------------------------------------------------
00014 
00015 //----------------------------------------------------------------------
00027 //----------------------------------------------------------------------
00028 #ifndef ICL_CORE_LOGGING_LOG_STREAM_H_INCLUDED
00029 #define ICL_CORE_LOGGING_LOG_STREAM_H_INCLUDED
00030 
00031 
00032 #include <list>
00033 #include <map>
00034 #include <set>
00035 #include <string>
00036 
00037 #include "icl_core/BaseTypes.h"
00038 #include "icl_core/Noncopyable.h"
00039 #include "icl_core/os_thread.h"
00040 #include "icl_core_logging/ImportExport.h"
00041 #include "icl_core_logging/LogLevel.h"
00042 #include "icl_core_logging/Semaphore.h"
00043 
00044 namespace icl_core {
00045 namespace logging {
00046 
00047 class LogOutputStream;
00048 class LogStream;
00049 class ThreadStream;
00050 
00051 typedef std::set<LogStream*> LogStreamSet;
00052 
00054 class ICL_CORE_LOGGING_IMPORT_EXPORT LogStream : private icl_core::Noncopyable
00055 {
00056   friend class LoggingManager;
00057   friend class ThreadStream;
00058 
00059 public:
00063   LogStream(const icl_core::String& name, icl_core::logging::LogLevel initial_level = cDEFAULT_LOG_LEVEL);
00064 
00065   ~LogStream();
00066 
00068   icl_core::String name() const { return m_name; }
00069   const char *nameCStr() const { return m_name.c_str(); }
00070 
00072   void setActive(bool active = true) { m_active = active; }
00073 
00075   icl_core::logging::LogLevel initialLogLevel() const { return m_initial_level; }
00076 
00078   bool isActive() const { return m_active; }
00079 
00081   icl_core::logging::LogLevel getLogLevel() const;
00082 
00086   void addOutputStream(LogOutputStream *new_stream);
00087 
00091   void removeOutputStream(LogOutputStream *stream);
00092 
00098   icl_core::logging::ThreadStream& threadStream(icl_core::logging::LogLevel log_level);
00099 
00101   void printConfiguration() const;
00102 
00104 #ifdef _IC_BUILDER_DEPRECATED_STYLE_
00105 
00109   ICL_CORE_VC_DEPRECATE_STYLE icl_core::String Name() const ICL_CORE_GCC_DEPRECATE_STYLE;
00110 
00111   ICL_CORE_VC_DEPRECATE_STYLE const char *NameCStr() const ICL_CORE_GCC_DEPRECATE_STYLE;
00112 
00116   ICL_CORE_VC_DEPRECATE_STYLE void SetActive(bool active = true) ICL_CORE_GCC_DEPRECATE_STYLE;
00117 
00121   ICL_CORE_VC_DEPRECATE_STYLE icl_core::logging::LogLevel InitialLogLevel() const ICL_CORE_GCC_DEPRECATE_STYLE;
00122 
00126   ICL_CORE_VC_DEPRECATE_STYLE bool IsActive() const ICL_CORE_GCC_DEPRECATE_STYLE;
00127 
00128   ICL_CORE_VC_DEPRECATE_STYLE_USE(LogStream::getLogLevel)
00129   icl_core::logging::LogLevel LogLevel() const ICL_CORE_GCC_DEPRECATE_STYLE_USE(LogStream::getLogLevel);
00130 
00135   ICL_CORE_VC_DEPRECATE_STYLE void AddOutputStream(LogOutputStream *new_stream) ICL_CORE_GCC_DEPRECATE_STYLE;
00136 
00141   ICL_CORE_VC_DEPRECATE_STYLE void RemoveOutputStream(LogOutputStream *stream) ICL_CORE_GCC_DEPRECATE_STYLE;
00142 
00146   ICL_CORE_VC_DEPRECATE_STYLE void PrintConfiguration() const ICL_CORE_GCC_DEPRECATE_STYLE;
00147 
00153   ICL_CORE_VC_DEPRECATE_STYLE
00154     icl_core::logging::ThreadStream& ThreadStream(icl_core::logging::LogLevel log_level)
00155     ICL_CORE_GCC_DEPRECATE_STYLE;
00156 
00157 #endif
00158 
00159 
00160 private:
00161   void releaseThreadStream(icl_core::logging::ThreadStream *thread_stream);
00162 
00163   icl_core::logging::LogLevel m_initial_level;
00164 
00165   struct ThreadStreamInfo
00166   {
00167     ThreadStreamInfo(ThreadId thread_id,
00168                      icl_core::logging::LogLevel log_level,
00169                      icl_core::logging::ThreadStream *thread_stream)
00170       : thread_id(thread_id),
00171         log_level(log_level),
00172         thread_stream(thread_stream)
00173     { }
00174 
00175     ThreadId thread_id;
00176     icl_core::logging::LogLevel log_level;
00177     icl_core::logging::ThreadStream *thread_stream;
00178   };
00179   typedef std::list<ThreadStreamInfo> ThreadStreamMap;
00180   ThreadStreamMap m_thread_stream_map;
00181 
00182   icl_core::String m_name;
00183   bool m_active;
00184   std::set<LogOutputStream*> m_output_stream_list;
00185 
00186   // Safe access to the output stream list.
00187   Semaphore m_mutex;
00188 
00189   static ThreadId m_empty_thread_id;
00190 };
00191 
00192 }
00193 }
00194 
00195 #endif


schunk_svh_driver
Author(s): Georg Heppner
autogenerated on Fri Aug 28 2015 12:59:19