KiCad PCB EDA Suite
Loading...
Searching...
No Matches
lib_element_diff.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 LIB_ELEMENT_DIFF_H
22#define LIB_ELEMENT_DIFF_H
23
25
26#include <functional>
27#include <map>
28#include <vector>
29#include <wx/string.h>
30
31
32class EDA_ITEM;
33
34
35namespace KICAD_DIFF
36{
37
40{
41 const EDA_ITEM* item; // after-side item, or before-side for REMOVED
42 wxString typeName;
43 wxString key; // pin number or field name, empty for unkeyed elements
44 CHANGE_KIND kind; // ADDED, REMOVED or MODIFIED
45 std::vector<PROPERTY_DELTA> deltas;
46};
47
49void DiffKeyedElements( std::vector<LIB_ELEMENT>& aOut, const wxString& aTypeName,
50 const std::map<wxString, const EDA_ITEM*>& aBefore,
51 const std::map<wxString, const EDA_ITEM*>& aAfter );
52
58void DiffUnkeyedElements( std::vector<LIB_ELEMENT>& aOut, const std::vector<const EDA_ITEM*>& aBefore,
59 const std::vector<const EDA_ITEM*>& aAfter,
60 const std::function<wxString( const EDA_ITEM* )>& aTypeName,
61 const std::function<bool( const EDA_ITEM*, const EDA_ITEM* )>& aSameGeometry = {} );
62
64void AppendElementChanges( ITEM_CHANGE& aChange, const std::vector<LIB_ELEMENT>& aElements );
65
66} // namespace KICAD_DIFF
67
68#endif // LIB_ELEMENT_DIFF_H
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
CHANGE_KIND
Coarse classification of a single item-level change between two documents.
void DiffKeyedElements(std::vector< LIB_ELEMENT > &aOut, const wxString &aTypeName, const std::map< wxString, const EDA_ITEM * > &aBefore, const std::map< wxString, const EDA_ITEM * > &aAfter)
Elements that are matched by a key, such as pins by number or fields by name.
void AppendElementChanges(ITEM_CHANGE &aChange, const std::vector< LIB_ELEMENT > &aElements)
Add each element to aChange as a child change, which is how a library item reports its elements.
void DiffUnkeyedElements(std::vector< LIB_ELEMENT > &aOut, const std::vector< const EDA_ITEM * > &aBefore, const std::vector< const EDA_ITEM * > &aAfter, const std::function< wxString(const EDA_ITEM *)> &aTypeName, const std::function< bool(const EDA_ITEM *, const EDA_ITEM *)> &aSameGeometry)
Elements with no key.
One changed element of a library item, such as a pin, pad, field or graphic.
std::vector< PROPERTY_DELTA > deltas