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

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

#include <symbol_import_reconciler.h>

Public Member Functions

 SYMBOL_IMPORT_RECONCILER (SYMBOL_LIBRARY_ADAPTER &aAdapter, const wxString &aProjectPath, REPORTER &aReporter=NULL_REPORTER::GetInstance())
 
SYMBOL_IMPORT_RECONCILE_RESULT Reconcile (SCHEMATIC *aSchematic, std::vector< std::unique_ptr< LIB_SYMBOL > > aDefinitions, const wxString &aCacheNickname, const std::vector< wxString > &aSourceLibNicknames)
 Reconcile aSchematic against the importer definitions and the provenance source libraries.
 

Private Member Functions

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

Private Attributes

SYMBOL_LIBRARY_ADAPTERm_adapter
 
wxString m_projectPath
 
REPORTERm_reporter
 

Detailed Description

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

This is the schematic counterpart of FOOTPRINT_IMPORT_RECONCILER and follows the same policy. A symbol whose definition provably lives in a provenance source library is re-linked there ("prefer source"); anything left over is written into a single caller-chosen generated cache (.kicad_sym) registered in the project symbol-library table ("generate residual"). The service never scans arbitrary loaded/global libraries and never deletes a user library.

The symbol-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 64 of file symbol_import_reconciler.h.

Constructor & Destructor Documentation

◆ SYMBOL_IMPORT_RECONCILER()

SYMBOL_IMPORT_RECONCILER::SYMBOL_IMPORT_RECONCILER ( SYMBOL_LIBRARY_ADAPTER & aAdapter,
const wxString & aProjectPath,
REPORTER & aReporter = NULL_REPORTER::GetInstance() )

Definition at line 47 of file symbol_import_reconciler.cpp.

References m_adapter, m_projectPath, and m_reporter.

Member Function Documentation

◆ Reconcile()

SYMBOL_IMPORT_RECONCILE_RESULT SYMBOL_IMPORT_RECONCILER::Reconcile ( SCHEMATIC * aSchematic,
std::vector< std::unique_ptr< LIB_SYMBOL > > aDefinitions,
const wxString & aCacheNickname,
const std::vector< wxString > & aSourceLibNicknames )

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

Parameters
aSchematicis the imported schematic whose symbol LIB_IDs are re-pointed in place.
aDefinitionsare the caller-owned canonical symbol definitions produced by the importer (e.g. SCH_IO::GetImportedCachedLibrarySymbols()). Ownership is consumed by this call.
aCacheNicknameis the caller-chosen collision-free generated-cache nickname.
aSourceLibNicknamesare the provenance source symbol-library nicknames registered for this import.

Definition at line 129 of file symbol_import_reconciler.cpp.

References _, SCH_SYMBOL::GetLibId(), LIB_ID::GetUniStringLibItemName(), LIB_ID::GetUniStringLibNickname(), loadSymbol(), 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(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and ReconcileImportedSymbols().

◆ registerCacheRow()

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

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

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

Definition at line 437 of file symbol_import_reconciler.cpp.

References _, FILEEXT::KiCadSymbolLibFileExtension, m_adapter, m_reporter, IMPORT_PROJ_PROPS::ManagedCacheOption(), PROJECT, RPT_SEVERITY_ERROR, 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 SYMBOL_IMPORT_RECONCILER::writeAndRegisterCache ( const wxString & aCacheNickname,
const std::map< wxString, LIB_SYMBOL * > & aCacheDefs,
SYMBOL_IMPORT_RECONCILE_RESULT & aResult )
private

Member Data Documentation

◆ m_adapter

SYMBOL_LIBRARY_ADAPTER& SYMBOL_IMPORT_RECONCILER::m_adapter
private

◆ m_projectPath

wxString SYMBOL_IMPORT_RECONCILER::m_projectPath
private

Definition at line 96 of file symbol_import_reconciler.h.

Referenced by SYMBOL_IMPORT_RECONCILER(), and writeAndRegisterCache().

◆ m_reporter

REPORTER& SYMBOL_IMPORT_RECONCILER::m_reporter
private

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