KiCad PCB EDA Suite
KIFACE_I Class Referenceabstract

KIFACE_I is a KIFACE (I)mplementation, with some features useful for DSOs which implement a KIFACE. More...

#include <kiface_i.h>

Inheritance diagram for KIFACE_I:
KIFACE BMP2CMP::IFACE CV::IFACE GERBV::IFACE IFACE IFACE IFACE IFACE PCB::IFACE PCBCALC::IFACE PGE::IFACE SCH::IFACE

Public Member Functions

VTBL_ENTRY bool OnKifaceStart (PGM_BASE *aProgram, int aCtlBits) override=0
 Function OnKifaceStart is called just once shortly after the DSO is loaded. More...
 
VTBL_ENTRY void OnKifaceEnd () override
 Function OnKifaceEnd is called just once just before the DSO is to be unloaded. More...
 
VTBL_ENTRY wxWindow * CreateWindow (wxWindow *aParent, int aClassId, KIWAY *aKIWAY, int aCtlBits=0) override=0
 Function CreateWindow creates a wxWindow for the current project. More...
 
VTBL_ENTRY void * IfaceOrAddress (int aDataId) override=0
 Function IfaceOrAddress returns a pointer to the requested object. More...
 
 KIFACE_I (const char *aKifaceName, KIWAY::FACE_T aId)
 Constructor. More...
 
const wxString Name ()
 
APP_SETTINGS_BASEKifaceSettings () const
 
void InitSettings (APP_SETTINGS_BASE *aSettings)
 
int StartFlags () const
 Function StartFlags returns whatever was passed as aCtlBits to OnKifaceStart() More...
 
bool IsSingle () const
 Function IsSingle is this KIFACE_I running under single_top? More...
 
const wxString & GetHelpFileName () const
 Function GetHelpFileName returns just the basename portion of the current help file. More...
 
SEARCH_STACKKifaceSearch ()
 Only for DSO specific 'non-library' files. More...
 
VTBL_ENTRY void SaveFileAs (const wxString &srcProjectBasePath, const wxString &srcProjectName, const wxString &newProjectBasePath, const wxString &newProjectName, const wxString &srcFilePath, wxString &aErrors)
 Function SaveFileAs Saving a file under a different name is delegated to the various KIFACEs because the project doesn't know the internal format of the various files (which may have paths in them that need updating). More...
 

Protected Member Functions

bool start_common (int aCtlBits)
 Common things to do for a top program module, during OnKifaceStart(). More...
 
void end_common ()
 Common things to do for a top program module, during OnKifaceEnd();. More...
 

Private Attributes

KIWAY::FACE_T m_id
 
BIN_MOD m_bm
 
int m_start_flags
 flags provided in OnKifaceStart() More...
 

Detailed Description

KIFACE_I is a KIFACE (I)mplementation, with some features useful for DSOs which implement a KIFACE.

It is abstract, a few functions must be implemented in derivations.

Definition at line 37 of file kiface_i.h.

Constructor & Destructor Documentation

◆ KIFACE_I()

KIFACE_I::KIFACE_I ( const char *  aKifaceName,
KIWAY::FACE_T  aId 
)
inline

Constructor.

Parameters
aKifaceNameshould point to a C string in permanent storage, which contains the name of the DSO. Examples: "eeschema", "pcbnew", etc. This controls the name of the wxConfigBase established in m_bm, so it should be lowercase.
aIdis the type of DSO ( FACE_SCH, FACE_PCB, FACE_CVPCB, FACE_GERBVIEW, FACE_PL_EDITOR, FACE_PCB_CALCULATOR, FACE_BMP2CMP)

Definition at line 78 of file kiface_i.h.

78  :
79  m_id( aId ),
80  m_bm( aKifaceName ),
81  m_start_flags( 0 )
82  {
83  }
KIWAY::FACE_T m_id
Definition: kiface_i.h:130
BIN_MOD m_bm
Definition: kiface_i.h:132
int m_start_flags
flags provided in OnKifaceStart()
Definition: kiface_i.h:134

Member Function Documentation

◆ CreateWindow()

VTBL_ENTRY wxWindow* KIFACE_I::CreateWindow ( wxWindow *  aParent,
int  aClassId,
KIWAY aKIWAY,
int  aCtlBits = 0 
)
overridepure virtual

Function CreateWindow creates a wxWindow for the current project.

The caller must cast the return value into the known type.

