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 };
91 
92 
98 {
99  wxTextCtrl* m_textCtrl;
100 
101 public:
102  WX_TEXT_CTRL_REPORTER( wxTextCtrl* aTextCtrl ) :
103  REPORTER(),
104  m_textCtrl( aTextCtrl )
105  {
106  }
107 
108  REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) override;
109 };
110 
111 
117 {
118  wxString* m_string;
119 
120 public:
121  WX_STRING_REPORTER( wxString* aString ) :
122  REPORTER(),
123  m_string( aString )
124  {
125  }
126 
127  REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) override;
128 };
129 
130 
136 {
138 
139 public:
141  REPORTER(),
142  m_panel( aPanel )
143  {
144  }
145 
146  REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) override;
147 };
148 
155 class NULL_REPORTER : public REPORTER
156 {
157  public:
159  {
160  };
161 
162  static REPORTER& GetInstance();
163 
164  REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) override;
165 };
166 
167 #endif // _REPORTER_H_
wxTextCtrl * m_textCtrl
Definition: reporter.h:99
WX_HTML_PANEL_REPORTER(WX_HTML_REPORT_PANEL *aPanel)
Definition: reporter.h:140
WX_TEXT_CTRL_REPORTER(wxTextCtrl *aTextCtrl)
Definition: reporter.h:102
WX_HTML_REPORT_PANEL * m_panel
Definition: reporter.h:137
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:97
Class NULL_REPORTER.
Definition: reporter.h:155
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:116
Class WX_HTML_PANEL_REPORTER is a wrapper for reporting to a wx HTML window.
Definition: reporter.h:135
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:86
WX_STRING_REPORTER(wxString *aString)
Definition: reporter.h:121
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:118
static REPORTER & GetInstance()
Definition: reporter.cpp:71
Class WX_HTML_REPORT_PANEL.