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, see <https://www.gnu.org/licenses/>.
19 */
20
21#ifndef _REPORTER_H_
22#define _REPORTER_H_
23
24#include <memory>
25#include <map>
26
27#include <eda_units.h>
29#include <kicommon.h>
30
41
42class wxString;
43class wxStatusBar;
44class wxTextCtrl;
46class WX_INFOBAR;
47class KISTATUSBAR;
49
50
69
71{
72public:
75 { }
76
77 virtual ~REPORTER()
78 { }
79
91
99
100 virtual REPORTER& Report( const wxString& aText,
101 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED )
102 {
103 m_reportedSeverityMask |= aSeverity;
104 return *this;
105 }
106
110 virtual REPORTER& ReportTail( const wxString& aText,
111 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED )
112 {
113 return Report( aText, aSeverity );
114 }
115
119 virtual REPORTER& ReportHead( const wxString& aText,
120 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED )
121 {
122 return Report( aText, aSeverity );
123 }
124
125 REPORTER& Report( const char* aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED );
126
127 REPORTER& operator <<( const wxString& aText ) { return Report( aText ); }
128
132 virtual bool HasMessage() const
133 {
134 return m_reportedSeverityMask != 0;
135 }
136
141 virtual bool HasMessageOfSeverity( int aSeverityMask ) const
142 {
143 return ( m_reportedSeverityMask & aSeverityMask ) != 0;
144 }
145
146 virtual EDA_UNITS GetUnits() const
147 {
148 return EDA_UNITS::MM;
149 }
150
151 virtual void Clear()
152 {
154 }
155
156private:
158};
159
160
165{
166public:
167 WX_TEXT_CTRL_REPORTER( wxTextCtrl* aTextCtrl ) :
168 REPORTER(),
169 m_textCtrl( aTextCtrl )
170 {
171 }
172
174 {
175 }
176
177 REPORTER& Report( const wxString& aText,
178 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
179
180private:
181 wxTextCtrl* m_textCtrl;
182};
183
184
189{
190public:
192 REPORTER()
193 { }
194
196 { }
197
198 REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
199
200 const wxString& GetMessages() const;
201 void Clear() override;
202
203private:
204 wxString m_string;
205};
206
207
214{
215public:
217 { }
218
220 { }
221
222 static REPORTER& GetInstance();
223
224 REPORTER& Report( const wxString& aText,
225 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
226};
227
228
234{
235public:
237 m_verbose( false )
238 { }
239
241 { }
242
243 static CLI_REPORTER& GetInstance();
244
248 void SetVerbose( bool aVerbose ) { m_verbose = aVerbose; }
249
250 bool GetVerbose() const { return m_verbose; }
251
252 REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
253
254private:
256};
257
258
263{
264public:
267
269 { }
270
271 static REPORTER& GetInstance();
272
273 REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
274};
275
276
278{
279public:
281 { }
282
284 { }
285
286 static REPORTER& GetInstance();
287
288 REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
289};
290
291
293{
294public:
297
299 { }
300
301 static LOAD_INFO_REPORTER& GetInstance();
302
303 REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
304
305 void SetRedirectTarget( REPORTER* aReporter );
306 REPORTER* GetRedirectTarget() const;
307
308private:
310};
311
312
323
324
332{
333public:
334 explicit FONTCONFIG_REPORTER_SCOPE( REPORTER* aReporter );
336
337private:
339};
340
341
343{
344public:
345 REDIRECT_REPORTER( REPORTER* aRedirectTarget ) : m_redirectTarget( aRedirectTarget ) {}
346
347 REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
348
350};
351
352
357{
358public:
359 STATUSBAR_REPORTER( wxStatusBar* aStatusBar, int aPosition = 0 )
360 : REPORTER(),
361 m_statusBar( aStatusBar ),
362 m_position( aPosition )
363 { }
364
365 REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
366
367private:
368 wxStatusBar* m_statusBar;
370};
371
372
374{
375public:
376 STATUSBAR_WARNING_REPORTER( KISTATUSBAR* aStatusBar, const wxString& aSource );
378
379 REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
380
381private:
382 std::shared_ptr<STATUSBAR_WARNING_REPORTER_IMPL> m_impl;
383};
384
385#endif // _REPORTER_H_
Reporter forwarding messages to stdout or stderr as appropriate.
Definition reporter.h:234
void SetVerbose(bool aVerbose)
Enable or disable verbose mode.
Definition reporter.h:248
virtual ~CLI_REPORTER()
Definition reporter.h:240
bool m_verbose
Definition reporter.h:255
bool GetVerbose() const
Definition reporter.h:250
FONTCONFIG_REPORTER_SCOPE(REPORTER *aReporter)
Definition reporter.cpp:284
REPORTER * m_previousReporter
Definition reporter.h:338
LOAD_INFO_REPORTER_SCOPE(REPORTER *aReporter)
Definition reporter.cpp:270
LOAD_INFO_REPORTER & m_reporter
Definition reporter.h:320
REPORTER * m_previousReporter
Definition reporter.h:321
REPORTER * m_redirectTarget
Definition reporter.h:309
virtual ~LOAD_INFO_REPORTER()
Definition reporter.h:298
virtual ~NULL_REPORTER()
Definition reporter.h:219
REPORTER * m_redirectTarget
Definition reporter.h:349
REDIRECT_REPORTER(REPORTER *aRedirectTarget)
Definition reporter.h:345
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:71
virtual EDA_UNITS GetUnits() const
Definition reporter.h:146
int m_reportedSeverityMask
Definition reporter.h:157
LOCATION
Location where the message is to be reported.
Definition reporter.h:86
@ LOC_BODY
Definition reporter.h:88
@ LOC_TAIL
Definition reporter.h:89
@ LOC_HEAD
Definition reporter.h:87
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:119
virtual void Clear()
Definition reporter.h:151
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Report a string with a given severity.
Definition reporter.h:100
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:110
virtual bool HasMessageOfSeverity(int aSeverityMask) const
Returns true if the reporter has one or more messages matching the specified severity mask.
Definition reporter.h:141
virtual ~REPORTER()
Definition reporter.h:77
REPORTER()
Definition reporter.h:73
virtual bool HasMessage() const
Returns true if any messages were reported.
Definition reporter.h:132
STATUSBAR_REPORTER(wxStatusBar *aStatusBar, int aPosition=0)
Definition reporter.h:359
wxStatusBar * m_statusBar
Definition reporter.h:368
STATUSBAR_WARNING_REPORTER(KISTATUSBAR *aStatusBar, const wxString &aSource)
Definition reporter.cpp:323
~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:333
std::shared_ptr< STATUSBAR_WARNING_REPORTER_IMPL > m_impl
Definition reporter.h:382
virtual ~STDOUT_REPORTER()
Definition reporter.h:268
virtual ~WXLOG_REPORTER()
Definition reporter.h:283
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:204
virtual ~WX_STRING_REPORTER()
Definition reporter.h:195
virtual ~WX_TEXT_CTRL_REPORTER()
Definition reporter.h:173
wxTextCtrl * m_textCtrl
Definition reporter.h:181
WX_TEXT_CTRL_REPORTER(wxTextCtrl *aTextCtrl)
Definition reporter.h:167
std::ostream & operator<<(std::ostream &aStream, const EDA_TEXT &aText)
EDA_UNITS
Definition eda_units.h:44
#define KICOMMON_API
Definition kicommon.h:27
SEVERITY
@ RPT_SEVERITY_UNDEFINED