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

Reconciles item identity across two snapshots of the same document. More...

#include <identity_reconciler.h>

Classes

struct  CONFIG
 

Public Member Functions

 IDENTITY_RECONCILER ()=default
 
 IDENTITY_RECONCILER (const CONFIG &aConfig)
 
const CONFIGGetConfig () const
 
void SetConfig (const CONFIG &aConfig)
 
RECONCILIATION Reconcile (const std::vector< ITEM_DESCRIPTOR > &aA, const std::vector< ITEM_DESCRIPTOR > &aB) const
 
double ScoreSimilarity (const ITEM_DESCRIPTOR &aA, const ITEM_DESCRIPTOR &aB) const
 Compute the similarity score between two items of the same type.
 

Private Attributes

CONFIG m_config
 

Detailed Description

Reconciles item identity across two snapshots of the same document.

Primary key is KIID_PATH. Items with the same KIID_PATH on both sides are matched directly. Items that exist only on one side are then candidates for similarity matching — useful when UUIDs churn from imports, copy-paste, or third-party tools rewriting identifiers.

Similarity score is 0..1 and combines:

  • position equality (weight 0.40)
  • bbox equality (weight 0.20)
  • keyProp matches (weight up to 0.40, prorated)

Items with score >= threshold are matched; ties prefer the closest position. A given B item is matched at most once (greedy by best score; deterministic order).

Definition at line 96 of file identity_reconciler.h.

Constructor & Destructor Documentation

◆ IDENTITY_RECONCILER() [1/2]

KICAD_DIFF::IDENTITY_RECONCILER::IDENTITY_RECONCILER ( )
default

◆ IDENTITY_RECONCILER() [2/2]

KICAD_DIFF::IDENTITY_RECONCILER::IDENTITY_RECONCILER ( const CONFIG & aConfig)
inlineexplicit

Definition at line 108 of file identity_reconciler.h.

References m_config.

Member Function Documentation

◆ GetConfig()

const CONFIG & KICAD_DIFF::IDENTITY_RECONCILER::GetConfig ( ) const
inline

Definition at line 110 of file identity_reconciler.h.

References m_config.

Referenced by BOOST_AUTO_TEST_CASE().

◆ Reconcile()

◆ ScoreSimilarity()

double KICAD_DIFF::IDENTITY_RECONCILER::ScoreSimilarity ( const ITEM_DESCRIPTOR & aA,
const ITEM_DESCRIPTOR & aB ) const

Compute the similarity score between two items of the same type.

Exposed publicly so per-document differs can tune the threshold against representative fixtures.

Definition at line 100 of file identity_reconciler.cpp.

References KICAD_DIFF::ITEM_DESCRIPTOR::bbox, KICAD_DIFF::ITEM_DESCRIPTOR::keyProps, m_config, KICAD_DIFF::ITEM_DESCRIPTOR::position, and KICAD_DIFF::ITEM_DESCRIPTOR::type.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and Reconcile().

◆ SetConfig()

void KICAD_DIFF::IDENTITY_RECONCILER::SetConfig ( const CONFIG & aConfig)
inline

Definition at line 111 of file identity_reconciler.h.

References m_config.

Referenced by BOOST_AUTO_TEST_CASE().

Member Data Documentation

◆ m_config

CONFIG KICAD_DIFF::IDENTITY_RECONCILER::m_config
private

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