KiCad PCB EDA Suite
common_mocks.cpp
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) 2018 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 
29 #include <pgm_base.h>
30 #include <kiface_i.h>
31 
32 
33 struct PGM_TEST_FRAME : public PGM_BASE
34 {
35  void MacOpenFile( const wxString& aFileName ) override
36  {}
37 };
38 
40 {
41  static PGM_TEST_FRAME program;
42  return program;
43 }
44 
45 static struct IFACE : public KIFACE_I
46 {
47  bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) override
48  {
49  return start_common( aCtlBits );
50  }
51 
52  wxWindow* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 ) override
53  {
54  return nullptr;
55  }
56 
57  void* IfaceOrAddress( int aDataId ) override
58  {
59  return nullptr;
60  }
61 
62  IFACE( const char* aDSOname, KIWAY::FACE_T aType ) :
63  KIFACE_I( aDSOname, aType )
64  {}
65 
66 } kiface( "common_test", KIWAY::KIWAY_FACE_COUNT );
67 
69 {
70  return kiface;
71 }
KIFACE_I is a KIFACE (I)mplementation, with some features useful for DSOs which implement a KIFACE.
Definition: kiface_i.h:37
bool start_common(int aCtlBits)
Common things to do for a top program module, during OnKifaceStart().
Definition: kiface_i.cpp:89
bool OnKifaceStart(PGM_BASE *aProgram, int aCtlBits) override
Function OnKifaceStart is called just once shortly after the DSO is loaded.
void MacOpenFile(const wxString &aFileName) override
Function MacOpenFile is specific to MacOSX (not used under Linux or Windows).
IFACE KIFACE_I kiface("common_test", KIWAY::KIWAY_FACE_COUNT)
PGM_BASE keeps program (whole process) data for KiCad programs.
Definition: pgm_base.h:137
PGM_BASE & Pgm()
The global Program "get" accessor.
wxWindow * CreateWindow(wxWindow *aParent, int aClassId, KIWAY *aKiway, int aCtlBits=0) override
Function CreateWindow creates a wxWindow for the current project.
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the s...
Definition: kiway.h:273
int PGM_BASE * aProgram
Definition: cvpcb/cvpcb.cpp:97
void * IfaceOrAddress(int aDataId) override
Function IfaceOrAddress returns a pointer to the requested object.
FACE_T
Known KIFACE implementations.
Definition: kiway.h:279
see class PGM_BASE
IFACE(const char *aDSOname, KIWAY::FACE_T aType)
PGM_SINGLE_TOP program