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;
51
52
71
73{
74public:
77 { }
78
79 virtual ~REPORTER()
80 { }
81
93
101
102 virtual REPORTER& Report( const wxString& aText,
103 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED )
104 {
105 m_reportedSeverityMask |= aSeverity;
106 return *this;
107 }
108
112 virtual REPORTER& ReportTail( const wxString& aText,
113 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED )
114 {
115 return Report( aText, aSeverity );
116 }
117
121 virtual REPORTER& ReportHead( const wxString& aText,
122 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED )
123 {
124 return Report( aText, aSeverity );
125 }
126
127 REPORTER& Report( const char* aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED );
128
129 REPORTER& operator <<( const wxString& aText ) { return Report( aText ); }
130
134 virtual bool HasMessage() const
135 {
136 return m_reportedSeverityMask != 0;
137 }
138
143 virtual bool HasMessageOfSeverity( int aSeverityMask ) const
144 {
145 return ( m_reportedSeverityMask & aSeverityMask ) != 0;
146 }
147
148 virtual EDA_UNITS GetUnits() const
149 {
150 return EDA_UNITS::MM;
151 }
152
153 virtual void Clear()
154 {
156 }
157
158private:
160};
161
162
167{
168public:
169 WX_TEXT_CTRL_REPORTER( wxTextCtrl* aTextCtrl ) :
170 REPORTER(),
171 m_textCtrl( aTextCtrl )
172 {
173 }
174
176 {
177 }
178
179 REPORTER& Report( const wxString& aText,
180 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
181
182private:
183 wxTextCtrl* m_textCtrl;
184};
185
186
191{
192public:
194 REPORTER()
195 { }
196
198 { }
199
200 REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
201
202 const wxString& GetMessages() const;
203 void Clear() override;
204
205private:
206 wxString m_string;
207};
208
209
216{
217public:
219 { }
220
222 { }
223
224 static REPORTER& GetInstance();
225
226 REPORTER& Report( const wxString& aText,
227 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
228};
229
230
236{
237public:
239 m_verbose( false )
240 { }
241
243 { }
244
245 static CLI_REPORTER& GetInstance();
246
250 void SetVerbose( bool aVerbose ) { m_verbose = aVerbose; }
251
252 bool GetVerbose() const { return m_verbose; }
253
254 REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
255
256private:
258};
259
260
265{
266public:
269
271 { }
272
273 static REPORTER& GetInstance();
274
275 REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
276};
277
278
280{
281public:
283 { }
284
286 { }
287
288 static REPORTER& GetInstance();
289
290 REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
291};
292
293
295{
296public:
299
301 { }
302
303 static LOAD_INFO_REPORTER& GetInstance();
304
305 REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
306
307 void SetRedirectTarget( REPORTER* aReporter );
308 REPORTER* GetRedirectTarget() const;
309
310private:
312};
313
314
325
326
334{
335public:
336 explicit FONTCONFIG_REPORTER_SCOPE( REPORTER* aReporter );
338
339private:
341};
342
343
345{
346public:
347 REDIRECT_REPORTER( REPORTER* aRedirectTarget ) : m_redirectTarget( aRedirectTarget ) {}
348
349 REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
350
352};
353
354
359{
360public:
361 STATUSBAR_REPORTER( wxStatusBar* aStatusBar, int aPosition = 0 )
362 : REPORTER(),
363 m_statusBar( aStatusBar ),
364 m_position( aPosition )
365 { }
366
367 REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
368
369private:
370 wxStatusBar* m_statusBar;
372};
373
374#endif // _REPORTER_H_
Reporter forwarding messages to stdout or stderr as appropriate.
Definition reporter.h:236
void SetVerbose(bool aVerbose)
Enable or disable verbose mode.
Definition reporter.h:250
virtual ~CLI_REPORTER()
Definition reporter.h:242
bool m_verbose
Definition reporter.h:257
bool GetVerbose() const
Definition reporter.h:252
FONTCONFIG_REPORTER_SCOPE(REPORTER *aReporter)
Definition reporter.cpp:259
REPORTER * m_previousReporter
Definition reporter.h:340
LOAD_INFO_REPORTER_SCOPE(REPORTER *aReporter)
Definition reporter.cpp:245
LOAD_INFO_REPORTER & m_reporter
Definition reporter.h:322
REPORTER * m_previousReporter
Definition reporter.h:323
REPORTER * m_redirectTarget
Definition reporter.h:311
virtual ~LOAD_INFO_REPORTER()
Definition reporter.h:300
virtual ~NULL_REPORTER()
Definition reporter.h:221
REPORTER * m_redirectTarget
Definition reporter.h:351
REDIRECT_REPORTER(REPORTER *aRedirectTarget)
Definition reporter.h:347
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:73
virtual EDA_UNITS GetUnits() const
Definition reporter.h:148
int m_reportedSeverityMask
Definition reporter.h:159
LOCATION
Location where the message is to be reported.
Definition reporter.h:88
@ LOC_BODY
Definition reporter.h:90
@ LOC_TAIL
Definition reporter.h:91
@ LOC_HEAD
Definition reporter.h:89
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:121
virtual void Clear()
Definition reporter.h:153
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Report a string with a given severity.
Definition reporter.h:102
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:112
virtual bool HasMessageOfSeverity(int aSeverityMask) const
Returns true if the reporter has one or more messages matching the specified severity mask.
Definition reporter.h:143
virtual ~REPORTER()
Definition reporter.h:79
REPORTER()
Definition reporter.h:75
virtual bool HasMessage() const
Returns true if any messages were reported.
Definition reporter.h:134
STATUSBAR_REPORTER(wxStatusBar *aStatusBar, int aPosition=0)
Definition reporter.h:361
wxStatusBar * m_statusBar
Definition reporter.h:370
virtual ~STDOUT_REPORTER()
Definition reporter.h:270
virtual ~WXLOG_REPORTER()
Definition reporter.h:285
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
wxString m_string
Definition reporter.h:206
virtual ~WX_STRING_REPORTER()
Definition reporter.h:197
virtual ~WX_TEXT_CTRL_REPORTER()
Definition reporter.h:175
wxTextCtrl * m_textCtrl
Definition reporter.h:183
WX_TEXT_CTRL_REPORTER(wxTextCtrl *aTextCtrl)
Definition reporter.h:169
std::ostream & operator<<(std::ostream &aStream, const EDA_TEXT &aText)
EDA_UNITS
Definition eda_units.h:48
#define KICOMMON_API
Definition kicommon.h:28
SEVERITY
@ RPT_SEVERITY_UNDEFINED