KiCad PCB EDA Suite
Loading...
Searching...
No Matches
footprint_library_adapter.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 * @author Jon Evans <[email protected]>
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
22
23#include <chrono>
24#include <env_vars.h>
25#include <footprint_info_impl.h>
26#include <thread_pool.h>
27#include <trace_helpers.h>
28#include <footprint.h>
29
30#include <magic_enum.hpp>
31#include <wx/hash.h>
32#include <wx/log.h>
33
34using namespace std::chrono_literals;
35
36
38
40
42
44
45
50
51
56
57
59{
60 return ENV_VAR::GetVersionedEnvVarName( wxS( "FOOTPRINT_DIR" ) );
61}
62
63
64void FOOTPRINT_LIBRARY_ADAPTER::enumerateLibrary( LIB_DATA* aLib, const wxString& aUri )
65{
66 wxArrayString namesAS;
67 std::map<std::string, UTF8> options = aLib->row->GetOptionsMap();
68 PCB_IO* plugin = pcbplugin( aLib );
69 wxString nickname = aLib->row->Nickname();
70
71 // Hold across the enumerate-then-borrow sequence: GetEnumeratedFootprint returns borrowed
72 // FP_CACHE pointers, so no other thread may rebuild the cache until we finish cloning.
73 std::lock_guard pluginGuard( pluginMutex( nickname ) );
74
75 // FootprintEnumerate populates the plugin's internal FP_CACHE with parsed footprints
76 plugin->FootprintEnumerate( namesAS, aUri, false, &options );
77
78 std::vector<std::unique_ptr<FOOTPRINT>> footprints;
79 footprints.reserve( namesAS.size() );
80
81 // For plugins with internal caches (like kicad_sexpr), GetEnumeratedFootprint returns
82 // a borrowed pointer and ClearCachedFootprints handles cleanup. For other plugins,
83 // GetEnumeratedFootprint allocates new memory that we must delete after cloning.
84 const bool pluginCaches = plugin->CachesEnumeratedFootprints();
85
86 for( const wxString& footprintName : namesAS )
87 {
88 try
89 {
90 const FOOTPRINT* cached = plugin->GetEnumeratedFootprint( aUri, footprintName, &options );
91
92 if( !cached )
93 continue;
94
95 FOOTPRINT* footprint = static_cast<FOOTPRINT*>( cached->Duplicate( IGNORE_PARENT_GROUP ) );
96 footprint->SetParent( nullptr );
97
98 // For non-caching plugins, delete the allocated footprint now that we've cloned it
99 if( !pluginCaches )
100 delete cached;
101
102 LIB_ID id = footprint->GetFPID();
103 id.SetLibNickname( nickname );
104 footprint->SetFPID( id );
105 footprints.emplace_back( footprint );
106 }
107 catch( IO_ERROR& e )
108 {
109 wxLogTrace( traceLibraries, "FP: %s:%s enumeration error: %s",
110 nickname, footprintName, e.What() );
111 }
112 }
113
114 // GetLibraryTimestamp() reads the filesystem, so do it before taking the lock.
115 long long timestamp = plugin->GetLibraryTimestamp( aUri );
116
117 {
118 std::unique_lock lock( PreloadedFootprintsMutex );
119 PreloadedFootprints.Get()[nickname] = std::move( footprints );
120 m_preloadedTimestamps[nickname] = timestamp;
121 }
122
123 // Clear the plugin's FP_CACHE now that we've copied footprints to PreloadedFootprints.
124 // This eliminates the double-caching that was consuming ~1.2GB of extra RAM.
125 plugin->ClearCachedFootprints( aUri );
126}
127
128
129std::optional<LIB_STATUS> FOOTPRINT_LIBRARY_ADAPTER::LoadOne( LIB_DATA* aLib )
130{
132
133 std::map<std::string, UTF8> options = aLib->row->GetOptionsMap();
134
135 try
136 {
137 std::lock_guard pluginGuard( pluginMutex( aLib->row->Nickname() ) );
138
139 wxArrayString dummyList;
140 pcbplugin( aLib )->FootprintEnumerate( dummyList, getUri( aLib->row ), false, &options );
142 }
143 catch( IO_ERROR& e )
144 {
146 aLib->status.error = LIBRARY_ERROR( { e.What() } );
147 wxLogTrace( traceLibraries, "FP: %s: plugin threw exception: %s", aLib->row->Nickname(), e.What() );
148 }
149
150 return aLib->status;
151}
152
153
154std::optional<LIB_STATUS> FOOTPRINT_LIBRARY_ADAPTER::LoadOne( const wxString& nickname )
155{
157
158 if( result.has_value() )
159 return LoadOne( *result );
160
161 return LIB_STATUS{
162 .load_status = LOAD_STATUS::LOAD_ERROR,
163 .error = LIBRARY_ERROR( { result.error() } )
164 };
165}
166
167
168std::vector<FOOTPRINT*> FOOTPRINT_LIBRARY_ADAPTER::GetFootprints( const wxString& aNickname, bool aBestEfforts )
169{
170 std::vector<FOOTPRINT*> footprints;
171
172 std::shared_lock lock( PreloadedFootprintsMutex );
173 auto it = PreloadedFootprints.Get().find( aNickname );
174
175 if( it == PreloadedFootprints.Get().end() )
176 return footprints;
177
178 footprints.reserve( it->second.size() );
179
180 for( const auto& fp : it->second )
181 footprints.push_back( fp.get() );
182
183 return footprints;
184}
185
186
187
188std::vector<wxString> FOOTPRINT_LIBRARY_ADAPTER::GetFootprintNames( const wxString& aNickname, bool aBestEfforts )
189{
190 // TODO(JE) can we kill wxArrayString in internal API?
191 wxArrayString namesAS;
192 std::vector<wxString> names;
193
194 if( std::optional<const LIB_DATA*> maybeLib = fetchIfLoaded( aNickname ) )
195 {
196 const LIB_DATA* lib = *maybeLib;
197 std::map<std::string, UTF8> options = lib->row->GetOptionsMap();
198
199 try
200 {
201 std::lock_guard pluginGuard( pluginMutex( aNickname ) );
202
203 pcbplugin( lib )->FootprintEnumerate( namesAS, getUri( lib->row ), true, &options );
204 }
205 catch( IO_ERROR& e )
206 {
207 wxLogTrace( traceLibraries, "FP: Exception enumerating library %s: %s", lib->row->Nickname(), e.What() );
208 }
209 }
210
211 for( const wxString& name : namesAS )
212 names.emplace_back( name );
213
214 return names;
215}
216
217
218long long FOOTPRINT_LIBRARY_ADAPTER::GenerateTimestamp( const wxString* aNickname )
219{
220 long long hash = 0;
221
222 if( aNickname )
223 {
224 wxCHECK( HasLibrary( *aNickname, true ), hash );
225
226 if( std::optional<const LIB_DATA*> r = fetchIfLoaded( *aNickname ); r.has_value() )
227 {
228 PCB_IO* plugin = dynamic_cast<PCB_IO*>( ( *r )->plugin.get() );
229 wxCHECK( plugin, hash );
230 return plugin->GetLibraryTimestamp( LIBRARY_MANAGER::GetFullURI( ( *r )->row, true ) )
231 + wxHashTable::MakeKey( *aNickname );
232 }
233 }
234
235 for( const wxString& nickname : GetLibraryNames() )
236 {
237 if( std::optional<const LIB_DATA*> r = fetchIfLoaded( nickname ); r.has_value() )
238 {
239 wxCHECK2( ( *r )->plugin->IsPCB_IO(), continue );
240 PCB_IO* plugin = static_cast<PCB_IO*>( ( *r )->plugin.get() );
241 hash += plugin->GetLibraryTimestamp( LIBRARY_MANAGER::GetFullURI( ( *r )->row, true ) )
242 + wxHashTable::MakeKey( nickname );
243 }
244 }
245
246 return hash;
247}
248
249
251{
252 std::optional<LIB_DATA*> maybeLib = fetchIfLoaded( aNickname );
253
254 if( !maybeLib )
255 return;
256
257 LIB_DATA* lib = *maybeLib;
258 PCB_IO* plugin = dynamic_cast<PCB_IO*>( lib->plugin.get() );
259
260 if( !plugin )
261 return;
262
263 wxString uri = getUri( lib->row );
264 long long currentTimestamp = plugin->GetLibraryTimestamp( uri );
265
266 {
267 std::shared_lock lock( PreloadedFootprintsMutex );
268 auto tsIt = m_preloadedTimestamps.find( aNickname );
269
270 if( tsIt != m_preloadedTimestamps.end() && tsIt->second == currentTimestamp )
271 return;
272
273 wxLogTrace( traceLibraries, "FP: %s changed on disk, re-enumerating", aNickname );
274 }
275
276 enumerateLibrary( lib, uri );
277}
278
279
280bool FOOTPRINT_LIBRARY_ADAPTER::FootprintExists( const wxString& aNickname, const wxString& aName )
281{
282 if( std::optional<const LIB_DATA*> maybeLib = fetchIfLoaded( aNickname ) )
283 {
284 const LIB_DATA* lib = *maybeLib;
285 std::map<std::string, UTF8> options = lib->row->GetOptionsMap();
286
287 std::lock_guard pluginGuard( pluginMutex( aNickname ) );
288
289 return pcbplugin( lib )->FootprintExists( getUri( lib->row ), aName, &options );
290 }
291
292 return false;
293}
294
295
296FOOTPRINT* FOOTPRINT_LIBRARY_ADAPTER::LoadFootprint( const wxString& aNickname, const wxString& aName, bool aKeepUUID )
297{
298 // First check if the footprint is in PreloadedFootprints and clone from there.
299 // This avoids re-parsing the file and keeps FP_CACHE from being repopulated.
300 {
301 std::shared_lock lock( PreloadedFootprintsMutex );
302 auto libIt = PreloadedFootprints.Get().find( aNickname );
303
304 if( libIt != PreloadedFootprints.Get().end() )
305 {
306 for( const auto& fp : libIt->second )
307 {
308 if( fp->GetFPID().GetLibItemName() == UTF8( aName ) )
309 {
311
312 if( aKeepUUID )
313 copy = static_cast<FOOTPRINT*>( fp->Clone() );
314 else
315 copy = static_cast<FOOTPRINT*>( fp->Duplicate( IGNORE_PARENT_GROUP ) );
316
317 copy->SetParent( nullptr );
318 return copy;
319 }
320 }
321 }
322 }
323
324 // Footprint not found in PreloadedFootprints, fall back to plugin.
325 // This re-parses the file but is needed for footprints not yet enumerated.
326 if( std::optional<const LIB_DATA*> lib = fetchIfLoaded( aNickname ) )
327 {
328 try
329 {
330 std::lock_guard pluginGuard( pluginMutex( aNickname ) );
331
332 if( FOOTPRINT* footprint = pcbplugin( *lib )->FootprintLoad( getUri( ( *lib )->row ), aName, aKeepUUID ) )
333 {
334 LIB_ID id = footprint->GetFPID();
335 id.SetLibNickname( ( *lib )->row->Nickname() );
336 footprint->SetFPID( id );
337 return footprint;
338 }
339 }
340 catch( const IO_ERROR& ioe )
341 {
342 wxLogTrace( traceLibraries, "LoadFootprint: error loading %s:%s: %s", aNickname, aName, ioe.What() );
343 }
344 }
345 else
346 {
347 wxLogTrace( traceLibraries, "LoadFootprint: requested library %s not loaded", aNickname );
348 }
349
350 return nullptr;
351}
352
353
355{
356 wxString nickname = aFootprintId.GetLibNickname();
357 wxString footprintName = aFootprintId.GetLibItemName();
358
359 if( nickname.size() )
360 return LoadFootprint( nickname, footprintName, aKeepUUID );
361
362 // nickname is empty, sequentially search (alphabetically) all libs/nicks for first match:
363 for( const wxString& library : GetLibraryNames() )
364 {
365 // FootprintLoad() returns NULL on not found, does not throw exception
366 // unless there's an IO_ERROR.
367 if( FOOTPRINT* ret = LoadFootprint( library, footprintName, aKeepUUID ) )
368 return ret;
369 }
370
371 return nullptr;
372}
373
374
376 const FOOTPRINT* aFootprint,
377 bool aOverwrite )
378{
379 wxCHECK( aFootprint, SAVE_SKIPPED );
380
381 if( std::optional<const LIB_DATA*> lib = fetchIfLoaded( aNickname ) )
382 {
383 // Serialize the load-check / save / cache-update sequence against a concurrent rebuild.
384 std::lock_guard pluginGuard( pluginMutex( aNickname ) );
385
386 if( !aOverwrite )
387 {
388 wxString fpname = aFootprint->GetFPID().GetLibItemName();
389
390 try
391 {
392 FOOTPRINT* existing = pcbplugin( *lib )->FootprintLoad( getUri( ( *lib )->row ), fpname, false );
393
394 if( existing )
395 {
396 delete existing;
397 return SAVE_SKIPPED;
398 }
399 }
400 catch( IO_ERROR& e )
401 {
402 wxLogTrace( traceLibraries, "SaveFootprint: error checking for existing footprint %s: %s",
403 aFootprint->GetFPIDAsString(), e.What() );
404 return SAVE_SKIPPED;
405 }
406 }
407
408 try
409 {
410 pcbplugin( *lib )->FootprintSave( getUri( ( *lib )->row ), aFootprint );
411 }
412 catch( IO_ERROR& e )
413 {
414 // Re-throw rather than returning SAVE_SKIPPED; swallowing a write failure (read-only
415 // file, full disk) would report a successful save while the file is unchanged.
416 wxLogTrace( traceLibraries, "SaveFootprint: error saving %s: %s",
417 aFootprint->GetFPIDAsString(), e.What() );
418 throw;
419 }
420
421 {
422 std::unique_lock lock( PreloadedFootprintsMutex );
423 auto it = PreloadedFootprints.Get().find( aNickname );
424
425 if( it != PreloadedFootprints.Get().end() )
426 {
427 wxString fpName = aFootprint->GetFPID().GetLibItemName();
428
429 if( aOverwrite )
430 {
431 auto& footprints = it->second;
432 footprints.erase( std::remove_if( footprints.begin(), footprints.end(),
433 [&fpName]( const std::unique_ptr<FOOTPRINT>& fp )
434 {
435 return fp->GetFPID().GetLibItemName().wx_str() == fpName;
436 } ),
437 footprints.end() );
438 }
439
440 FOOTPRINT* clone = static_cast<FOOTPRINT*>( aFootprint->Duplicate( IGNORE_PARENT_GROUP ) );
441 clone->SetParent( nullptr );
442
443 LIB_ID id = clone->GetFPID();
444 id.SetLibNickname( aNickname );
445 clone->SetFPID( id );
446
447 it->second.emplace_back( clone );
448 }
449 }
450
451 return SAVE_OK;
452 }
453 else
454 {
455 wxLogTrace( traceLibraries, "SaveFootprint: requested library %s not loaded", aNickname );
456 return SAVE_SKIPPED;
457 }
458}
459
460
461void FOOTPRINT_LIBRARY_ADAPTER::DeleteFootprint( const wxString& aNickname, const wxString& aFootprintName )
462{
463 if( std::optional<const LIB_DATA*> lib = fetchIfLoaded( aNickname ) )
464 {
465 std::lock_guard pluginGuard( pluginMutex( aNickname ) );
466
467 try
468 {
469 pcbplugin( *lib )->FootprintDelete( getUri( ( *lib )->row ), aFootprintName );
470 }
471 catch( IO_ERROR& e )
472 {
473 wxLogTrace( traceLibraries, "DeleteFootprint: error deleting %s:%s: %s", aNickname,
474 aFootprintName, e.What() );
475 return;
476 }
477
478 {
479 std::unique_lock lock( PreloadedFootprintsMutex );
480 auto it = PreloadedFootprints.Get().find( aNickname );
481
482 if( it != PreloadedFootprints.Get().end() )
483 {
484 auto& footprints = it->second;
485 footprints.erase( std::remove_if( footprints.begin(), footprints.end(),
486 [&aFootprintName]( const std::unique_ptr<FOOTPRINT>& fp )
487 {
488 return fp->GetFPID().GetLibItemName().wx_str() == aFootprintName;
489 } ),
490 footprints.end() );
491 }
492 }
493 }
494 else
495 {
496 wxLogTrace( traceLibraries, "DeleteFootprint: requested library %s not loaded", aNickname );
497 }
498}
499
500
502{
503 // Route through fetchIfLoaded() so LOAD_ERROR sentinel entries, which carry a null
504 // plugin, are filtered out instead of dereferenced.
505 if( std::optional<const LIB_DATA*> lib = fetchIfLoaded( aLib ) )
506 {
507 std::lock_guard pluginGuard( pluginMutex( aLib ) );
508
509 return ( *lib )->plugin->IsLibraryWritable( getUri( ( *lib )->row ) );
510 }
511
512 return false;
513}
514
515
517{
519
520 if( type == PCB_IO_MGR::NESTED_TABLE )
521 {
522 wxString msg;
523 wxFileName fileName( m_manager.GetFullURI( row, true ) );
524
525 if( fileName.FileExists() )
526 return tl::unexpected( LIBRARY_TABLE_OK() );
527 else
528 msg = wxString::Format( _( "Nested table '%s' not found." ), row->URI() );
529
530 return tl::unexpected( LIBRARY_ERROR( msg ) );
531 }
532 else if( type == PCB_IO_MGR::PCB_FILE_UNKNOWN )
533 {
534 wxLogTrace( traceLibraries, "FP: Plugin type %s is unknown!", row->Type() );
535 wxString msg = wxString::Format( _( "Unknown library type %s " ), row->Type() );
536 return tl::unexpected( LIBRARY_ERROR( msg ) );
537 }
538
540 wxCHECK( plugin, tl::unexpected( LIBRARY_ERROR( _( "Internal error" ) ) ) );
541
542 wxLogTrace( traceLibraries, "FP: Library %s (%s) plugin created", row->Nickname(),
543 magic_enum::enum_name( row->Scope() ) );
544
545 return plugin;
546}
547
548
550{
551 // Note: can't use dynamic_cast across compile units on Mac
552 wxCHECK( aRow->plugin->IsPCB_IO(), nullptr );
553 PCB_IO* ret = static_cast<PCB_IO*>( aRow->plugin.get() );
554 return ret;
555}
const char * name
virtual void SetParent(EDA_ITEM *aParent)
Definition eda_item.cpp:89
bool IsFootprintLibWritable(const wxString &aNickname)
Return true if the library given by aNickname is writable.
void DeleteFootprint(const wxString &aNickname, const wxString &aFootprintName)
Deletes the aFootprintName from the library given by aNickname.
std::vector< FOOTPRINT * > GetFootprints(const wxString &aNickname, bool aBestEfforts=false)
Retrieves a list of footprints contained in a given loaded library.
void RefreshLibraryIfChanged(const wxString &aNickname)
Checks whether the library on disk has changed since it was last enumerated into PreloadedFootprints ...
static LEAK_AT_EXIT< std::shared_mutex > GlobalLibraryMutex
void enumerateLibrary(LIB_DATA *aLib, const wxString &aUri) override
Override in derived class to perform library-specific enumeration.
IO_BASE * plugin(const LIB_DATA *aRow) override
SAVE_T SaveFootprint(const wxString &aNickname, const FOOTPRINT *aFootprint, bool aOverwrite=true)
Write aFootprint to an existing library given by aNickname.
std::vector< wxString > GetFootprintNames(const wxString &aNickname, bool aBestEfforts=false)
Retrieves a list of footprint names contained in a given loaded library.
FOOTPRINT * LoadFootprint(const wxString &aNickname, const wxString &aName, bool aKeepUUID)
Load a FOOTPRINT having aName from the library given by aNickname.
static LEAK_AT_EXIT< std::map< wxString, LIB_DATA > > GlobalLibraries
static PCB_IO * pcbplugin(const LIB_DATA *aRow)
FOOTPRINT * LoadFootprintWithOptionalNickname(const LIB_ID &aFootprintId, bool aKeepUUID)
Load a footprint having aFootprintId with possibly an empty nickname.
std::map< wxString, long long > m_preloadedTimestamps
Per-library filesystem timestamps recorded when PreloadedFootprints was last populated.
LIBRARY_RESULT< IO_BASE * > createPlugin(const LIBRARY_TABLE_ROW *row) override
Creates a concrete plugin for the given row.
FOOTPRINT_LIBRARY_ADAPTER(LIBRARY_MANAGER &aManager)
long long GenerateTimestamp(const wxString *aNickname)
Generates a filesystem timestamp / hash value for library(ies)
std::optional< LIB_STATUS > LoadOne(LIB_DATA *aLib) override
Loads or reloads the given library, if it exists.
SAVE_T
The set of return values from SaveSymbol() below.
static LEAK_AT_EXIT< std::map< wxString, std::vector< std::unique_ptr< FOOTPRINT > > > > PreloadedFootprints
Storage for preloaded footprints, indexed by library nickname.
bool FootprintExists(const wxString &aNickname, const wxString &aName)
static std::shared_mutex PreloadedFootprintsMutex
void SetFPID(const LIB_ID &aFPID)
Definition footprint.h:445
wxString GetFPIDAsString() const
Definition footprint.h:450
const LIB_ID & GetFPID() const
Definition footprint.h:444
BOARD_ITEM * Duplicate(bool addToParentGroup, BOARD_COMMIT *aCommit=nullptr) const override
Create a copy of this BOARD_ITEM.
virtual bool IsPCB_IO() const
Work-around for lack of dynamic_cast across compile units on Mac.
Definition io_base.h:84
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
A wrapper for static data that should not be destroyed at program exit.
void evictOwnedGlobalEntries()
Erases this adapter's own entries (LIB_DATA::global_owner == this) from the process-wide globalLibs()...
LIBRARY_MANAGER_ADAPTER(LIBRARY_MANAGER &aManager)
Constructs a type-specific adapter into the library manager.
static std::mutex & pluginMutex(const wxString &aNickname)
Serializes access to a library's shared plugin instance so its single mutable cache is not raced by c...
LIBRARY_RESULT< LIB_DATA * > loadIfNeeded(const wxString &aNickname)
Fetches a loaded library, triggering a load of that library if it isn't loaded yet.
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library tables.
std::vector< wxString > GetLibraryNames() const
Returns a list of library nicknames that are available (skips any that failed to load)
static wxString getUri(const LIBRARY_TABLE_ROW *aRow)
LIBRARY_MANAGER & m_manager
std::optional< const LIB_DATA * > fetchIfLoaded(const wxString &aNickname) const
std::optional< wxString > GetFullURI(LIBRARY_TABLE_TYPE aType, const wxString &aNickname, bool aSubstituted=false)
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
LIBRARY_TABLE_SCOPE Scope() const
std::map< std::string, UTF8 > GetOptionsMap() const
const wxString & Type() const
const wxString & URI() const
const wxString & Nickname() const
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:45
int SetLibNickname(const UTF8 &aLibNickname)
Override the logical library name portion of the LIB_ID to aLibNickname.
Definition lib_id.cpp:113
const UTF8 & GetLibItemName() const
Definition lib_id.h:98
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition lib_id.h:83
static PCB_FILE_T EnumFromStr(const wxString &aFileType)
Return the PCB_FILE_T from the corresponding plugin type name: "kicad", "legacy", etc.
PCB_FILE_T
The set of file types that the PCB_IO_MGR knows about, and for which there has been a plugin written,...
Definition pcb_io_mgr.h:52
@ PCB_FILE_UNKNOWN
0 is not a legal menu id on Mac
Definition pcb_io_mgr.h:53
static PCB_IO * FindPlugin(PCB_FILE_T aFileType)
Return a #PLUGIN which the caller can use to import, export, save, or load design documents.
A base class that BOARD loading and saving plugins should derive from.
Definition pcb_io.h:75
virtual void FootprintEnumerate(wxArrayString &aFootprintNames, const wxString &aLibraryPath, bool aBestEfforts, const std::map< std::string, UTF8 > *aProperties=nullptr)
Return a list of footprint names contained within the library at aLibraryPath.
Definition pcb_io.cpp:91
virtual bool FootprintExists(const wxString &aLibraryPath, const wxString &aFootprintName, const std::map< std::string, UTF8 > *aProperties=nullptr)
Check for the existence of a footprint.
Definition pcb_io.cpp:132
virtual void FootprintDelete(const wxString &aLibraryPath, const wxString &aFootprintName, const std::map< std::string, UTF8 > *aProperties=nullptr)
Delete aFootprintName from the library at aLibraryPath.
Definition pcb_io.cpp:156
virtual FOOTPRINT * FootprintLoad(const wxString &aLibraryPath, const wxString &aFootprintName, bool aKeepUUID=false, const std::map< std::string, UTF8 > *aProperties=nullptr)
Load a footprint having aFootprintName from the aLibraryPath containing a library format that this PC...
Definition pcb_io.cpp:140
virtual void FootprintSave(const wxString &aLibraryPath, const FOOTPRINT *aFootprint, const std::map< std::string, UTF8 > *aProperties=nullptr)
Write aFootprint to an existing library located at aLibraryPath.
Definition pcb_io.cpp:148
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
Definition utf8.h:67
#define _(s)
#define IGNORE_PARENT_GROUP
Definition eda_item.h:53
Functions related to environment variables, including help functions.
const wxChar *const traceLibraries
Flag to enable library table and library manager tracing.
tl::expected< ResultType, LIBRARY_ERROR > LIBRARY_RESULT
KICOMMON_API wxString GetVersionedEnvVarName(const wxString &aBaseName)
Construct a versioned environment variable based on this KiCad major version.
Definition env_vars.cpp:78
Storage for an actual loaded library (including library content owned by the plugin)
LIB_STATUS status
std::unique_ptr< IO_BASE > plugin
const LIBRARY_TABLE_ROW * row
The overall status of a loaded or loading library.
std::optional< LIBRARY_ERROR > error
LOAD_STATUS load_status
wxString result
Test unit parsing edge cases and error handling.
wxLogTrace helper definitions.