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
235{
236public:
238 { }
239
241 { }
242
243 static REPORTER& GetInstance();
244
245 REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
246};
247
248
253{
254public:
257
259 { }
260
261 static REPORTER& GetInstance();
262
263 REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
264};
265
266
268{
269public:
271 { }
272
274 { }
275
276 static REPORTER& GetInstance();
277
278 REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
279};
280
281
283{
284public:
285 REDIRECT_REPORTER( REPORTER* aRedirectTarget ) : m_redirectTarget( aRedirectTarget ) {}
286
287 REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
288
290};
291
292
297{
298public:
299 STATUSBAR_REPORTER( wxStatusBar* aStatusBar, int aPosition = 0 )
300 : REPORTER(),
301 m_statusBar( aStatusBar ),
302 m_position( aPosition )
303 { }
304
305 REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
306
307private:
308 wxStatusBar* m_statusBar;
310};
311
312#endif // _REPORTER_H_
virtual ~CLI_REPORTER()
Definition reporter.h:240
virtual ~NULL_REPORTER()
Definition reporter.h:221
REPORTER * m_redirectTarget
Definition reporter.h:289
REDIRECT_REPORTER(REPORTER *aRedirectTarget)
Definition reporter.h:285
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:299
wxStatusBar * m_statusBar
Definition reporter.h:308
virtual ~STDOUT_REPORTER()
Definition reporter.h:258
virtual ~WXLOG_REPORTER()
Definition reporter.h:273
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