KiCad PCB EDA Suite
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
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 <stambaughw@gmail.com>
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:
81 enum LOCATION {
82 LOC_HEAD = 0,
84 LOC_TAIL
85 };
86
95 virtual REPORTER& Report( const wxString& aText,
96 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) = 0;
97
101 virtual REPORTER& ReportTail( const wxString& aText,
102 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED )
103 {
104 return Report( aText, aSeverity );
105 }
106
110 virtual REPORTER& ReportHead( const wxString& aText,
111 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED )
112 {
113 return Report( aText, aSeverity );
114 }
115
116 REPORTER& Report( const char* aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED );
117
118 REPORTER& operator <<( const wxString& aText ) { return Report( aText ); }
119
123 virtual bool HasMessage() const = 0;
124
129 virtual bool HasMessageOfSeverity( int aSeverityMask ) const;
130
131 virtual EDA_UNITS GetUnits() const
132 {
133 return EDA_UNITS::MM;
134 }
135
136 virtual ~REPORTER()
137 {
138 }
139};
140
141
146{
147public:
148 WX_TEXT_CTRL_REPORTER( wxTextCtrl* aTextCtrl ) :
149 REPORTER(),
150 m_textCtrl( aTextCtrl )
151 {
152 }
153
155 {
156 }
157
158 REPORTER& Report( const wxString& aText,
159 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
160
161 bool HasMessage() const override;
162
163private:
164 wxTextCtrl* m_textCtrl;
165};
166
167
172{
173public:
175 REPORTER(),
176 m_severityMask( 0 )
177 {
178 }
179
181 {
182 }
183
184 REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
185
186 bool HasMessage() const override;
187 bool HasMessageOfSeverity( int aSeverityMask ) const override;
188
189 const wxString& GetMessages() const;
190 void Clear();
191
192private:
193 wxString m_string;
195};
196
197
204{
205public:
207 {
208 }
209
211 {
212 }
213
214 static REPORTER& GetInstance();
215
216 REPORTER& Report( const wxString& aText,
217 SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
218
219 bool HasMessage() const override { return false; }
220};
221
222
227{
228public:
230 {
231 }
232
234 {
235 }
236
237 static REPORTER& GetInstance();
238
239 REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
240
241 bool HasMessage() const override { return false; }
242 bool HasMessageOfSeverity( int aSeverityMask ) const override;
243
244private:
245 std::map<SEVERITY, bool> m_hasMessageMap;
246};
247
248
253{
254public:
256 {
257 }
258
260 {
261 }
262
263 static REPORTER& GetInstance();
264
265 REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
266
267 bool HasMessage() const override { return false; }
268};
269
270
272{
273public:
275 {
276 }
277
279 {
280 }
281
282 static REPORTER& GetInstance();
283
284 REPORTER& Report( const wxString& aMsg, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
285
286 bool HasMessage() const override { return false; }
287};
288
289
294{
295public:
296 STATUSBAR_REPORTER( wxStatusBar* aStatusBar, int aPosition = 0 )
297 : REPORTER(),
298 m_statusBar( aStatusBar ),
299 m_position( aPosition )
300 {
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:227
bool HasMessage() const override
Returns true if the reporter client is non-empty.
Definition: reporter.h:241
std::map< SEVERITY, bool > m_hasMessageMap
Definition: reporter.h:245
virtual ~CLI_REPORTER()
Definition: reporter.h:233
A singleton reporter that reports to nowhere.
Definition: reporter.h:204
virtual ~NULL_REPORTER()
Definition: reporter.h:210
bool HasMessage() const override
Returns true if the reporter client is non-empty.
Definition: reporter.h:219
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:73
virtual EDA_UNITS GetUnits() const
Definition: reporter.h:131
LOCATION
Location where the message is to be reported.
Definition: reporter.h:81
@ LOC_BODY
Definition: reporter.h:83
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:110
virtual bool HasMessage() const =0
Returns true if the reporter client is non-empty.
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:101
virtual ~REPORTER()
Definition: reporter.h:136
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
A wrapper for reporting to a specific text location in a statusbar.
Definition: reporter.h:294
STATUSBAR_REPORTER(wxStatusBar *aStatusBar, int aPosition=0)
Definition: reporter.h:296
wxStatusBar * m_statusBar
Definition: reporter.h:308
Debug type reporter, forwarding messages to std::cout.
Definition: reporter.h:253
virtual ~STDOUT_REPORTER()
Definition: reporter.h:259
bool HasMessage() const override
Returns true if the reporter client is non-empty.
Definition: reporter.h:267
bool HasMessage() const override
Returns true if the reporter client is non-empty.
Definition: reporter.h:286
virtual ~WXLOG_REPORTER()
Definition: reporter.h:278
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:172
wxString m_string
Definition: reporter.h:193
virtual ~WX_STRING_REPORTER()
Definition: reporter.h:180
A wrapper for reporting to a wxTextCtrl object.
Definition: reporter.h:146
virtual ~WX_TEXT_CTRL_REPORTER()
Definition: reporter.h:154
wxTextCtrl * m_textCtrl
Definition: reporter.h:164
WX_TEXT_CTRL_REPORTER(wxTextCtrl *aTextCtrl)
Definition: reporter.h:148
EDA_UNITS
Definition: eda_units.h:46
#define KICOMMON_API
Definition: kicommon.h:28
SEVERITY
@ RPT_SEVERITY_UNDEFINED