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 The 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#include <map>
30
31#include <eda_units.h>
33#include <kicommon.h>
34
45
46class wxString;
47class wxStatusBar;
48class wxTextCtrl;
50class WX_INFOBAR;
51class KISTATUSBAR;
53
54
73
75{
76public:
79 { }
80
81 virtual ~REPORTER()
82 { }
83
95
103
104 virtual REPORTER& Report( const wxString& aText,
105 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED )
106 {
107 m_reportedSeverityMask |= aSeverity;
108 return *this;
109 }
110
114 virtual REPORTER& ReportTail( const wxString& aText,
115 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED )
116 {
117 return Report( aText, aSeverity );
118 }
119
123 virtual REPORTER& ReportHead( const wxString& aText,
124 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED )
125 {
126 return Report( aText, aSeverity );
127 }
128
129 REPORTER& Report( const char* aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED );
130
131 REPORTER& operator <<( const wxString& aText ) { return Report( aText ); }
132
136 virtual bool HasMessage() const
137 {
138 return m_reportedSeverityMask != 0;
139 }
140
145 virtual bool HasMessageOfSeverity( int aSeverityMask ) const
146 {
147 return ( m_reportedSeverityMask & aSeverityMask ) != 0;
148 }
149
150 virtual EDA_UNITS GetUnits() const
151 {
152 return EDA_UNITS::MM;
153 }
154
155 virtual void Clear()
156 {
158 }
159
160private:
162};
163
164
169{
170public:
171 WX_TEXT_CTRL_REPORTER( wxTextCtrl* aTextCtrl ) :
172 REPORTER(),
173 m_textCtrl( aTextCtrl )
174 {
175 }
176
178 {
179 }
180
181 REPORTER& Report( const wxString& aText,
182 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
183
184private:
185 wxTextCtrl* m_textCtrl;
186};
187
188
193{
194public:
196 REPORTER()
197 { }
198
200 { }
201
202 REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
203
204 const wxString& GetMessages() const;
205 void Clear() override;
206
207private:
208 wxString m_string;
209};
210
211
218{
219public:
221 { }
222
224 { }
225
226 static REPORTER& GetInstance();
227
228 REPORTER& Report( const wxString& aText,
229 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
230};
231
232
238{
239public:
241 m_verbose( false )
242 { }
243
245 { }
246
247 static CLI_REPORTER& GetInstance();
248
252 void SetVerbose( bool aVerbose ) { m_verbose = aVerbose; }
253
254 bool GetVerbose() const { return m_verbose; }
255
256 REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
257
258private:
260};
261
262
267{
268public:
271
273 { }
274
275 static REPORTER& GetInstance();
276
277 REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
278};
279
280
282{
283public:
285 { }
286
288 { }
289
290 static REPORTER& GetInstance();
291
292 REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
293};
294
295
297{
298public:
301
303 { }
304
305 static LOAD_INFO_REPORTER& GetInstance();
306
307 REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
308
309 void SetRedirectTarget( REPORTER* aReporter );
310 REPORTER* GetRedirectTarget() const;
311
312private:
314};
315
316
327
328
336{
337public:
338 explicit FONTCONFIG_REPORTER_SCOPE( REPORTER* aReporter );
340
341private:
343};
344
345
347{
348public:
349 REDIRECT_REPORTER( REPORTER* aRedirectTarget ) : m_redirectTarget( aRedirectTarget ) {}
350
351 REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
352
354};
355
356
361{
362public:
363 STATUSBAR_REPORTER( wxStatusBar* aStatusBar, int aPosition = 0 )
364 : REPORTER(),
365 m_statusBar( aStatusBar ),
366 m_position( aPosition )
367 { }
368
369 REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
370
371private:
372 wxStatusBar* m_statusBar;
374};
375
376
378{
379public:
380 STATUSBAR_WARNING_REPORTER( KISTATUSBAR* aStatusBar, const wxString& aSource );
382
383 REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
384
385private:
386 std::shared_ptr<STATUSBAR_WARNING_REPORTER_IMPL> m_impl;
387};
388
389#endif // _REPORTER_H_
Reporter forwarding messages to stdout or stderr as appropriate.
Definition reporter.h:238
void SetVerbose(bool aVerbose)
Enable or disable verbose mode.
Definition reporter.h:252
virtual ~CLI_REPORTER()
Definition reporter.h:244
bool m_verbose
Definition reporter.h:259
bool GetVerbose() const
Definition reporter.h:254
FONTCONFIG_REPORTER_SCOPE(REPORTER *aReporter)
Definition reporter.cpp:286
REPORTER * m_previousReporter
Definition reporter.h:342
LOAD_INFO_REPORTER_SCOPE(REPORTER *aReporter)
Definition reporter.cpp:272
LOAD_INFO_REPORTER & m_reporter
Definition reporter.h:324
REPORTER * m_previousReporter
Definition reporter.h:325
REPORTER * m_redirectTarget
Definition reporter.h:313
virtual ~LOAD_INFO_REPORTER()
Definition reporter.h:302
virtual ~NULL_REPORTER()
Definition reporter.h:223
REPORTER * m_redirectTarget
Definition reporter.h:353
REDIRECT_REPORTER(REPORTER *aRedirectTarget)
Definition reporter.h:349
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:75
virtual EDA_UNITS GetUnits() const
Definition reporter.h:150
int m_reportedSeverityMask
Definition reporter.h:161
LOCATION
Location where the message is to be reported.
Definition reporter.h:90
@ LOC_BODY
Definition reporter.h:92
@ LOC_TAIL
Definition reporter.h:93
@ LOC_HEAD
Definition reporter.h:91
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:123
virtual void Clear()
Definition reporter.h:155
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Report a string with a given severity.
Definition reporter.h:104
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:114
virtual bool HasMessageOfSeverity(int aSeverityMask) const
Returns true if the reporter has one or more messages matching the specified severity mask.
Definition reporter.h:145
virtual ~REPORTER()
Definition reporter.h:81
REPORTER()
Definition reporter.h:77
virtual bool HasMessage() const
Returns true if any messages were reported.
Definition reporter.h:136
STATUSBAR_REPORTER(wxStatusBar *aStatusBar, int aPosition=0)
Definition reporter.h:363
wxStatusBar * m_statusBar
Definition reporter.h:372
STATUSBAR_WARNING_REPORTER(KISTATUSBAR *aStatusBar, const wxString &aSource)
Definition reporter.cpp:321
~STATUSBAR_WARNING_REPORTER() override
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
Definition reporter.cpp:331
std::shared_ptr< STATUSBAR_WARNING_REPORTER_IMPL > m_impl
Definition reporter.h:386
virtual ~STDOUT_REPORTER()
Definition reporter.h:272
virtual ~WXLOG_REPORTER()
Definition reporter.h:287
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:77
wxString m_string
Definition reporter.h:208
virtual ~WX_STRING_REPORTER()
Definition reporter.h:199
virtual ~WX_TEXT_CTRL_REPORTER()
Definition reporter.h:177
wxTextCtrl * m_textCtrl
Definition reporter.h:185
WX_TEXT_CTRL_REPORTER(wxTextCtrl *aTextCtrl)
Definition reporter.h:171
std::ostream & operator<<(std::ostream &aStream, const EDA_TEXT &aText)
EDA_UNITS
Definition eda_units.h:48
#define KICOMMON_API
Definition kicommon.h:27
SEVERITY
@ RPT_SEVERITY_UNDEFINED