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

Materialize a MERGE_PLAN into a real merged BOARD. More...

#include <pcb_merge_applier.h>

Classes

struct  REPORT
 Report on the application after Apply() runs. More...
 

Public Member Functions

 PCB_MERGE_APPLIER (const BOARD *aAncestor, const BOARD *aOurs, const BOARD *aTheirs, MERGE_PLAN aPlan)
 
std::unique_ptr< BOARDApply ()
 Produce the merged board.
 
const REPORTGetReport () const
 

Private Member Functions

const BOARD_ITEMfindItem (const BOARD *aBoard, const KIID &aId) const
 Locate an item (top-level or footprint child) by UUID on one of the source boards.
 
BOARD_ITEMcloneInto (BOARD *aTarget, const BOARD_ITEM *aSource) const
 Clone a board item using its virtual Clone(); returns nullptr if the source is null, the clone fails, or BOARD::Add() rejects the item.
 
std::size_t applyPropertyResolutions (BOARD_ITEM *aTarget, const std::vector< PROPERTY_RESOLUTION > &aProps, const BOARD_ITEM *aOurs, const BOARD_ITEM *aTheirs, const BOARD_ITEM *aAncestor)
 Apply property-level resolutions to a clone of aOurs (or aTheirs per PROP_RES).
 

Private Attributes

const BOARDm_ancestor
 
const BOARDm_ours
 
const BOARDm_theirs
 
MERGE_PLAN m_plan
 
REPORT m_report
 

Detailed Description

Materialize a MERGE_PLAN into a real merged BOARD.

Construction takes the three input boards (ancestor, ours, theirs) by reference and a plan. Apply() produces a new BOARD that owns its items; the input boards are never mutated.

Resolution semantics:

  • TAKE_OURS / TAKE_THEIRS / TAKE_ANCESTOR: clone the chosen side's item into the result with the same KIID.
  • DELETE: skip the item entirely (no record in the result).
  • KEEP: clone ancestor's item; used for "conservatively conflicted" items where the plan flagged unresolved.
  • MERGE_PROPS: clone ours's item as the starting point, then apply each PROPERTY_RESOLUTION via PROPERTY_MANAGER::SetValue. Properties not in the resolution list are inherited from ours.

Items that exist on no side, or are listed in the plan with no surviving source, are silently dropped.

The applier never invents item state. If a MERGE_PROPS resolution references a property that cannot be set (read-only, hidden, missing on the target), the property is left at the OURS value and the failure is logged via wxLogTrace( traceDiffMerge ).

The plan is stored by value so a temporary engine.Plan(...) result is safe to pass into the constructor.

Definition at line 67 of file pcb_merge_applier.h.

Constructor & Destructor Documentation

◆ PCB_MERGE_APPLIER()

KICAD_DIFF::PCB_MERGE_APPLIER::PCB_MERGE_APPLIER ( const BOARD * aAncestor,
const BOARD * aOurs,
const BOARD * aTheirs,
MERGE_PLAN aPlan )

Definition at line 50 of file pcb_merge_applier.cpp.

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

Member Function Documentation

◆ Apply()

std::unique_ptr< BOARD > KICAD_DIFF::PCB_MERGE_APPLIER::Apply ( )

Produce the merged board.

Returns a unique_ptr; on null indicates a fatal application error (currently only "no input boards").

Definition at line 115 of file pcb_merge_applier.cpp.

