KiCad PCB EDA Suite
Loading...
Searching...
No Matches
kiface_services.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 The 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, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef KIFACE_SERVICES_H
21#define KIFACE_SERVICES_H
22
23#include <set>
24#include <string>
25#include <type_traits>
26
27#include <wx/string.h>
28
29#include <kiface_ids.h>
30#include <kiway.h>
31
33class PROJECT;
34class REPORTER;
36class wxWindow;
37
38namespace KICAD_DIFF
39{
41struct DOCUMENT_DIFF;
42}
43
47template <KIFACE_ADDR_ID aId, typename T>
49{
50 static constexpr KIFACE_ADDR_ID Id = aId;
51 using Type = T;
52};
53
56
58 KIFACE_SERVICE<KIFACE_FILTER_FOOTPRINTS, wxString (*)( const wxString& )>;
59
62
65
67 KIFACE_SERVICE<KIFACE_FILTER_FOOTPRINT_USERS, wxString (*)( const wxString& )>;
68
71
74
76 KIFACE_SERVICE<KIFACE_NETLIST_SCHEMATIC, bool (*)( const wxString&, std::string&, KIWAY* )>;
77
79 KIFACE_SERVICE<KIFACE_MERGE_DOCUMENT, int (*)( int, const wxString&, const wxString&,
80 const wxString&, const wxString&, bool, bool,
81 REPORTER* )>;
82
84 KIFACE_SERVICE<KIFACE_OPEN_DIFF_DIALOG, int (*)( int, const wxString&, const wxString&,
85 const wxString&, const wxString&, wxWindow*,
86 REPORTER* )>;
87
90 KICAD_DIFF::DIFF_CANVAS_CONTEXT* (*)( int, const wxString&, const wxString&,
93
95 KIFACE_SERVICE<KIFACE_TEST_FOOTPRINT_LINK, int (*)( const wxString&, PROJECT* )>;
96
99 void (*)( const wxString&, PROJECT*, std::set<wxString>& )>;
100
107template <typename Service, typename T>
108void* KifaceServiceAddress( T aAddress )
109{
110 static_assert( std::is_same_v<T, typename Service::Type>,
111 "KIFACE service address does not match its service descriptor" );
112 return reinterpret_cast<void*>( aAddress );
113}
114
121template <typename Service>
122typename Service::Type GetKifaceService( KIFACE* aKiface )
123{
124 if( !aKiface )
125 return nullptr;
126
127 return reinterpret_cast<typename Service::Type>( aKiface->IfaceOrAddress( Service::Id ) );
128}
129
130#endif // KIFACE_SERVICES_H
An interface to the global shared library manager that is schematic-specific and linked to one projec...
Keeps the documents drawn on a pair of diff canvases alive.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition kiway.h:348
Container for project specific data.
Definition project.h:63
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:73
GAL-backed canvas for visualizing a KICAD_DIFF::DIFF_SCENE.
KIFACE_ADDR_ID
IDs of objects that may be returned by KIFACE::IfaceOrAddress.
Definition kiface_ids.h:27
@ KIFACE_TEST_FOOTPRINT_LINK
Definition kiface_ids.h:87
@ KIFACE_FILTER_FOOTPRINT_USERS
Function pointer type: wxString (*)(const wxString& aQueryJson) Input JSON: the object written by FOO...
Definition kiface_ids.h:50
@ KIFACE_MERGE_DOCUMENT
int (*)( int aKind, const wxString& aAncestor, const wxString& aOurs, const wxString& aTheirs,...
Definition kiface_ids.h:70
@ KIFACE_FOOTPRINTS_LOAD_PROGRESS
Function pointer type: float (*)() Returns how far the library loader has gotten as a fraction of the...
Definition kiface_ids.h:45
@ KIFACE_NETLIST_SCHEMATIC
Definition kiface_ids.h:63
@ KIFACE_FILTER_FOOTPRINTS
Function pointer type: wxString (*)(const wxString& aFilterJson) Input JSON: {"pin_count": N,...
Definition kiface_ids.h:35
@ KIFACE_TRIGGER_FOOTPRINTS_LOAD
Function pointer type: bool (*)() Starts loading the footprint libraries in the background.
Definition kiface_ids.h:40
@ KIFACE_TRIGGER_SYMBOLS_LOAD
Function pointer type: bool (*)() Starts loading the symbol libraries in the background.
Definition kiface_ids.h:55
@ KIFACE_ATTACH_DIFF_CANVASES
KICAD_DIFF::DIFF_CANVAS_CONTEXT* (*)( int aKind, const wxString& aFileA, const wxString& aFileB,...
Definition kiface_ids.h:85
@ KIFACE_OPEN_DIFF_DIALOG
int (*)( int aKind, const wxString& aFileA, const wxString& aFileB, const wxString& aLabelA,...
Definition kiface_ids.h:77
@ KIFACE_SYMBOLS_LOAD_PROGRESS
Function pointer type: float (*)() Returns how far the library loader has gotten as a fraction of the...
Definition kiface_ids.h:60
@ KIFACE_FOOTPRINT_PAD_NUMBERS
Function pointer type: void (*)( const wxString& aFootprint, PROJECT* aProject, std::set<wxString>& a...
Definition kiface_ids.h:95
KIFACE_SERVICE< KIFACE_FILTER_FOOTPRINTS, wxString(*)(const wxString &)> KIFACE_FILTER_FOOTPRINTS_SERVICE
KIFACE_SERVICE< KIFACE_FILTER_FOOTPRINT_USERS, wxString(*)(const wxString &)> KIFACE_FILTER_FOOTPRINT_USERS_SERVICE
Service::Type GetKifaceService(KIFACE *aKiface)
Look up a service exported by a KIFACE.
KIFACE_SERVICE< KIFACE_TEST_FOOTPRINT_LINK, int(*)(const wxString &, PROJECT *)> KIFACE_TEST_FOOTPRINT_LINK_SERVICE
KIFACE_SERVICE< KIFACE_ATTACH_DIFF_CANVASES, KICAD_DIFF::DIFF_CANVAS_CONTEXT *(*)(int, const wxString &, const wxString &, WIDGET_DIFF_CANVAS *, WIDGET_DIFF_CANVAS *, KICAD_DIFF::DOCUMENT_DIFF *, REPORTER *)> KIFACE_ATTACH_DIFF_CANVASES_SERVICE
KIFACE_SERVICE< KIFACE_OPEN_DIFF_DIALOG, int(*)(int, const wxString &, const wxString &, const wxString &, const wxString &, wxWindow *, REPORTER *)> KIFACE_OPEN_DIFF_DIALOG_SERVICE
void * KifaceServiceAddress(T aAddress)
Return a service address for IfaceOrAddress().
KIFACE_SERVICE< KIFACE_FOOTPRINT_LIBRARY_ADAPTER, FOOTPRINT_LIBRARY_ADAPTER * > KIFACE_FOOTPRINT_LIBRARY_ADAPTER_SERVICE
KIFACE_SERVICE< KIFACE_MERGE_DOCUMENT, int(*)(int, const wxString &, const wxString &, const wxString &, const wxString &, bool, bool, REPORTER *)> KIFACE_MERGE_DOCUMENT_SERVICE
KIFACE_SERVICE< KIFACE_SYMBOLS_LOAD_PROGRESS, float(*)()> KIFACE_SYMBOLS_LOAD_PROGRESS_SERVICE
KIFACE_SERVICE< KIFACE_FOOTPRINT_PAD_NUMBERS, void(*)(const wxString &, PROJECT *, std::set< wxString > &)> KIFACE_FOOTPRINT_PAD_NUMBERS_SERVICE
KIFACE_SERVICE< KIFACE_TRIGGER_SYMBOLS_LOAD, bool(*)()> KIFACE_TRIGGER_SYMBOLS_LOAD_SERVICE
KIFACE_SERVICE< KIFACE_FOOTPRINTS_LOAD_PROGRESS, float(*)()> KIFACE_FOOTPRINTS_LOAD_PROGRESS_SERVICE
KIFACE_SERVICE< KIFACE_NETLIST_SCHEMATIC, bool(*)(const wxString &, std::string &, KIWAY *)> KIFACE_NETLIST_SCHEMATIC_SERVICE
KIFACE_SERVICE< KIFACE_TRIGGER_FOOTPRINTS_LOAD, bool(*)()> KIFACE_TRIGGER_FOOTPRINTS_LOAD_SERVICE
The full set of changes between two parsed documents of one type.
Describes an object or function exported by a KIFACE through IfaceOrAddress()
Implement a participant in the KIWAY alchemy.
Definition kiway.h:153
virtual void * IfaceOrAddress(int aDataId)=0
Return pointer to the requested object.