KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_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 SCH_DIFFER_H
22#define SCH_DIFFER_H
23
25
26#include <wx/string.h>
27
28
29class SCHEMATIC;
30class SCH_ITEM;
31class SCH_SHEET_PATH;
32
33
34namespace KICAD_DIFF
35{
36
55{
56public:
57 SCH_DIFFER( const SCHEMATIC* aBefore, const SCHEMATIC* aAfter,
58 const wxString& aPath = wxEmptyString );
59 ~SCH_DIFFER() override;
60
64 void SetScope( const KIID_PATH& aBeforeScope, const KIID_PATH& aAfterScope );
65
66 DOCUMENT_DIFF Diff() override;
67
68 const SCHEMATIC* Before() const { return m_before; }
69 const SCHEMATIC* After() const { return m_after; }
70
71private:
73 {
75 const SCH_ITEM* item;
76 SCH_SHEET_PATH* sheetPath; // raw pointer into m_pathStorage
77 };
78
83 void walk( const SCHEMATIC* aSchematic, std::vector<WalkedItem>& aOut,
84 std::vector<std::unique_ptr<SCH_SHEET_PATH>>& aStorage, const KIID_PATH& aScope = {} ) const;
85
92 std::vector<PROPERTY_DELTA> diffProperties( const SCH_ITEM* aBefore,
93 const SCH_ITEM* aAfter,
94 const SCH_SHEET_PATH* aBeforePath,
95 const SCH_SHEET_PATH* aAfterPath ) const;
96
98 static wxString itemTypeName( const SCH_ITEM* aItem );
99
101 static std::optional<wxString> itemRefdes( const SCH_ITEM* aItem,
102 const SCH_SHEET_PATH* aPath );
103
104 static void sortChanges( std::vector<ITEM_CHANGE>& aChanges );
105
106private:
109 wxString m_path;
112};
113
114} // namespace KICAD_DIFF
115
116#endif // SCH_DIFFER_H
const SCHEMATIC * m_after
Definition sch_differ.h:108
static std::optional< wxString > itemRefdes(const SCH_ITEM *aItem, const SCH_SHEET_PATH *aPath)
Refdes if the item is a symbol; nullopt otherwise.
static wxString itemTypeName(const SCH_ITEM *aItem)
Type name for an SCH_ITEM (used in diff records).
void SetScope(const KIID_PATH &aBeforeScope, const KIID_PATH &aAfterScope)
Restrict the diff to one sheet on each side.
const SCHEMATIC * m_before
Definition sch_differ.h:107
SCH_DIFFER(const SCHEMATIC *aBefore, const SCHEMATIC *aAfter, const wxString &aPath=wxEmptyString)
static void sortChanges(std::vector< ITEM_CHANGE > &aChanges)
std::vector< PROPERTY_DELTA > diffProperties(const SCH_ITEM *aBefore, const SCH_ITEM *aAfter, const SCH_SHEET_PATH *aBeforePath, const SCH_SHEET_PATH *aAfterPath) const
Property-level delta via PROPERTY_MANAGER.
const SCHEMATIC * After() const
Definition sch_differ.h:69
DOCUMENT_DIFF Diff() override
Produce a DOCUMENT_DIFF of the inputs the concrete differ was constructed with.
void walk(const SCHEMATIC *aSchematic, std::vector< WalkedItem > &aOut, std::vector< std::unique_ptr< SCH_SHEET_PATH > > &aStorage, const KIID_PATH &aScope={}) const
Walk a schematic and produce a flat list of (KIID_PATH, item) tuples.
const SCHEMATIC * Before() const
Definition sch_differ.h:68
Holds all the data relating to one schematic.
Definition schematic.h:90
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:162
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
The full set of changes between two parsed documents of one type.