KiCad PCB EDA Suite
Loading...
Searching...
No Matches
reporter.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2013 Wayne Stambaugh <[email protected]>
5 * Copyright (C) 2013-2021 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#ifndef _REPORTER_H_
26#define _REPORTER_H_
27
28#include <memory>
29
30#include <eda_units.h>
32#include <kicommon.h>
33
45class wxString;
46class wxStatusBar;
47class wxTextCtrl;
49class WX_INFOBAR;
50
51
72{
73public:
80 enum LOCATION {
81 LOC_HEAD = 0,
83 LOC_TAIL
84 };
85
94 virtual REPORTER& Report( const wxString& aText,
95 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) = 0;
96
100 virtual REPORTER& ReportTail( const wxString& aText,
101 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED )
102 {
103 return Report( aText, aSeverity );
104 }
105
109 virtual REPORTER& ReportHead( const wxString& aText,
110 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED )
111 {
112 return Report( aText, aSeverity );
113 }
114
115 REPORTER& Report( const char* aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED );
116
117 REPORTER& operator <<( const wxString& aText ) { return Report( aText ); }
118
122 virtual bool HasMessage() const = 0;
123
128 virtual bool HasMessageOfSeverity( int aSeverityMask ) const;
129
130 virtual EDA_UNITS GetUnits() const
131 {
132 return EDA_UNITS::MILLIMETRES;
133 }
134
135 virtual ~REPORTER()
136 {
137 }
138};
139
140
145{
146public:
147 WX_TEXT_CTRL_REPORTER( wxTextCtrl* aTextCtrl ) :
148 REPORTER(),
149 m_textCtrl( aTextCtrl )
150 {
151 }
152
154 {
155 }
156
157 REPORTER& Report( const wxString& aText,
158 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
159
160 bool HasMessage() const override;
161
162private:
163 wxTextCtrl* m_textCtrl;
164};
165
166
171{
172public:
174 REPORTER(),
175 m_severityMask( 0 )
176 {
177 }
178
180 {
181 }
182
183 REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
184
185 bool HasMessage() const override;
186 bool HasMessageOfSeverity( int aSeverityMask ) const override;
187
188 const wxString& GetMessages() const;
189 void Clear();
190
191private:
192 wxString m_string;
194};
195
196
203{
204public:
206 {
207 }
208
210 {
211 }
212
213 static REPORTER& GetInstance();
214
215 REPORTER& Report( const wxString& aText,
216 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
217
218 bool HasMessage() const override { return false; }
219};
220
221
226{
227public:
229 {
230 }
231
233 {
234 }
235
236 static REPORTER& GetInstance();
237
238 REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
239
240 bool HasMessage() const override { return false; }
241};
242
243
248{
249public:
251 {
252 }
253
255 {
256 }
257
258 static REPORTER& GetInstance();
259
260 REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
261
262 bool HasMessage() const override { return false; }
263};
264
265
267{
268public:
270 {
271 }
272
274 {
275 }
276
277 static REPORTER& GetInstance();
278
279 REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
280
281 bool HasMessage() const override { return false; }
282};
283
284
289{
290public:
291 STATUSBAR_REPORTER( wxStatusBar* aStatusBar, int aPosition = 0 )
292 : REPORTER(),
293 m_statusBar( aStatusBar ),
294 m_position( aPosition )
295 {
296 }
297
298 REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
299
300 bool HasMessage() const override;
301
302private:
303 wxStatusBar* m_statusBar;
305};
306
307#endif // _REPORTER_H_
Reporter forwarding messages to stdout or stderr as appropriate.
Definition: reporter.h:226
bool HasMessage() const override
Returns true if the reporter client is non-empty.
Definition: reporter.h:240
virtual ~CLI_REPORTER()
Definition: reporter.h:232
A singleton reporter that reports to nowhere.
Definition: reporter.h:203
virtual ~NULL_REPORTER()
Definition: reporter.h:209
bool HasMessage() const override
Returns true if the reporter client is non-empty.
Definition: reporter.h:218
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:72
virtual EDA_UNITS GetUnits() const
Definition: reporter.h:130
LOCATION
Location where the message is to be reported.
Definition: reporter.h:80
@ LOC_BODY
Definition: reporter.h:82
virtual REPORTER & ReportHead(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Places the report at the beginning of the list for objects that support ordering.
Definition: reporter.h:109
virtual bool HasMessage() const =0
Returns true if the reporter client is non-empty.
virtual REPORTER & ReportTail(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Places the report at the end of the list, for objects that support report ordering.
Definition: reporter.h:100
virtual ~REPORTER()
Definition: reporter.h:135
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
A wrapper for reporting to a specific text location in a statusbar.
Definition: reporter.h:289
STATUSBAR_REPORTER(wxStatusBar *aStatusBar, int aPosition=0)
Definition: reporter.h:291
wxStatusBar * m_statusBar
Definition: reporter.h:303
Debug type reporter, forwarding messages to std::cout.
Definition: reporter.h:248
virtual ~STDOUT_REPORTER()
Definition: reporter.h:254
bool HasMessage() const override
Returns true if the reporter client is non-empty.
Definition: reporter.h:262
bool HasMessage() const override
Returns true if the reporter client is non-empty.
Definition: reporter.h:281
virtual ~WXLOG_REPORTER()
Definition: reporter.h:273
A widget for browsing a rich text error/status report.
A modified version of the wxInfoBar class that allows us to:
Definition: wx_infobar.h:76
A wrapper for reporting to a wxString object.
Definition: reporter.h:171
wxString m_string
Definition: reporter.h:192
virtual ~WX_STRING_REPORTER()
Definition: reporter.h:179
A wrapper for reporting to a wxTextCtrl object.
Definition: reporter.h:145
virtual ~WX_TEXT_CTRL_REPORTER()
Definition: reporter.h:153
wxTextCtrl * m_textCtrl
Definition: reporter.h:163
WX_TEXT_CTRL_REPORTER(wxTextCtrl *aTextCtrl)
Definition: reporter.h:147
EDA_UNITS
Definition: eda_units.h:46
#define KICOMMON_API
Definition: kicommon.h:28
SEVERITY
@ RPT_SEVERITY_UNDEFINED