LibrePCB Developers Documentation
rulecheckmessage.h
Go to the documentation of this file.
1/*
2 * LibrePCB - Professional EDA for everyone!
3 * Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
4 * https://librepcb.org/
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef LIBREPCB_CORE_RULECHECKMESSAGE_H
21#define LIBREPCB_CORE_RULECHECKMESSAGE_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../geometry/path.h"
27#include "../serialization/sexpression.h"
28
29#include <QtCore>
30
31#include <memory>
32
33/*******************************************************************************
34 * Namespace / Forward Declarations
35 ******************************************************************************/
36namespace librepcb {
37
38/*******************************************************************************
39 * Class RuleCheckMessage
40 ******************************************************************************/
41
46 Q_DECLARE_TR_FUNCTIONS(RuleCheckMessage)
47
48public:
50 enum class Severity {
51 Hint = 0,
52 Warning = 1,
53 Error = 2,
54 };
55
56 // Constructors / Destructor
57 RuleCheckMessage() = delete;
58
59 // Getters
60 Severity getSeverity() const noexcept { return mSeverity; }
61 QString getSeverityTr() const noexcept;
62 const QIcon& getSeverityIcon() const noexcept;
63 const QString& getMessage() const noexcept { return mMessage; }
64 const QString& getDescription() const noexcept { return mDescription; }
65 const SExpression& getApproval() const noexcept { return *mApproval; }
66 const QVector<Path>& getLocations() const noexcept { return mLocations; }
67
68 // General Methods
69 template <typename T>
70 T* as() noexcept {
71 return dynamic_cast<T*>(this);
72 }
73 template <typename T>
74 const T* as() const noexcept {
75 return dynamic_cast<const T*>(this);
76 }
77
78 // Static Methods
79 static QString getSeverityTr(Severity severity) noexcept;
80 static const QIcon& getSeverityIcon(Severity severity) noexcept;
81 static QSet<SExpression> getAllApprovals(
82 const QVector<std::shared_ptr<const RuleCheckMessage>>&
83 messages) noexcept;
84
85 // Operator Overloads
86 bool operator==(const RuleCheckMessage& rhs) const noexcept;
87 bool operator!=(const RuleCheckMessage& rhs) const noexcept;
88
89protected: // Methods
90 RuleCheckMessage(const RuleCheckMessage& other) noexcept;
91 RuleCheckMessage(Severity severity, const QString& msg,
92 const QString& description, const QString& approvalName,
93 const QVector<Path>& locations = {}) noexcept;
94 virtual ~RuleCheckMessage() noexcept;
95
96protected: // Data
98 QString mMessage;
99 QString mDescription;
100 std::unique_ptr<SExpression> mApproval;
101 QVector<Path> mLocations;
102};
103
104typedef QVector<std::shared_ptr<const RuleCheckMessage>> RuleCheckMessageList;
105
106/*******************************************************************************
107 * End of File
108 ******************************************************************************/
109
110} // namespace librepcb
111
112#endif
The Path class represents a list of vertices connected by straight lines or circular arc segments.
Definition: path.h:58
The RuleCheckMessage class.
Definition: rulecheckmessage.h:45
Severity
Message severity type (higher number = higher severity)
Definition: rulecheckmessage.h:50
bool operator!=(const RuleCheckMessage &rhs) const noexcept
Definition: rulecheckmessage.cpp:114
QString mDescription
Definition: rulecheckmessage.h:99
T * as() noexcept
Definition: rulecheckmessage.h:70
virtual ~RuleCheckMessage() noexcept
Definition: rulecheckmessage.cpp:54
QVector< Path > mLocations
Definition: rulecheckmessage.h:101
const QString & getDescription() const noexcept
Definition: rulecheckmessage.h:64
const T * as() const noexcept
Definition: rulecheckmessage.h:74
QString getSeverityTr() const noexcept
Definition: rulecheckmessage.cpp:57
const QVector< Path > & getLocations() const noexcept
Definition: rulecheckmessage.h:66
bool operator==(const RuleCheckMessage &rhs) const noexcept
Definition: rulecheckmessage.cpp:106
const QString & getMessage() const noexcept
Definition: rulecheckmessage.h:63
QString mMessage
Definition: rulecheckmessage.h:98
const QIcon & getSeverityIcon() const noexcept
Definition: rulecheckmessage.cpp:61
static QSet< SExpression > getAllApprovals(const QVector< std::shared_ptr< const RuleCheckMessage > > &messages) noexcept
Definition: rulecheckmessage.cpp:92
Severity getSeverity() const noexcept
Definition: rulecheckmessage.h:60
Severity mSeverity
Definition: rulecheckmessage.h:97
std::unique_ptr< SExpression > mApproval
Definition: rulecheckmessage.h:100
const SExpression & getApproval() const noexcept
Definition: rulecheckmessage.h:65
The SExpression class.
Definition: sexpression.h:69
Definition: occmodel.cpp:77
QVector< std::shared_ptr< const RuleCheckMessage > > RuleCheckMessageList
Definition: rulecheckmessage.h:104