References FOOTPRINT::Add(), KICAD_DIFF::VALIDATION_INPUT::ancestorSchemaVersion, APPEND, KICAD_DIFF::VALIDATION_INPUT::applierReportedRebuild, applyPropertyResolutions(), EDA_ITEM::Clone(), cloneInto(), KICAD_DIFF::CollectTopLevelIds(), KICAD_DIFF::DELETE_ITEM, FILEEXT::DesignRulesFileExtension, KICAD_DIFF::DOC_PROP_BOARD_THICKNESS, KICAD_DIFF::DOC_PROP_CUSTOM_RULES, KICAD_DIFF::DOC_PROP_DRAWING_SHEET, KICAD_DIFF::DOC_PROP_DRC_SEVERITIES, KICAD_DIFF::DOC_PROP_FP_LIB_TABLE, KICAD_DIFF::DOC_PROP_LAYER_STACKUP, KICAD_DIFF::DOC_PROP_NET_CLASSES, KICAD_DIFF::DOC_PROP_PAGE_FORMAT, KICAD_DIFF::DOC_PROP_PAGE_ORIENTATION, KICAD_DIFF::DOC_PROP_SYM_LIB_TABLE, findItem(), KICAD_DIFF::FOOTPRINT, FILEEXT::FootprintLibraryTableFileName, BOARD_DESIGN_SETTINGS::GetBoardThickness(), BOARD::GetDesignSettings(), FOOTPRINT::GetFields(), BOARD::GetFileName(), BOARD::GetPageSettings(), BOARD::GetProject(), PROJECT::GetProjectFile(), BOARD_DESIGN_SETTINGS::GetStackupDescriptor(), PAGE_INFO::GetType(), FOOTPRINT::GraphicalItems(), KICAD_DIFF::ITEM_RESOLUTION::id, KICAD_DIFF::REFDES_ENTRY::id, PAGE_INFO::IsPortrait(), KICAD_DIFF::KEEP, KICAD_DIFF::ITEM_RESOLUTION::kind, KICAD_DIFF::PROPERTY_RESOLUTION::kind, m_ancestor, PROJECT_FILE::m_BoardDrawingSheetFile, BOARD_DESIGN_SETTINGS::m_DRCSeverities, BOARD_DESIGN_SETTINGS::m_NetSettings, m_ours, m_plan, m_report, m_theirs, KICAD_DIFF::MERGE_PROPS, KICAD_DIFF::PROPERTY_RESOLUTION::name, KICAD_DIFF::OURS, KICAD_DIFF::VALIDATION_INPUT::oursSchemaVersion, pad, FOOTPRINT::Pads(), path, KICAD_DIFF::VALIDATION_INPUT::planRequiredRebuild, KICAD_DIFF::ITEM_RESOLUTION::props, KICAD_DIFF::REFDES_ENTRY::refdes, KICAD_DIFF::VALIDATION_INPUT::refdesEntries, FOOTPRINT::Remove(), res, result, KICAD_DIFF::RunPostApplyValidators(), PAGE_INFO::SetPortrait(), PAGE_INFO::SetType(), FILEEXT::SymbolLibraryTableFileName, KICAD_DIFF::TAKE_ANCESTOR, KICAD_DIFF::TAKE_OURS, KICAD_DIFF::TAKE_THEIRS, KICAD_DIFF::THEIRS, KICAD_DIFF::VALIDATION_INPUT::theirsSchemaVersion, and FOOTPRINT::Zones().

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(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), KIGIT_PCB_MERGE::Merge(), and PCBNEW_JOBS_HANDLER::runPcbMerge().

◆ applyPropertyResolutions()

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

Apply property-level resolutions to a clone of aOurs (or aTheirs per PROP_RES).

Returns the number of properties successfully applied.

Definition at line 99 of file pcb_merge_applier.cpp.

References KICAD_DIFF::PROPERTY_APPLY_COUNTS::applied, KICAD_DIFF::ApplyPropertyResolutions(), KICAD_DIFF::PROPERTY_APPLY_COUNTS::failed, and m_report.

Referenced by Apply().

◆ cloneInto()

BOARD_ITEM * KICAD_DIFF::PCB_MERGE_APPLIER::cloneInto ( BOARD * aTarget,
const BOARD_ITEM * aSource ) const
private

Clone a board item using its virtual Clone(); returns nullptr if the source is null, the clone fails, or BOARD::Add() rejects the item.

Definition at line 73 of file pcb_merge_applier.cpp.

References BOARD::Add(), APPEND, and EDA_ITEM::Clone().

Referenced by Apply().

◆ findItem()

const BOARD_ITEM * KICAD_DIFF::PCB_MERGE_APPLIER::findItem ( const BOARD * aBoard,
const KIID & aId ) const
private

Locate an item (top-level or footprint child) by UUID on one of the source boards.

Delegates to BOARD::ResolveItem, which maintains its own KIID->item cache and resolves footprint children under their own UUIDs.

Definition at line 59 of file pcb_merge_applier.cpp.

References BOARD::ResolveItem().

Referenced by Apply().

◆ GetReport()

Member Data Documentation

◆ m_ancestor

const BOARD* KICAD_DIFF::PCB_MERGE_APPLIER::m_ancestor
private

Definition at line 166 of file pcb_merge_applier.h.

Referenced by Apply(), and PCB_MERGE_APPLIER().

◆ m_ours

const BOARD* KICAD_DIFF::PCB_MERGE_APPLIER::m_ours
private

Definition at line 167 of file pcb_merge_applier.h.

Referenced by Apply(), and PCB_MERGE_APPLIER().

◆ m_plan

MERGE_PLAN KICAD_DIFF::PCB_MERGE_APPLIER::m_plan
private

Definition at line 169 of file pcb_merge_applier.h.

Referenced by Apply(), and PCB_MERGE_APPLIER().

◆ m_report

REPORT KICAD_DIFF::PCB_MERGE_APPLIER::m_report
private

Definition at line 170 of file pcb_merge_applier.h.

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

◆ m_theirs

const BOARD* KICAD_DIFF::PCB_MERGE_APPLIER::m_theirs
private

Definition at line 168 of file pcb_merge_applier.h.

Referenced by Apply(), and PCB_MERGE_APPLIER().


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