Cppcheck
checkstatistics.h
Go to the documentation of this file.
1 /*
2  * Cppcheck - A tool for static C/C++ code analysis
3  * Copyright (C) 2007-2024 Cppcheck team.
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef CHECKSTATISTICS_H
20 #define CHECKSTATISTICS_H
21 
22 #include "showtypes.h"
23 
24 #include <QMap>
25 #include <QObject>
26 #include <QString>
27 #include <QStringList>
28 
29 #include <set>
30 #include <string>
31 #include <utility>
32 
33 /// @addtogroup GUI
34 /// @{
35 
36 /**
37  * A class for check statistics.
38  */
39 class CheckStatistics : public QObject {
40 public:
41  explicit CheckStatistics(QObject *parent = nullptr);
42 
43  /**
44  * @brief Add new checked item to statistics.
45  *
46  * @param tool Tool.
47  * @param type Type of the item to add.
48  */
49  void addItem(const QString &tool, ShowTypes::ShowType type);
50 
51  /**
52  * @brief Add checker to statistics
53  */
54  void addChecker(const QString& checker);
55 
56  /**
57  * @brief Clear the statistics.
58  *
59  */
60  void clear();
61 
62  /**
63  * @brief Return statistics for given type.
64  *
65  * @param tool Tool.
66  * @param type Type for which the statistics are returned.
67  * @return Number of items of given type.
68  */
69  unsigned getCount(const QString &tool, ShowTypes::ShowType type) const;
70 
71  const std::set<std::string>& getActiveCheckers() const {
72  return mActiveCheckers;
73  }
74 
76  return mActiveCheckers.size();
77  }
78 
79  /** Get tools with results */
80  QStringList getTools() const;
81 
82  void setCheckersReport(QString report) {
83  mCheckersReport = std::move(report);
84  }
85  const QString& getCheckersReport() const {
86  return mCheckersReport;
87  }
88 
89 private:
90  QMap<QString, unsigned> mStyle;
91  QMap<QString, unsigned> mWarning;
92  QMap<QString, unsigned> mPerformance;
93  QMap<QString, unsigned> mPortability;
94  QMap<QString, unsigned> mInformation;
95  QMap<QString, unsigned> mError;
96  std::set<std::string> mActiveCheckers;
97  QString mCheckersReport;
98 };
99 
100 /// @}
101 
102 #endif // CHECKSTATISTICS_H
A class for check statistics.
QStringList getTools() const
Get tools with results.
const QString & getCheckersReport() const
void clear()
Clear the statistics.
std::set< std::string > mActiveCheckers
CheckStatistics(QObject *parent=nullptr)
unsigned getCount(const QString &tool, ShowTypes::ShowType type) const
Return statistics for given type.
QMap< QString, unsigned > mError
QMap< QString, unsigned > mPortability
QMap< QString, unsigned > mWarning
const std::set< std::string > & getActiveCheckers() const
void addItem(const QString &tool, ShowTypes::ShowType type)
Add new checked item to statistics.
QMap< QString, unsigned > mInformation
void setCheckersReport(QString report)
int getNumberOfActiveCheckers() const
void addChecker(const QString &checker)
Add checker to statistics.
QString mCheckersReport
QMap< QString, unsigned > mPerformance
QMap< QString, unsigned > mStyle
ShowType
Show types we have (i.e.
Definition: showtypes.h:44