KiCad PCB EDA Suite
Loading...
Searching...
No Matches
KICAD_DIFF::SCH_MERGE_APPLIER Class Reference

Materialize a MERGE_PLAN into a merged SCHEMATIC by mutating the ancestor in place. More...

#include <sch_merge_applier.h>

Classes

struct  PathedItem
 
struct  REPORT
 

Public Member Functions

 SCH_MERGE_APPLIER (SCHEMATIC *aAncestor, const SCHEMATIC *aOurs, const SCHEMATIC *aTheirs, MERGE_PLAN aPlan)
 
bool Apply ()
 Apply the plan to the ancestor.
 
const REPORTGetReport () const
 

Private Member Functions

std::map< KIID_PATH, PathedItemindexSchematic (const SCHEMATIC *aSchematic, std::vector< std::unique_ptr< SCH_SHEET_PATH > > &aStorage) const
 Walk a schematic into a KIID_PATH-keyed table of (item, sheet_path).
 
std::size_t applyPropertyResolutions (SCH_ITEM *aTarget, const std::vector< PROPERTY_RESOLUTION > &aProps, const SCH_ITEM *aOurs, const SCH_ITEM *aTheirs, const SCH_ITEM *aAncestor)
 

Private Attributes

SCHEMATICm_ancestor
 
const SCHEMATICm_ours
 
const SCHEMATICm_theirs
 
MERGE_PLAN m_plan
 
REPORT m_report
 

Detailed Description

Materialize a MERGE_PLAN into a merged SCHEMATIC by mutating the ancestor in place.

Schematics are hierarchical: an item lives on one SCH_SCREEN identified by a sheet path. The applier indexes every (KIID_PATH, SCH_ITEM*) tuple in the three input schematics, then for each ITEM_RESOLUTION it either removes from the target, clones an item onto the correct sheet, or applies a property delta against the target item.

Unlike the PCB applier which builds a fresh output BOARD, the SCH applier mutates the ancestor schematic in place. The reason: SCHEMATIC carries hierarchy, project-relative paths, sheet UUIDs, and instance data that cannot be cleanly recomputed from a fresh empty schematic. Working off the ancestor preserves all of that automatically.

Definition at line 56 of file sch_merge_applier.h.

Constructor & Destructor Documentation

◆ SCH_MERGE_APPLIER()

KICAD_DIFF::SCH_MERGE_APPLIER::SCH_MERGE_APPLIER ( SCHEMATIC * aAncestor,
const SCHEMATIC * aOurs,
const SCHEMATIC * aTheirs,
MERGE_PLAN aPlan )

Definition at line 76 of file sch_merge_applier.cpp.

References m_ancestor, m_ours, m_plan, m_theirs, and move.

Member Function Documentation

◆ Apply()

bool KICAD_DIFF::SCH_MERGE_APPLIER::Apply ( )

Apply the plan to the ancestor.

Returns true on success.

Definition at line 129 of file sch_merge_applier.cpp.

