KiCad PCB EDA Suite
Loading...
Searching...
No Matches
FOOTPRINT_IMPORT_RECONCILER Class Reference

Frame-independent, non-interactive service that reconciles the footprint-library references of a freshly imported (non-KiCad) board so that every board footprint FPID resolves to a registered project library. More...

#include <footprint_import_reconciler.h>

Public Member Functions

 FOOTPRINT_IMPORT_RECONCILER (FOOTPRINT_LIBRARY_ADAPTER &aAdapter, const wxString &aProjectPath, REPORTER *aReporter=nullptr)
 
FOOTPRINT_IMPORT_RECONCILE_RESULT Reconcile (BOARD *aBoard, std::vector< std::unique_ptr< FOOTPRINT > > aDefinitions, const wxString &aCacheNickname, const std::vector< wxString > &aSourceLibNicknames)
 Reconcile aBoard against the importer definitions and the provenance source libraries.
 

Static Public Member Functions

static const wxString & ManagedCacheOption ()
 Options string identifying a footprint-library table row as a generated import cache.
 

Private Member Functions

void writeAndRegisterCache (const wxString &aCacheNickname, const std::map< wxString, FOOTPRINT * > &aCacheDefs, FOOTPRINT_IMPORT_RECONCILE_RESULT &aResult)
 Write the residual definitions into an atomically-published .pretty and register its row.
 
bool registerCacheRow (const wxString &aCacheNickname)
 Insert or refresh the project footprint-library-table row for the generated cache.
 

Private Attributes

FOOTPRINT_LIBRARY_ADAPTERm_adapter
 
wxString m_projectPath
 
REPORTERm_reporter
 

Detailed Description

Frame-independent, non-interactive service that reconciles the footprint-library references of a freshly imported (non-KiCad) board so that every board footprint FPID resolves to a registered project library.

A footprint whose definition provably lives in a provenance source library is re-linked there ("prefer source"); anything left over is written into a single manager-chosen generated cache (.pretty) registered in the project footprint-library table ("generate residual"). The service never scans arbitrary loaded/global libraries and never deletes a user library.

The footprint-library adapter and project path are injected so the service can be exercised with a temporary project and a locally-owned LIBRARY_MANAGER, without a frame.

Definition at line 61 of file footprint_import_reconciler.h.

Constructor & Destructor Documentation

◆ FOOTPRINT_IMPORT_RECONCILER()

FOOTPRINT_IMPORT_RECONCILER::FOOTPRINT_IMPORT_RECONCILER ( FOOTPRINT_LIBRARY_ADAPTER & aAdapter,
const wxString & aProjectPath,
REPORTER * aReporter = nullptr )

Definition at line 48 of file footprint_import_reconciler.cpp.

References m_adapter, m_projectPath, and m_reporter.

Member Function Documentation

◆ ManagedCacheOption()

const wxString & FOOTPRINT_IMPORT_RECONCILER::ManagedCacheOption ( )
static

Options string identifying a footprint-library table row as a generated import cache.

Definition at line 41 of file footprint_import_reconciler.cpp.

Referenced by registerCacheRow().

◆ Reconcile()

FOOTPRINT_IMPORT_RECONCILE_RESULT FOOTPRINT_IMPORT_RECONCILER::Reconcile ( BOARD * aBoard,
std::vector< std::unique_ptr< FOOTPRINT > > aDefinitions,
const wxString & aCacheNickname,
const std::vector< wxString > & aSourceLibNicknames )

Reconcile aBoard against the importer definitions and the provenance source libraries.

Parameters
aBoardis the imported board whose footprint FPIDs are re-pointed in place.
aDefinitionsare the caller-owned canonical footprint definitions produced by the importer (e.g. PCB_IO::GetImportedCachedLibraryFootprints()). Ownership is consumed by this call.
aCacheNicknameis the manager-chosen collision-free generated-cache nickname.
aSourceLibNicknamesare the provenance source footprint-library nicknames registered for this import.

Definition at line 91 of file footprint_import_reconciler.cpp.

References _, BOARD::Footprints(), FOOTPRINT::GetFPID(), LIB_ID::GetUniStringLibItemName(), LIB_ID::GetUniStringLibNickname(), m_adapter, m_reporter, name, result, RPT_SEVERITY_WARNING, LIB_ID::SetLibNickname(), and writeAndRegisterCache().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and PCB_EDIT_FRAME::reconcileImportedFootprintLibraries().

◆ registerCacheRow()

bool FOOTPRINT_IMPORT_RECONCILER::registerCacheRow ( const wxString & aCacheNickname)
private

Insert or refresh the project footprint-library-table row for the generated cache.

Returns false when no project table exists or the row could not be created.

Definition at line 363 of file footprint_import_reconciler.cpp.

References _, FILEEXT::KiCadFootprintLibPathExtension, m_adapter, m_reporter, ManagedCacheOption(), PROJECT, RPT_SEVERITY_ERROR, RPT_SEVERITY_WARNING, LIBRARY_TABLE_ROW::SetNickname(), LIBRARY_TABLE_ROW::SetOptions(), LIBRARY_TABLE_ROW::SetScope(), LIBRARY_TABLE_ROW::SetType(), LIBRARY_TABLE_ROW::SetURI(), and table.

Referenced by writeAndRegisterCache().

◆ writeAndRegisterCache()

void FOOTPRINT_IMPORT_RECONCILER::writeAndRegisterCache ( const wxString & aCacheNickname,
const std::map< wxString, FOOTPRINT * > & aCacheDefs,
FOOTPRINT_IMPORT_RECONCILE_RESULT & aResult )
private

Member Data Documentation

◆ m_adapter

FOOTPRINT_LIBRARY_ADAPTER& FOOTPRINT_IMPORT_RECONCILER::m_adapter
private

◆ m_projectPath

wxString FOOTPRINT_IMPORT_RECONCILER::m_projectPath
private

◆ m_reporter

REPORTER* FOOTPRINT_IMPORT_RECONCILER::m_reporter
private

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