kradio4 r778
thread-logging.h
Go to the documentation of this file.
00001 /***************************************************************************
00002                           thread-logging.h  -  description
00003                              -------------------
00004     begin                : Sun Feb 12 2012
00005     copyright            : (C) 2012 by Martin Witte
00006     email                : emw-kradio@nocabal.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef __THREAD_LOGGING_H__
00019 #define __THREAD_LOGGING_H__
00020 
00021 
00022 #include <QtCore/QMutex>
00023 #include <QtCore/QString>
00024 #include <errorlog_interfaces.h>
00025 
00026 // logging in thread
00027 class KDE_EXPORT ThreadLogging
00028 {
00029 public:
00030 
00031     enum  LoggingClass { LogInfo, LogWarning, LogDebug, LogError };
00032 
00033     ThreadLogging();
00034 
00035     bool                 hasLog (LoggingClass cls)                       const;
00036     QStringList          getLogs(LoggingClass cls, bool resetLog = true);
00037 
00038     QList<LoggingClass>  getLogClasses() const;
00039 
00040     void                 log    (LoggingClass cls, QString logString);
00041 
00042 private:
00043     mutable QMutex                    m_accessLock;
00044     QMap<LoggingClass, QStringList>   logs;
00045 };
00046 
00047 
00048 
00049 // receiving logs outside the thread
00050 class KDE_EXPORT ThreadLoggingClient
00051 {
00052 public:
00053     ThreadLoggingClient();
00054     virtual ~ThreadLoggingClient();
00055 
00056     // returns false if there logs of class LogError are available
00057     bool   checkLogs(ThreadLogging *threadLogger, QString logPrefix, bool resetLogs = true);
00058 
00059 
00060 protected:
00061     virtual IErrorLogClient *getErrorLogClient() = 0;
00062 
00063 
00064 protected:
00065     // returns true if some messages were logged
00066     bool   checkLogs(ThreadLogging *threadLogger, ThreadLogging::LoggingClass cls, QString logPrefix, IErrorLogClient::logFunction_t logFunc, bool resetLog);
00067 };
00068 
00069 
00070 #endif
00071 
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines