KiCad PCB EDA Suite
kiface_i.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) 1992-2014 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 #ifndef KIFACE_I_H_
25 #define KIFACE_I_H_
26 
27 #include <kiway.h>
28 #include <bin_mod.h>
29 
30 
37 class KIFACE_I : public KIFACE
38 {
39 public:
40 
41  //-----<KIFACE API>----------------------------------------------------------
42 
43  // see base class KIFACE in kiway.h for doxygen docs
44 
45  VTBL_ENTRY bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) override = 0;
46  /*
47  {
48  typically call start_common() in your overload
49  return start_common();
50  }
51  */
52 
53  VTBL_ENTRY void OnKifaceEnd() override
54  {
55  // overload this if you want, end_common() may be handy.
56  end_common();
57  }
58 
59  VTBL_ENTRY wxWindow* CreateWindow( wxWindow* aParent,
60  int aClassId, KIWAY* aKIWAY, int aCtlBits = 0 ) override = 0;
61 
62  VTBL_ENTRY void* IfaceOrAddress( int aDataId ) override = 0;
63 
64  //-----</KIFACE API>---------------------------------------------------------
65 
66  // The remainder are DSO specific helpers, not part of the KIFACE API
67 
76  KIFACE_I( const char* aKifaceName, KIWAY::FACE_T aId ) :
77  m_id( aId ),
78  m_bm( aKifaceName ),
79  m_start_flags( 0 )
80  {
81  }
82 
83  // ~KIFACE_I();
84 
85 protected:
86 
88  bool start_common( int aCtlBits );
89 
91  void end_common();
92 
93  // From here down should probably not be in a KIFACE, even though they
94  // are DSO specific, they have nothing to do with KIWAY's use of KIFACE,
95  // so its a questionable choice to put non KIWAY client code in this class.
96 
97 public:
98 
99  const wxString Name() { return wxString::FromUTF8( m_bm.m_name ); }
100 
101  wxConfigBase* KifaceSettings() const { return m_bm.m_config; }
102 
107  int StartFlags() const { return m_start_flags; }
108 
113  bool IsSingle() const { return m_start_flags & KFCTL_STANDALONE; }
114 
119  const wxString& GetHelpFileName() const { return m_bm.m_help_file; }
120 
121  wxFileHistory& GetFileHistory() { return m_bm.m_history; }
122 
126 
127 private:
129 
131 
133 };
134 
135 
137 KIFACE_I& Kiface();
138 
139 #endif // KIFACE_I_H_
VTBL_ENTRY wxWindow * CreateWindow(wxWindow *aParent, int aClassId, KIWAY *aKIWAY, int aCtlBits=0) override=0
Function CreateWindow creates a wxWindow for the current project.
Class KIFACE_I is a KIFACE (I)mplementation, with some features useful for DSOs which implement a KIF...
Definition: kiface_i.h:37
KIWAY::FACE_T m_id
Definition: kiface_i.h:128
bool start_common(int aCtlBits)
Common things to do for a top program module, during OnKifaceStart().
Definition: kiface_i.cpp:94
Struct BIN_MOD pertains to a single program module, either an EXE or a DSO/DLL ("bin_mod").
Definition: bin_mod.h:47
Class PGM_BASE keeps program (whole process) data for KiCad programs.
Definition: pgm_base.h:107
VTBL_ENTRY bool OnKifaceStart(PGM_BASE *aProgram, int aCtlBits) override=0
Function OnKifaceStart is called just once shortly after the DSO is loaded.
VTBL_ENTRY void * IfaceOrAddress(int aDataId) override=0
Function IfaceOrAddress returns a pointer to the requested object.
Class SEARCH_STACK looks for files in a number of places.
Definition: search_stack.h:41
BIN_MOD m_bm
Definition: kiface_i.h:130
const wxString Name()
Definition: kiface_i.h:99
KIFACE_I(const char *aKifaceName, KIWAY::FACE_T aId)
Constructor.
Definition: kiface_i.h:76
#define VTBL_ENTRY
Definition: kiway.h:109
VTBL_ENTRY void OnKifaceEnd() override
Function OnKifaceEnd is called just once just before the DSO is to be unloaded.
Definition: kiface_i.h:53
SEARCH_STACK & KifaceSearch()
Only for DSO specific 'non-library' files.
Definition: kiface_i.h:125
void end_common()
Common things to do for a top program module, during OnKifaceEnd();.
Definition: kiface_i.cpp:104
wxFileHistory & GetFileHistory()
Definition: kiface_i.h:121
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:257
wxConfigBase * KifaceSettings() const
Definition: kiface_i.h:101
int m_start_flags
flags provided in OnKifaceStart()
Definition: kiface_i.h:132
SEARCH_STACK m_search
Definition: bin_mod.h:61
FACE_T
Known KIFACE implementations.
Definition: kiway.h:263
bool IsSingle() const
Function IsSingle is this KIFACE_I running under single_top?
Definition: kiface_i.h:113
const wxString & GetHelpFileName() const
Function GetHelpFileName returns just the basename portion of the current help file.
Definition: kiface_i.h:119
wxString m_help_file
Definition: bin_mod.h:59
wxFileHistory m_history
Definition: bin_mod.h:58
Class KIFACE is used by a participant in the KIWAY alchemy.
Definition: kiway.h:150
wxConfigBase * m_config
maybe from $HOME/.${m_name}
Definition: bin_mod.h:57
int PGM_BASE * aProgram
Definition: pcbnew.cpp:205
const char * m_name
name of this binary module, static C string.
Definition: bin_mod.h:55
#define KFCTL_STANDALONE
Am running as a standalone Top.
Definition: kiway.h:158
int StartFlags() const
Function StartFlags returns whatever was passed as aCtlBits to OnKifaceStart()
Definition: kiface_i.h:107