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
46class wxString;
47class wxStatusBar;
48class wxTextCtrl;
50class WX_INFOBAR;
51
52
73{
74public:
76 m_severityMask( 0 )
77 { }
78
79 virtual ~REPORTER()
80 { }
81
88 enum LOCATION {
89 LOC_HEAD = 0,
91 LOC_TAIL
92 };
93
102 virtual REPORTER& Report( const wxString& aText,
103 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED )
104 {
105 m_severityMask |= 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 = 0;
135
140 virtual bool HasMessageOfSeverity( int aSeverityMask ) const
141 {
142 return ( m_severityMask & aSeverityMask ) != 0;
143 }
144
145 virtual EDA_UNITS GetUnits() const
146 {
147 return EDA_UNITS::MM;
148 }
149
150 virtual void Clear()
151 {
152 m_severityMask = 0;
153 }
154
155private:
157};
158
159
164{
165public:
166 WX_TEXT_CTRL_REPORTER( wxTextCtrl* aTextCtrl ) :
167 REPORTER(),
168 m_textCtrl( aTextCtrl )
169 {
170 }
171
173 {
174 }
175
176 REPORTER& Report( const wxString& aText,
177 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
178
179 bool HasMessage() const override;
180
181private:
182 wxTextCtrl* m_textCtrl;
183};
184
185
190{
191public:
193 REPORTER()
194 { }
195
197 { }
198
199 REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
200
201 bool HasMessage() const override;
202
203 const wxString& GetMessages() const;
204 void Clear() override;
205
206private:
207 wxString m_string;
208};
209
210
217{
218public:
220 { }
221
223 { }
224
225 static REPORTER& GetInstance();
226
227 REPORTER& Report( const wxString& aText,
228 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
229
230 bool HasMessage() const override { return false; }
231};
232
233
238{
239public:
241 { }
242
244 { }
245
246 static REPORTER& GetInstance();
247
248 REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
249
250 bool HasMessage() const override { return false; }
251};
252
253
258{
259public:
261 { }
262
264 { }
265
266 static REPORTER& GetInstance();
267
268 REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
269
270 bool HasMessage() const override { return false; }
271};
272
273
275{
276public:
278 { }
279
281 { }
282
283 static REPORTER& GetInstance();
284
285 REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
286
287 bool HasMessage() const override { return false; }
288};
289
290
295{
296public:
297 STATUSBAR_REPORTER( wxStatusBar* aStatusBar, int aPosition = 0 )
298 : REPORTER(),
299 m_statusBar( aStatusBar ),
300 m_position( aPosition )
301 { }
302
303 REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
304
305 bool HasMessage() const override;
306
307private:
308 wxStatusBar* m_statusBar;
310};
311
312#endif // _REPORTER_H_
Reporter forwarding messages to stdout or stderr as appropriate.
Definition: reporter.h:238
bool HasMessage() const override
Returns true if the reporter client is non-empty.
Definition: reporter.h:250
virtual ~CLI_REPORTER()
Definition: reporter.h:243
A singleton reporter that reports to nowhere.
Definition: reporter.h:217
virtual ~NULL_REPORTER()
Definition: reporter.h:222
bool HasMessage() const override
Returns true if the reporter client is non-empty.
Definition: reporter.h:230
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:73
virtual EDA_UNITS GetUnits() const
Definition: reporter.h:145
LOCATION
Location where the message is to be reported.
Definition: reporter.h:88
@ LOC_BODY
Definition: reporter.h:90
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
int m_severityMask
Definition: reporter.h:156
virtual void Clear()
Definition: reporter.h:150
virtual bool HasMessage() const =0
Returns true if the reporter client is non-empty.
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:140
virtual ~REPORTER()
Definition: reporter.h:79
REPORTER()
Definition: reporter.h:75
A wrapper for reporting to a specific text location in a statusbar.
Definition: reporter.h:295
STATUSBAR_REPORTER(wxStatusBar *aStatusBar, int aPosition=0)
Definition: reporter.h:297
wxStatusBar * m_statusBar
Definition: reporter.h:308
Debug type reporter, forwarding messages to std::cout.
Definition: reporter.h:258
virtual ~STDOUT_REPORTER()
Definition: reporter.h:263
bool HasMessage() const override
Returns true if the reporter client is non-empty.
Definition: reporter.h:270
bool HasMessage() const override
Returns true if the reporter client is non-empty.
Definition: reporter.h:287
virtual ~WXLOG_REPORTER()
Definition: reporter.h:280
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:190
wxString m_string
Definition: reporter.h:207
virtual ~WX_STRING_REPORTER()
Definition: reporter.h:196
A wrapper for reporting to a wxTextCtrl object.
Definition: reporter.h:164
virtual ~WX_TEXT_CTRL_REPORTER()
Definition: reporter.h:172
wxTextCtrl * m_textCtrl
Definition: reporter.h:182
WX_TEXT_CTRL_REPORTER(wxTextCtrl *aTextCtrl)
Definition: reporter.h:166
EDA_UNITS
Definition: eda_units.h:48
#define KICOMMON_API
Definition: kicommon.h:28
SEVERITY
@ RPT_SEVERITY_UNDEFINED