LoggingManager.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 //----------------------------------------------------------------------
00026 //----------------------------------------------------------------------
00027 #ifndef ICL_CORE_LOGGING_LOGGING_MANAGER_H_INCLUDED
00028 #define ICL_CORE_LOGGING_LOGGING_MANAGER_H_INCLUDED
00029 
00030 #include <icl_core/BaseTypes.h>
00031 #include <icl_core/List.h>
00032 #include <icl_core/Map.h>
00033 #include "icl_core_logging/ImportExport.h"
00034 #include "icl_core_logging/LogLevel.h"
00035 
00036 #include <boost/shared_ptr.hpp>
00037 
00038 #ifdef _IC_BUILDER_DEPRECATED_STYLE_
00039 # include "icl_core/Deprecate.h"
00040 #endif
00041 
00042 namespace icl_core {
00043 namespace logging {
00044 
00045 class LogOutputStream;
00046 class LogStream;
00047 
00048 typedef LogOutputStream* (*LogOutputStreamFactory)(const icl_core::String& name,
00049                                                    const icl_core::String& config_prefix,
00050                                                    LogLevel log_level);
00051 typedef LogStream* (*LogStreamFactory)();
00052 
00061 class ICL_CORE_LOGGING_IMPORT_EXPORT LoggingManager
00062 {
00063 public:
00064   static LoggingManager& instance()
00065   {
00066     static LoggingManager manager_instance;
00067     return manager_instance;
00068   }
00069 
00075   void configure();
00076 
00087   void initialize();
00088 
00091   bool initialized() const { return m_initialized; }
00092 
00096   void assertInitialized() const;
00097 
00100   void registerLogOutputStream(const icl_core::String& name, LogOutputStreamFactory factory);
00101 
00104   void removeLogOutputStream(LogOutputStream *log_output_stream, bool remove_from_list = true);
00105 
00108   void registerLogStream(const icl_core::String& name, LogStreamFactory factory);
00109 
00112   void registerLogStream(LogStream *log_stream);
00113 
00116   void removeLogStream(const icl_core::String& log_stream_name);
00117 
00122   void printConfiguration() const;
00123 
00127   void changeLogFormat(const icl_core::String& name, const char *format = "~T ~S(~L)~ C~(O~::D: ~E");
00128 
00134   void shutdown();
00135 
00137 #ifdef _IC_BUILDER_DEPRECATED_STYLE_
00138 
00139   static ICL_CORE_VC_DEPRECATE_STYLE LoggingManager& Instance()
00140     ICL_CORE_GCC_DEPRECATE_STYLE;
00141 
00145   ICL_CORE_VC_DEPRECATE_STYLE void Configure()
00146     ICL_CORE_GCC_DEPRECATE_STYLE;
00147 
00151   ICL_CORE_VC_DEPRECATE_STYLE void Initialize()
00152     ICL_CORE_GCC_DEPRECATE_STYLE;
00153 
00157   ICL_CORE_VC_DEPRECATE_STYLE bool Initialized() const
00158     ICL_CORE_GCC_DEPRECATE_STYLE;
00159 
00163   ICL_CORE_VC_DEPRECATE_STYLE void AssertInitialized() const
00164     ICL_CORE_GCC_DEPRECATE_STYLE;
00165 
00169   ICL_CORE_VC_DEPRECATE_STYLE void RegisterLogOutputStream(const icl_core::String& name,
00170                                                            LogOutputStreamFactory factory)
00171     ICL_CORE_GCC_DEPRECATE_STYLE;
00172 
00176   ICL_CORE_VC_DEPRECATE_STYLE void RemoveLogOutputStream(LogOutputStream *log_output_stream,
00177                                                          bool remove_from_list = true)
00178     ICL_CORE_GCC_DEPRECATE_STYLE;
00179 
00183   ICL_CORE_VC_DEPRECATE_STYLE void RegisterLogStream(const icl_core::String& name,
00184                                                      LogStreamFactory factory)
00185     ICL_CORE_GCC_DEPRECATE_STYLE;
00186 
00190   ICL_CORE_VC_DEPRECATE_STYLE void RegisterLogStream(LogStream *log_stream)
00191     ICL_CORE_GCC_DEPRECATE_STYLE;
00192 
00196   ICL_CORE_VC_DEPRECATE_STYLE void RemoveLogStream(const icl_core::String& log_stream_name)
00197     ICL_CORE_GCC_DEPRECATE_STYLE;
00198 
00202   ICL_CORE_VC_DEPRECATE_STYLE void PrintConfiguration() const
00203     ICL_CORE_GCC_DEPRECATE_STYLE;
00204 
00208   ICL_CORE_VC_DEPRECATE_STYLE void ChangeLogFormat(const icl_core::String& name,
00209                                                    const char *format = "~T ~S(~L)~ C~(O~::D: ~E")
00210     ICL_CORE_GCC_DEPRECATE_STYLE;
00211 
00215   ICL_CORE_VC_DEPRECATE_STYLE void Shutdown()
00216     ICL_CORE_GCC_DEPRECATE_STYLE;
00217 
00218 #endif
00219 
00220 
00221 private:
00222   typedef icl_core::List<icl_core::String> StringList;
00223 
00225   struct LogOutputStreamConfig
00226   {
00230     icl_core::String output_stream_name;
00232     icl_core::String name;
00234     LogLevel log_level;
00236     StringList log_streams;
00237   };
00238   typedef icl_core::Map<icl_core::String, LogOutputStreamConfig> LogOutputStreamConfigMap;
00239 
00241   struct LogStreamConfig
00242   {
00244     icl_core::String name;
00246     LogLevel log_level;
00247   };
00248   typedef icl_core::Map<icl_core::String, LogStreamConfig> LogStreamConfigMap;
00249 
00250   LoggingManager();
00251 
00252   ~LoggingManager();
00253 
00254   // Forbid copying logging manager objects.
00255   LoggingManager(const LoggingManager&);
00256   LoggingManager& operator = (const LoggingManager&);
00257 
00258   bool m_initialized;
00259   bool m_shutdown_running;
00260 
00261   LogOutputStreamConfigMap m_output_stream_config;
00262   LogStreamConfigMap m_log_stream_config;
00263 
00264   typedef icl_core::Map<icl_core::String, LogStream*> LogStreamMap;
00265   typedef icl_core::Map<icl_core::String, LogOutputStreamFactory> LogOutputStreamFactoryMap;
00266   typedef icl_core::Map<icl_core::String, LogStreamFactory> LogStreamFactoryMap;
00267   typedef icl_core::Map<icl_core::String, LogOutputStream*> LogOutputStreamMap;
00268   LogStreamMap m_log_streams;
00269   LogOutputStreamFactoryMap m_log_output_stream_factories;
00270   LogStreamFactoryMap m_log_stream_factories;
00271   LogOutputStreamMap m_log_output_streams;
00272 
00273   LogOutputStream *m_default_log_output;
00274 };
00275 
00277 namespace hidden {
00278 
00285 class ICL_CORE_LOGGING_IMPORT_EXPORT LogOutputStreamRegistrar
00286 {
00287 public:
00288   LogOutputStreamRegistrar(const icl_core::String& name, LogOutputStreamFactory factory);
00289 };
00290 
00296 class ICL_CORE_LOGGING_IMPORT_EXPORT LogStreamRegistrar
00297 {
00298 public:
00299   LogStreamRegistrar(const icl_core::String& name, LogStreamFactory factory);
00300 };
00301 
00302 }
00303 
00307 class ICL_CORE_LOGGING_IMPORT_EXPORT LifeCycle
00308 {
00309 public:
00311   typedef boost::shared_ptr<LifeCycle> Ptr;
00313   typedef boost::shared_ptr<const LifeCycle> ConstPtr;
00314 
00316   LifeCycle(int &argc, char *argv[]);
00317 
00319   ~LifeCycle();
00320 };
00321 
00322 }
00323 }
00324 
00325 #endif


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