KiCad PCB EDA Suite
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@verizon.net>
5  * Copyright (C) 1992-2013 KiCad Developers, see change_log.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 <wx/string.h>
29 
37 class wxTextCtrl;
38 class wxHtmlListbox;
40 
41 
61 class REPORTER {
62 
63 public:
65  enum SEVERITY {
67  RPT_INFO = 0x1,
68  RPT_WARNING = 0x2,
69  RPT_ERROR = 0x4,
70  RPT_ACTION = 0x8
71  };
72 
82  virtual REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) = 0;
83 
84  REPORTER& Report( const char* aText, SEVERITY aSeverity = RPT_UNDEFINED );
85 
86  REPORTER& operator <<( const wxString& aText ) { return Report( aText ); }
87  REPORTER& operator <<( const wxChar* aText ) { return Report( wxString( aText ) ); }
88  REPORTER& operator <<( wxChar aChar ) { return Report( wxString( aChar ) ); }
89  REPORTER& operator <<( const char* aText ) { return Report( aText ); }
90 
95  virtual bool HasMessage() const = 0;
96 };
97 
98 
104 {
105  wxTextCtrl* m_textCtrl;
106 
107 public:
108  WX_TEXT_CTRL_REPORTER( wxTextCtrl* aTextCtrl ) :
109  REPORTER(),
110  m_textCtrl( aTextCtrl )
111  {
112  }
113 
114  REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) override;
115 
116  bool HasMessage() const override;
117 };
118 
119 
125 {
126  wxString* m_string;
127 
128 public:
129  WX_STRING_REPORTER( wxString* aString ) :
130  REPORTER(),
131  m_string( aString )
132  {
133  }
134 
135  REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) override;
136 
137  bool HasMessage() const override;
138 };
139 
140 
146 {
148 
149 public:
151  REPORTER(),
152  m_panel( aPanel )
153  {
154  }
155 
156  REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) override;
157 
158  bool HasMessage() const override;
159 };
160 
167 class NULL_REPORTER : public REPORTER
168 {
169 public:
171  {
172  }
173 
174  static REPORTER& GetInstance();
175 
176  REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) override;
177 
178  bool HasMessage() const override { return false; }
179 };
180 
181 #endif // _REPORTER_H_
wxTextCtrl * m_textCtrl
Definition: reporter.h:105
virtual bool HasMessage() const =0
Function HasMessage Returns true if the reporter client is non-empty.
WX_HTML_PANEL_REPORTER(WX_HTML_REPORT_PANEL *aPanel)
Definition: reporter.h:150
WX_TEXT_CTRL_REPORTER(wxTextCtrl *aTextCtrl)
Definition: reporter.h:108
WX_HTML_REPORT_PANEL * m_panel
Definition: reporter.h:147
Class REPORTER is a pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:61
Class WX_TEXT_CTRL_REPORTER is wrapper for reporting to a wxTextCtrl object.
Definition: reporter.h:103
Class NULL_REPORTER.
Definition: reporter.h:167
SEVERITY
Severity of the reported messages.
Definition: reporter.h:65
Class WX_STRING_REPORTER is a wrapper for reporting to a wxString object.
Definition: reporter.h:124
Class WX_HTML_PANEL_REPORTER is a wrapper for reporting to a wx HTML window.
Definition: reporter.h:145
REPORTER & operator<<(const wxString &aText)
Definition: reporter.h:86
WX_STRING_REPORTER(wxString *aString)
Definition: reporter.h:129
bool HasMessage() const override
Function HasMessage Returns true if the reporter client is non-empty.
Definition: reporter.h:178
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_UNDEFINED)=0
Function Report is a pure virtual function to override in the derived object.
wxString * m_string
Definition: reporter.h:126
Class WX_HTML_REPORT_PANEL.