Parameters
aParentmay be NULL, or is otherwise the parent to connect under. If NULL then caller may want to connect the returned wxWindow into some hierarchy after this function returns.
aClassIdidentifies which wxFrame or wxDialog to retrieve, using a value known to the implementing KIFACE.
aKIWAYtells the window which KIWAY (and PROJECT) it is a participant in.
aCtlBitsconsists of bit flags from the set of KFCTL_* #defines above.
Returns
wxWindow* - and if not NULL, should be cast into the known type using and old school cast. dynamic_cast is problematic since it needs typeinfo probably not contained in the caller's link image.

Implements KIFACE.

Implemented in PCB::IFACE, SCH::IFACE, GERBV::IFACE, IFACE, PCBCALC::IFACE, PGE::IFACE, CV::IFACE, IFACE, IFACE, IFACE, and BMP2CMP::IFACE.

◆ end_common()

void KIFACE_I::end_common ( )
protected

Common things to do for a top program module, during OnKifaceEnd();.

Definition at line 99 of file kiface_i.cpp.

100 {
101  m_bm.End();
102 }
BIN_MOD m_bm
Definition: kiface_i.h:132
void End()
Definition: bin_mod.cpp:53

References BIN_MOD::End(), and m_bm.

Referenced by CV::IFACE::OnKifaceEnd(), OnKifaceEnd(), PGE::IFACE::OnKifaceEnd(), PCBCALC::IFACE::OnKifaceEnd(), GERBV::IFACE::OnKifaceEnd(), SCH::IFACE::OnKifaceEnd(), and PCB::IFACE::OnKifaceEnd().

◆ GetHelpFileName()

const wxString& KIFACE_I::GetHelpFileName ( ) const
inline

Function GetHelpFileName returns just the basename portion of the current help file.

Definition at line 123 of file kiface_i.h.

123 { return m_bm.m_help_file; }
BIN_MOD m_bm
Definition: kiface_i.h:132
wxString m_help_file
Definition: bin_mod.h:65

References m_bm, and BIN_MOD::m_help_file.

Referenced by EDA_BASE_FRAME::help_name().

◆ IfaceOrAddress()

VTBL_ENTRY void* KIFACE_I::IfaceOrAddress ( int  aDataId)
overridepure virtual

Function IfaceOrAddress returns a pointer to the requested object.

The safest way to use this is to retrieve a pointer to a static instance of an interface, similar to how the KIFACE interface is exported. But if you know what you are doing use it to retrieve anything you want. Segfaults are your fault.

Parameters
aDataIdidentifies which object you want the address of, and consists of choices known in advance by the implementing KIFACE.
Returns
void* - and must be cast into the known type.

Implements KIFACE.

Implemented in PCB::IFACE, SCH::IFACE, GERBV::IFACE, PGE::IFACE, IFACE, CV::IFACE, PCBCALC::IFACE, IFACE, IFACE, BMP2CMP::IFACE, and IFACE.

◆ InitSettings()

void KIFACE_I::InitSettings ( APP_SETTINGS_BASE aSettings)
inline

Definition at line 105 of file kiface_i.h.

105 { m_bm.InitSettings( aSettings ); }
BIN_MOD m_bm
Definition: kiface_i.h:132
void InitSettings(APP_SETTINGS_BASE *aPtr)
Takes ownership of a new application settings object.
Definition: bin_mod.h:60

References BIN_MOD::InitSettings(), and m_bm.

Referenced by BMP2CMP::IFACE::CreateWindow(), CV::IFACE::OnKifaceStart(), PGE::IFACE::OnKifaceStart(), PCBCALC::IFACE::OnKifaceStart(), GERBV::IFACE::OnKifaceStart(), SCH::IFACE::OnKifaceStart(), and PCB::IFACE::OnKifaceStart().

◆ IsSingle()

◆ KifaceSearch()

SEARCH_STACK& KIFACE_I::KifaceSearch ( )
inline

Only for DSO specific 'non-library' files.

(The library search path is in the PROJECT class.)

Definition at line 127 of file kiface_i.h.

127 { return m_bm.m_search; }
BIN_MOD m_bm
Definition: kiface_i.h:132
SEARCH_STACK m_search
Definition: bin_mod.h:67

References m_bm, and BIN_MOD::m_search.

Referenced by CVPCB_MAINFRAME::buildEquivalenceList(), WS_DATA_MODEL::MakeFullFileName(), WS_DATA_MODEL::MakeShortFileName(), and EDA_BASE_FRAME::sys_search().

◆ KifaceSettings()

◆ Name()

const wxString KIFACE_I::Name ( )
inline

Definition at line 101 of file kiface_i.h.

101 { return wxString::FromUTF8( m_bm.m_name ); }
BIN_MOD m_bm
Definition: kiface_i.h:132
const char * m_name
name of this binary module, static C string.
Definition: bin_mod.h:62

References m_bm, and BIN_MOD::m_name.

◆ OnKifaceEnd()

