Cppcheck
threadresult.h
Go to the documentation of this file.
00001 /*
00002  * Cppcheck - A tool for static C/C++ code analysis
00003  * Copyright (C) 2007-2013 Daniel Marjamäki and Cppcheck team.
00004  *
00005  * This program is free software: you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation, either version 3 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017  */
00018 
00019 
00020 #ifndef THREADRESULT_H
00021 #define THREADRESULT_H
00022 
00023 #include <QMutex>
00024 #include <QObject>
00025 #include <QStringList>
00026 #include "errorlogger.h"
00027 
00028 class ErrorItem;
00029 
00030 /// @addtogroup GUI
00031 /// @{
00032 
00033 /**
00034 * @brief Threads use this class to obtain new files to process and to publish results
00035 *
00036 */
00037 class ThreadResult : public QObject, public ErrorLogger {
00038     Q_OBJECT
00039 public:
00040     ThreadResult();
00041     virtual ~ThreadResult();
00042 
00043     /**
00044     * @brief Get next unprocessed file
00045     * @return File path
00046     */
00047     QString GetNextFile();
00048 
00049     /**
00050     * @brief Set list of files to check
00051     * @param files List of files to check
00052     */
00053     void SetFiles(const QStringList &files);
00054 
00055     /**
00056     * @brief Clear files to check
00057     *
00058     */
00059     void ClearFiles();
00060 
00061     /**
00062     * @brief Get the number of files to check
00063     *
00064     */
00065     int GetFileCount() const;
00066 
00067     /**
00068     * ErrorLogger methods
00069     */
00070     void reportOut(const std::string &outmsg);
00071     void reportErr(const ErrorLogger::ErrorMessage &msg);
00072 
00073 public slots:
00074 
00075     /**
00076     * @brief Slot threads use to signal this class that a specific file is checked
00077     * @param file File that is checked
00078     */
00079     void FileChecked(const QString &file);
00080 signals:
00081     /**
00082     * @brief Progress signal
00083     * @param value Current progress
00084     * @param description Description of the current stage
00085     */
00086     void Progress(int value, const QString& description);
00087 
00088     /**
00089     * @brief Signal of a new error
00090     *
00091     * @param item Error data
00092     */
00093     void Error(const ErrorItem &item);
00094 
00095     /**
00096     * @brief Signal of a new log message
00097     *
00098     * @param logline Log line
00099     */
00100     void Log(const QString &logline);
00101 
00102     /**
00103     * @brief Signal of a debug error
00104     *
00105     * @param item Error data
00106     */
00107     void DebugError(const ErrorItem &item);
00108 
00109 protected:
00110 
00111     /**
00112     * @brief Mutex
00113     *
00114     */
00115     mutable QMutex mutex;
00116 
00117     /**
00118     * @brief List of files to check
00119     *
00120     */
00121     QStringList mFiles;
00122 
00123     /**
00124     * @brief Max progress
00125     *
00126     */
00127     quint64 mMaxProgress;
00128 
00129     /**
00130     * @brief Current progress
00131     *
00132     */
00133     quint64 mProgress;
00134 
00135     /**
00136     * @brief Current number of files checked
00137     *
00138     */
00139     unsigned long mFilesChecked;
00140 
00141     /**
00142     * @brief Total number of files
00143     *
00144     */
00145     unsigned long mTotalFiles;
00146 };
00147 /// @}
00148 #endif // THREADRESULT_H