KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_differ.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 3
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/gpl-3.0.html
19 */
20
21#ifndef PCB_DIFFER_H
22#define PCB_DIFFER_H
23
26
27#include <wx/string.h>
28
29
30class BOARD;
31class BOARD_ITEM;
32class FOOTPRINT;
33
34
35namespace KICAD_DIFF
36{
37
52{
53public:
54 PCB_DIFFER( const BOARD* aBefore, const BOARD* aAfter, const wxString& aPath = wxEmptyString );
55 ~PCB_DIFFER() override;
56
57 DOCUMENT_DIFF Diff() override;
58
61 const BOARD* Before() const { return m_before; }
62 const BOARD* After() const { return m_after; }
63
64private:
68 std::vector<PROPERTY_DELTA> diffProperties( const BOARD_ITEM* aBefore, const BOARD_ITEM* aAfter ) const;
69
71 ITEM_DESCRIPTOR makeDescriptor( const BOARD_ITEM* aItem ) const;
72
74 std::vector<ITEM_CHANGE> diffFootprintChildren( const FOOTPRINT* aBefore, const FOOTPRINT* aAfter ) const;
75
77 static void sortChanges( std::vector<ITEM_CHANGE>& aChanges );
78
80 static wxString itemTypeName( const BOARD_ITEM* aItem );
81
83 static std::optional<wxString> itemRefdes( const BOARD_ITEM* aItem );
84
85private:
87 const BOARD* m_after;
88 wxString m_path;
89};
90
91} // namespace KICAD_DIFF
92
93#endif // PCB_DIFFER_H
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:80
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:320
const BOARD * m_after
Definition pcb_differ.h:87
static void sortChanges(std::vector< ITEM_CHANGE > &aChanges)
Stable, deterministic sort of ITEM_CHANGEs (by id, then typeName, then kind).
const BOARD * m_before
Definition pcb_differ.h:86
PCB_DIFFER(const BOARD *aBefore, const BOARD *aAfter, const wxString &aPath=wxEmptyString)
const BOARD * Before() const
Expose the underlying boards for callers that want to drive their own walk (e.g., the merge applier r...
Definition pcb_differ.h:61
std::vector< ITEM_CHANGE > diffFootprintChildren(const FOOTPRINT *aBefore, const FOOTPRINT *aAfter) const
Construct a child-level diff for nested items inside a footprint pair.
DOCUMENT_DIFF Diff() override
Produce a DOCUMENT_DIFF of the inputs the concrete differ was constructed with.
static std::optional< wxString > itemRefdes(const BOARD_ITEM *aItem)
Extract a presentation label: footprint refdes, or routing net name for tracks/vias.
std::vector< PROPERTY_DELTA > diffProperties(const BOARD_ITEM *aBefore, const BOARD_ITEM *aAfter) const
Compute property deltas between two items of the same dynamic type.
static wxString itemTypeName(const BOARD_ITEM *aItem)
Convert the dynamic class string for an item into the type name used in diffs.
const BOARD * After() const
Definition pcb_differ.h:62
ITEM_DESCRIPTOR makeDescriptor(const BOARD_ITEM *aItem) const
Build the ITEM_DESCRIPTOR for the reconciler from a BOARD_ITEM.
The full set of changes between two parsed documents of one type.
Descriptor used by the identity reconciler to compare items across two documents.