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 
80  virtual REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) = 0;
81 
82  REPORTER& Report( const char* aText, SEVERITY aSeverity = RPT_UNDEFINED );
83 
84  REPORTER& operator <<( const wxString& aText ) { return Report( aText ); }
85  REPORTER& operator <<( const wxChar* aText ) { return Report( wxString( aText ) ); }
86  REPORTER& operator <<( wxChar aChar ) { return Report( wxString( aChar ) ); }
87  REPORTER& operator <<( const char* aText ) { return Report( aText ); }
88 };
89 
90 
96 {
97  wxTextCtrl* m_textCtrl;
98 
99 public:
100  WX_TEXT_CTRL_REPORTER( wxTextCtrl* aTextCtrl ) :
101  REPORTER(),
102  m_textCtrl( aTextCtrl )
103  {
104  }
105 
106  REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) override;
107 };
108 
109 
115 {
116  wxString* m_string;
117 
118 public:
119  WX_STRING_REPORTER( wxString* aString ) :
120  REPORTER(),
121  m_string( aString )
122  {
123  }
124 
125  REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) override;
126 };
127 
128 
134 {
136 
137 public:
139  REPORTER(),
140  m_panel( aPanel )
141  {
142  }
143 
144  REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) override;
145 };
146 
153 class NULL_REPORTER : public REPORTER
154 {
155  public:
157  {
158  };
159 
160  static REPORTER& GetInstance();
161 
162  REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) override;
163 };
164 
165 #endif // _REPORTER_H_
wxTextCtrl * m_textCtrl
Definition: reporter.h:97
WX_HTML_PANEL_REPORTER(WX_HTML_REPORT_PANEL *aPanel)
Definition: reporter.h:138
WX_TEXT_CTRL_REPORTER(wxTextCtrl *aTextCtrl)
Definition: reporter.h:100
WX_HTML_REPORT_PANEL * m_panel
Definition: reporter.h:135
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:95
Class NULL_REPORTER.
Definition: reporter.h:153
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_UNDEFINED) override
Function Report is a pure virtual function to override in the derived object.
Definition: reporter.cpp:66
SEVERITY
Severity of the reported messages.
Definition: reporter.h:65
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_UNDEFINED) override
Function Report is a pure virtual function to override in the derived object.
Definition: reporter.cpp:48
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_UNDEFINED) override
Function Report is a pure virtual function to override in the derived object.
Definition: reporter.cpp:57
Class WX_STRING_REPORTER is a wrapper for reporting to a wxString object.
Definition: reporter.h:114
Class WX_HTML_PANEL_REPORTER is a wrapper for reporting to a wx HTML window.
Definition: reporter.h:133
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_UNDEFINED) override
Function Report is a pure virtual function to override in the derived object.
Definition: reporter.cpp:39
REPORTER & operator<<(const wxString &aText)
Definition: reporter.h:84
WX_STRING_REPORTER(wxString *aString)
Definition: reporter.h:119
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:116
static REPORTER & GetInstance()
Definition: reporter.cpp:71
Class WX_HTML_REPORT_PANEL.