References SCH_SYMBOL::AddHierarchicalReference(), KICAD_DIFF::VALIDATION_INPUT::ancestorSchemaVersion, SCH_SCREEN::Append(), KICAD_DIFF::VALIDATION_INPUT::applierReportedRebuild, applyPropertyResolutions(), EDA_ITEM::Clone(), KICAD_DIFF::DELETE_ITEM, KICAD_DIFF::DOC_PROP_DRAWING_SHEET, KICAD_DIFF::DOC_PROP_ERC_SEVERITIES, KICAD_DIFF::DOC_PROP_PAGE_FORMAT, KICAD_DIFF::DOC_PROP_PAGE_ORIENTATION, SCHEMATIC::ErcSettings(), SCH_SYMBOL::GetInstance(), SCH_SCREEN::GetPageSettings(), SCH_SYMBOL::GetRef(), PAGE_INFO::GetType(), KICAD_DIFF::REFDES_ENTRY::id, indexSchematic(), PAGE_INFO::IsPortrait(), KICAD_DIFF::isSheetItem(), SCHEMATIC::IsValid(), SCH_SCREEN::Items(), KICAD_DIFF::KEEP, KICAD_DIFF::PROPERTY_RESOLUTION::kind, SCH_SHEET_PATH::LastScreen(), m_ancestor, ERC_SETTINGS::m_ERCSeverities, m_ours, m_plan, m_report, SCHEMATIC_SETTINGS::m_SchDrawingSheetFileName, m_theirs, EDA_ITEM::m_Uuid, KICAD_DIFF::MERGE_PROPS, KICAD_DIFF::PROPERTY_RESOLUTION::name, EE_RTREE::OfType(), KICAD_DIFF::OURS, KICAD_DIFF::VALIDATION_INPUT::oursSchemaVersion, SCH_SHEET_PATH::Path(), KICAD_DIFF::VALIDATION_INPUT::planRequiredRebuild, KICAD_DIFF::REFDES_ENTRY::refdes, KICAD_DIFF::VALIDATION_INPUT::refdesEntries, SCH_SCREEN::Remove(), res, KICAD_DIFF::rootFileFormatVersion(), SCHEMATIC::RootScreen(), KICAD_DIFF::RunPostApplyValidators(), SCH_SYMBOL_T, KICAD_DIFF::SchScreenSentinelKiid(), BASE_SCREEN::SetContentModified(), SCH_SCREEN::SetPageSettings(), PAGE_INFO::SetPortrait(), SCHEMATIC::Settings(), PAGE_INFO::SetType(), KICAD_DIFF::TAKE_ANCESTOR, KICAD_DIFF::TAKE_OURS, KICAD_DIFF::TAKE_THEIRS, KICAD_DIFF::THEIRS, KICAD_DIFF::VALIDATION_INPUT::theirsSchemaVersion, traceDiffMerge, and SCH_SCREEN::Update().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and EESCHEMA_JOBS_HANDLER::runSchMerge().

◆ applyPropertyResolutions()

std::size_t KICAD_DIFF::SCH_MERGE_APPLIER::applyPropertyResolutions ( SCH_ITEM * aTarget,
const std::vector< PROPERTY_RESOLUTION > & aProps,
const SCH_ITEM * aOurs,
const SCH_ITEM * aTheirs,
const SCH_ITEM * aAncestor )
private

◆ GetReport()

const REPORT & KICAD_DIFF::SCH_MERGE_APPLIER::GetReport ( ) const
inline

◆ indexSchematic()

std::map< KIID_PATH, SCH_MERGE_APPLIER::PathedItem > KICAD_DIFF::SCH_MERGE_APPLIER::indexSchematic ( const SCHEMATIC * aSchematic,
std::vector< std::unique_ptr< SCH_SHEET_PATH > > & aStorage ) const
private

Walk a schematic into a KIID_PATH-keyed table of (item, sheet_path).

Definition at line 86 of file sch_merge_applier.cpp.

References index, and KICAD_DIFF::WalkSchematic().

Referenced by Apply().

Member Data Documentation

◆ m_ancestor

SCHEMATIC* KICAD_DIFF::SCH_MERGE_APPLIER::m_ancestor
private

Definition at line 123 of file sch_merge_applier.h.

Referenced by Apply(), and SCH_MERGE_APPLIER().

◆ m_ours

const SCHEMATIC* KICAD_DIFF::SCH_MERGE_APPLIER::m_ours
private

Definition at line 124 of file sch_merge_applier.h.

Referenced by Apply(), and SCH_MERGE_APPLIER().

◆ m_plan

MERGE_PLAN KICAD_DIFF::SCH_MERGE_APPLIER::m_plan
private

Definition at line 126 of file sch_merge_applier.h.

Referenced by Apply(), and SCH_MERGE_APPLIER().

◆ m_report

REPORT KICAD_DIFF::SCH_MERGE_APPLIER::m_report
private

Definition at line 127 of file sch_merge_applier.h.

Referenced by Apply(), applyPropertyResolutions(), and GetReport().

◆ m_theirs

const SCHEMATIC* KICAD_DIFF::SCH_MERGE_APPLIER::m_theirs
private

Definition at line 125 of file sch_merge_applier.h.

Referenced by Apply(), and SCH_MERGE_APPLIER().


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