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
44class wxString;
45class wxStatusBar;
46class wxTextCtrl;
48class WX_INFOBAR;
49
50
71{
72public:
79 enum LOCATION {
83 };
84
93 virtual REPORTER& Report( const wxString& aText,
94 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) = 0;
95
99 virtual REPORTER& ReportTail( const wxString& aText,
100 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED )
101 {
102 return Report( aText, aSeverity );
103 }
104
108 virtual REPORTER& ReportHead( const wxString& aText,
109 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED )
110 {
111 return Report( aText, aSeverity );
112 }
113
114 REPORTER& Report( const char* aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED );
115
116 REPORTER& operator <<( const wxString& aText ) { return Report( aText ); }
117
121 virtual bool HasMessage() const = 0;
122
123 virtual EDA_UNITS GetUnits() const
124 {
125 return EDA_UNITS::MILLIMETRES;
126 }
127
128 virtual ~REPORTER()
129 {
130 }
131};
132
133
138{
139public:
140 WX_TEXT_CTRL_REPORTER( wxTextCtrl* aTextCtrl ) :
141 REPORTER(),
142 m_textCtrl( aTextCtrl )
143 {
144 }
145
147 {
148 }
149
150 REPORTER& Report( const wxString& aText,
151 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
152
153 bool HasMessage() const override;
154
155private:
156 wxTextCtrl* m_textCtrl;
157};
158
159
164{
165public:
166 WX_STRING_REPORTER( wxString* aString ) :
167 REPORTER(),
168 m_string( aString )
169 {
170 }
171
173 {
174 }
175
176 REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
177
178 bool HasMessage() const override;
179
180private:
181 wxString* m_string;
182};
183
184
189{
190public:
192 REPORTER(),
193 m_panel( aPanel )
194 {
195 }
196
198 {
199 }
200
201 REPORTER& Report( const wxString& aText,
202 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
203
204 REPORTER& ReportTail( const wxString& aText,
205 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
206
207 REPORTER& ReportHead( const wxString& aText,
208 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
209
210 bool HasMessage() const override;
211
212private:
214};
215
216
223{
224public:
226 {
227 }
228
230 {
231 }
232
233 static REPORTER& GetInstance();
234
235 REPORTER& Report( const wxString& aText,
236 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
237
238 bool HasMessage() const override { return false; }
239};
240
241
246{
247public:
249 {
250 }
251
253 {
254 }
255
256 static REPORTER& GetInstance();
257
258 REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
259
260 bool HasMessage() const override { return false; }
261};
262
263
265{
266public:
268 {
269 }
270
272 {
273 }
274
275 static REPORTER& GetInstance();
276
277 REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
278
279 bool HasMessage() const override { return false; }
280};
281
282
287{
288public:
289 STATUSBAR_REPORTER( wxStatusBar* aStatusBar, int aPosition = 0 )
290 : REPORTER(),
291 m_statusBar( aStatusBar ),
292 m_position( aPosition )
293 {
294 }
295
296 REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
297
298 bool HasMessage() const override;
299
300private:
301 wxStatusBar* m_statusBar;
303};
304
305
316{
317public:
319 : REPORTER(),
320 m_messageSet( false ),
321 m_infoBar( aInfoBar ),
323 {
324 }
325
326 virtual ~INFOBAR_REPORTER();
327
328 REPORTER& Report( const wxString& aText,
329 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
330
331 bool HasMessage() const override;
332
336 void Finalize();
337
338private:
341 std::unique_ptr<wxString> m_message;
343};
344
345#endif // _REPORTER_H_
A wrapper for reporting to a WX_INFOBAR UI element.
Definition: reporter.h:316
INFOBAR_REPORTER(WX_INFOBAR *aInfoBar)
Definition: reporter.h:318
WX_INFOBAR * m_infoBar
Definition: reporter.h:340
void Finalize()
Update the infobar with the reported text.
Definition: reporter.cpp:227
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
Definition: reporter.cpp:211
SEVERITY m_severity
Definition: reporter.h:342
std::unique_ptr< wxString > m_message
Definition: reporter.h:341
virtual ~INFOBAR_REPORTER()
Definition: reporter.cpp:206
bool HasMessage() const override
Returns true if the reporter client is non-empty.
Definition: reporter.cpp:221
A singleton reporter that reports to nowhere.
Definition: reporter.h:223
static REPORTER & GetInstance()
Definition: reporter.cpp:117
virtual ~NULL_REPORTER()
Definition: reporter.h:229
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
Definition: reporter.cpp:111
bool HasMessage() const override
Returns true if the reporter client is non-empty.
Definition: reporter.h:238
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:71
virtual EDA_UNITS GetUnits() const
Definition: reporter.h:123
REPORTER & operator<<(const wxString &aText)
Definition: reporter.h:116
LOCATION
Location where the message is to be reported.
Definition: reporter.h:79
@ LOC_BODY
Definition: reporter.h:81
@ LOC_TAIL
Definition: reporter.h:82
@ LOC_HEAD
Definition: reporter.h:80
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:108
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:99
virtual ~REPORTER()
Definition: reporter.h:128
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:287
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
Definition: reporter.cpp:188
STATUSBAR_REPORTER(wxStatusBar *aStatusBar, int aPosition=0)
Definition: reporter.h:289
wxStatusBar * m_statusBar
Definition: reporter.h:301
bool HasMessage() const override
Returns true if the reporter client is non-empty.
Definition: reporter.cpp:197
Debug type reporter, forwarding messages to std::cout.
Definition: reporter.h:246
REPORTER & Report(const wxString &aMsg, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
Definition: reporter.cpp:128
static REPORTER & GetInstance()
Definition: reporter.cpp:148
virtual ~STDOUT_REPORTER()
Definition: reporter.h:252
bool HasMessage() const override
Returns true if the reporter client is non-empty.
Definition: reporter.h:260
bool HasMessage() const override
Returns true if the reporter client is non-empty.
Definition: reporter.h:279
REPORTER & Report(const wxString &aMsg, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
Definition: reporter.cpp:159
virtual ~WXLOG_REPORTER()
Definition: reporter.h:271
static REPORTER & GetInstance()
Definition: reporter.cpp:177
A wrapper for reporting to a wx HTML window.
Definition: reporter.h:189
virtual ~WX_HTML_PANEL_REPORTER()
Definition: reporter.h:197
bool HasMessage() const override
Returns true if the reporter client is non-empty.
Definition: reporter.cpp:105
REPORTER & ReportTail(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Places the report at the end of the list, for objects that support report ordering.
Definition: reporter.cpp:85
REPORTER & ReportHead(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Places the report at the beginning of the list for objects that support ordering.
Definition: reporter.cpp:95
WX_HTML_PANEL_REPORTER(WX_HTML_REPORT_PANEL *aPanel)
Definition: reporter.h:191
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
Definition: reporter.cpp:75
WX_HTML_REPORT_PANEL * m_panel
Definition: reporter.h:213
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:75
A wrapper for reporting to a wxString object.
Definition: reporter.h:164
virtual ~WX_STRING_REPORTER()
Definition: reporter.h:172
bool HasMessage() const override
Returns true if the reporter client is non-empty.
Definition: reporter.cpp:69
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
Definition: reporter.cpp:59
WX_STRING_REPORTER(wxString *aString)
Definition: reporter.h:166
wxString * m_string
Definition: reporter.h:181
A wrapper for reporting to a wxTextCtrl object.
Definition: reporter.h:138
virtual ~WX_TEXT_CTRL_REPORTER()
Definition: reporter.h:146
wxTextCtrl * m_textCtrl
Definition: reporter.h:156
bool HasMessage() const override
Returns true if the reporter client is non-empty.
Definition: reporter.cpp:53
WX_TEXT_CTRL_REPORTER(wxTextCtrl *aTextCtrl)
Definition: reporter.h:140
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
Definition: reporter.cpp:43
EDA_UNITS
Definition: eda_units.h:43
SEVERITY
@ RPT_SEVERITY_UNDEFINED