VTBL_ENTRY void KIFACE_I::OnKifaceEnd ( )
inlineoverridevirtual

Function OnKifaceEnd is called just once just before the DSO is to be unloaded.

It is called before static C++ destructors are called. A default implementation is supplied.

Implements KIFACE.

Reimplemented in PCB::IFACE, IFACE, PCBCALC::IFACE, PGE::IFACE, IFACE, and IFACE.

Definition at line 53 of file kiface_i.h.

54  {
55  // overload this if you want, end_common() may be handy.
56  end_common();
57  }
void end_common()
Common things to do for a top program module, during OnKifaceEnd();.
Definition: kiface_i.cpp:99

References end_common().

◆ OnKifaceStart()

VTBL_ENTRY bool KIFACE_I::OnKifaceStart ( PGM_BASE aProgram,
int  aCtlBits 
)
overridepure virtual

Function OnKifaceStart is called just once shortly after the DSO is loaded.

It is the second function called, immediately after the KIFACE_GETTER(). However before either of those, static C++ constructors are called. The DSO implementation should do process level initialization here, not project specific since there will be multiple projects open eventually.

Parameters
aProgramis the process block: PGM_BASE*
aCtlBitsconsists of bit flags from the set of KFCTL_* #defines above.
Returns
bool - true if DSO initialized OK, false if not. When returning false, the loader may optionally decide to terminate the process or not, but will not put out any UI because that is the duty of this function to say why it is returning false. Never return false without having reported to the UI why.

Implements KIFACE.

Implemented in PCB::IFACE, SCH::IFACE, GERBV::IFACE, IFACE, PCBCALC::IFACE, PGE::IFACE, CV::IFACE, IFACE, IFACE, BMP2CMP::IFACE, and IFACE.

◆ SaveFileAs()

VTBL_ENTRY void KIFACE::SaveFileAs ( const wxString &  srcProjectBasePath,
const wxString &  srcProjectName,
const wxString &  newProjectBasePath,
const wxString &  newProjectName,
const wxString &  srcFilePath,
wxString &  aErrors 
)
inlineinherited

Function SaveFileAs Saving a file under a different name is delegated to the various KIFACEs because the project doesn't know the internal format of the various files (which may have paths in them that need updating).

Definition at line 219 of file kiway.h.

225  {
226  // If a KIFACE owns files then it needs to implement this....
227  }

Referenced by SAVE_AS_TRAVERSER::OnFile().

◆ start_common()

bool KIFACE_I::start_common ( int  aCtlBits)
protected

Common things to do for a top program module, during OnKifaceStart().

Definition at line 89 of file kiface_i.cpp.

90 {
91  m_start_flags = aCtlBits;
92  m_bm.Init();
94 
95  return true;
96 }
KIWAY::FACE_T m_id
Definition: kiface_i.h:130
void Init()
Definition: bin_mod.cpp:41
BIN_MOD m_bm
Definition: kiface_i.h:132
int m_start_flags
flags provided in OnKifaceStart()
Definition: kiface_i.h:134
SEARCH_STACK m_search
Definition: bin_mod.h:67
static void setSearchPaths(SEARCH_STACK *aDst, KIWAY::FACE_T aId)
Initialize aDst SEARCH_STACK with KIFACE (DSO) specific settings.
Definition: kiface_i.cpp:37

References BIN_MOD::Init(), m_bm, m_id, BIN_MOD::m_search, m_start_flags, and setSearchPaths().

Referenced by BMP2CMP::IFACE::OnKifaceStart(), IFACE::OnKifaceStart(), CV::IFACE::OnKifaceStart(), PGE::IFACE::OnKifaceStart(), PCBCALC::IFACE::OnKifaceStart(), GERBV::IFACE::OnKifaceStart(), SCH::IFACE::OnKifaceStart(), and PCB::IFACE::OnKifaceStart().

◆ StartFlags()

int KIFACE_I::StartFlags ( ) const
inline

Function StartFlags returns whatever was passed as aCtlBits to OnKifaceStart()

Definition at line 111 of file kiface_i.h.

111 { return m_start_flags; }
int m_start_flags
flags provided in OnKifaceStart()
Definition: kiface_i.h:134

References m_start_flags.

Member Data Documentation

◆ m_bm

BIN_MOD KIFACE_I::m_bm
private

◆ m_id

KIWAY::FACE_T KIFACE_I::m_id
private

Definition at line 130 of file kiface_i.h.

Referenced by start_common().

◆ m_start_flags

int KIFACE_I::m_start_flags
private

flags provided in OnKifaceStart()

Definition at line 134 of file kiface_i.h.

Referenced by IsSingle(), start_common(), and StartFlags().


The documentation for this class was generated from the following files: