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-2020 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:
43  virtual bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) override = 0;
44 
45  virtual void OnKifaceEnd() override
46  {
47  // overload this if you want, end_common() may be handy.
48  end_common();
49  }
50 
51  virtual wxWindow* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKIWAY,
52  int aCtlBits = 0 ) override = 0;
53 
54  virtual void* IfaceOrAddress( int aDataId ) override = 0;
55 
64  KIFACE_I( const char* aKifaceName, KIWAY::FACE_T aId ) :
65  m_id( aId ),
66  m_bm( aKifaceName ),
67  m_start_flags( 0 )
68  {
69  }
70 
71  // ~KIFACE_I();
72 
73 protected:
74 
76  bool start_common( int aCtlBits );
77 
79  void end_common();
80 
81  // From here down should probably not be in a KIFACE, even though they
82  // are DSO specific, they have nothing to do with KIWAY's use of KIFACE,
83  // so its a questionable choice to put non KIWAY client code in this class.
84 
85 public:
86 
87  const wxString Name()
88  {
89  return wxString::FromUTF8( m_bm.m_name );
90  }
91 
93 
94  void InitSettings( APP_SETTINGS_BASE* aSettings ) { m_bm.InitSettings( aSettings ); }
95 
99  int StartFlags() const { return m_start_flags; }
100 
104  bool IsSingle() const { return m_start_flags & KFCTL_STANDALONE; }
105 
109  const wxString& GetHelpFileName() const { return m_bm.m_help_file; }
110 
114 
115 private:
117 
119 
121 };
122 
123 
125 KIFACE_I& Kiface();
126 
127 #endif // KIFACE_I_H_
virtual bool OnKifaceStart(PGM_BASE *aProgram, int aCtlBits) override=0
Typically start_common() is called from here.
virtual void * IfaceOrAddress(int aDataId) override=0
Return pointer to the requested object.
A KIFACE (I)mplementation.
Definition: kiface_i.h:37
KIWAY::FACE_T m_id
Definition: kiface_i.h:116
bool start_common(int aCtlBits)
Common things to do for a top program module, during OnKifaceStart().
Definition: kiface_i.cpp:88
int StartFlags() const
Return whatever was passed as aCtlBits to OnKifaceStart().
Definition: kiface_i.h:99
Pertains to a single program module, either an EXE or a DSO/DLL ("bin_mod").
Definition: bin_mod.h:48
virtual wxWindow * CreateWindow(wxWindow *aParent, int aClassId, KIWAY *aKIWAY, int aCtlBits=0) override=0
Create a wxWindow for the current project.
Container for data for KiCad programs.
Definition: pgm_base.h:131
APP_SETTINGS_BASE * KifaceSettings() const
Definition: kiface_i.h:92
Look for files in a number of paths.
Definition: search_stack.h:41
BIN_MOD m_bm
Definition: kiface_i.h:118
const wxString Name()
Definition: kiface_i.h:87
APP_SETTINGS_BASE * m_config
maybe from $HOME/.${m_name}
Definition: bin_mod.h:65
KIFACE_I(const char *aKifaceName, KIWAY::FACE_T aId)
Definition: kiface_i.h:64
SEARCH_STACK & KifaceSearch()
Only for DSO specific 'non-library' files.
Definition: kiface_i.h:113
const wxString & GetHelpFileName() const
Return just the basename portion of the current help file.
Definition: kiface_i.h:109
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:99
bool IsSingle() const
Is this KIFACE_I running under single_top?
Definition: kiface_i.h:104
void end_common()
Common things to do for a top program module, during OnKifaceEnd();.
Definition: kiface_i.cpp:98
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:260
void InitSettings(APP_SETTINGS_BASE *aPtr)
Takes ownership of a new application settings object.
Definition: bin_mod.h:61
int m_start_flags
flags provided in OnKifaceStart()
Definition: kiface_i.h:120
SEARCH_STACK m_search
Definition: bin_mod.h:68
FACE_T
Known KIFACE implementations.
Definition: kiway.h:266
wxString m_help_file
Definition: bin_mod.h:66
Implement a participant in the KIWAY alchemy.
Definition: kiway.h:147
void InitSettings(APP_SETTINGS_BASE *aSettings)
Definition: kiface_i.h:94
virtual void OnKifaceEnd() override
Called just once just before the DSO is to be unloaded.
Definition: kiface_i.h:45
int PGM_BASE * aProgram
Definition: cvpcb.cpp:97
const char * m_name
name of this binary module, static C string.
Definition: bin_mod.h:63
#define KFCTL_STANDALONE
Running as a standalone Top.
Definition: kiway.h:155