Cppcheck
checkthread.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 CHECKTHREAD_H
00021 #define CHECKTHREAD_H
00022 
00023 #include <QThread>
00024 #include "cppcheck.h"
00025 #include "threadresult.h"
00026 
00027 class Settings;
00028 
00029 /// @addtogroup GUI
00030 /// @{
00031 
00032 /**
00033 * @brief Thread to run cppcheck
00034 *
00035 */
00036 class CheckThread : public QThread {
00037     Q_OBJECT
00038 public:
00039     CheckThread(ThreadResult &result);
00040     virtual ~CheckThread();
00041 
00042     /**
00043     * @brief Set settings for cppcheck
00044     *
00045     * @param settings settings for cppcheck
00046     */
00047     void Check(const Settings &settings);
00048 
00049     /**
00050     * @brief method that is run in a thread
00051     *
00052     */
00053     void run();
00054 
00055     void stop();
00056 
00057 
00058 signals:
00059 
00060     /**
00061     * @brief cpp checking is done
00062     *
00063     */
00064     void Done();
00065 
00066     void FileChecked(const QString &file);
00067 protected:
00068 
00069     /**
00070     * @brief States for the check thread.
00071     * Whole purpose of these states is to allow stopping of the checking. When
00072     * stopping we say for the thread (Stopping) that stop when current check
00073     * has been completed. Thread must be stopped cleanly, just terminating thread
00074     * likely causes unpredictable side-effects.
00075     */
00076     enum State {
00077         Running, /**< The thread is checking. */
00078         Stopping, /**< The thread will stop after current work. */
00079         Stopped, /**< The thread has been stopped. */
00080         Ready, /**< The thread is ready. */
00081     };
00082 
00083     /**
00084     * @brief Thread's current execution state.
00085     */
00086     State mState;
00087 
00088     ThreadResult &mResult;
00089     /**
00090     * @brief Cppcheck itself
00091     *
00092     */
00093     CppCheck mCppcheck;
00094 private:
00095 };
00096 /// @}
00097 #endif // CHECKTHREAD_H