KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pin_map.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 modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include <kicommon.h>
23#include <lib_id.h>
24
25#include <nlohmann/json_fwd.hpp>
26
27#include <unordered_map>
28#include <vector>
29#include <wx/string.h>
30
31
41{
42 wxString m_PinNumber;
43 wxString m_PadNumber;
44
45 bool operator==( const PIN_MAP_ENTRY& aOther ) const
46 {
47 return m_PinNumber == aOther.m_PinNumber && m_PadNumber == aOther.m_PadNumber;
48 }
49};
50
51
64{
65public:
66 PIN_MAP() = default;
67 explicit PIN_MAP( const wxString& aName );
68
69 const wxString& GetName() const { return m_name; }
70 void SetName( const wxString& aName ) { m_name = aName; }
71
76 void SetEntry( const wxString& aPinNumber, const wxString& aPadNumber );
77
81 void ClearEntry( const wxString& aPinNumber );
82
83 bool HasEntry( const wxString& aPinNumber ) const;
84
89 const wxString& GetPadNumber( const wxString& aPinNumber ) const;
90
91 const std::vector<PIN_MAP_ENTRY>& GetEntries() const { return m_entries; }
92
93 bool IsEmpty() const { return m_entries.empty(); }
94
102 bool IsIdentity( const std::vector<wxString>& aPinNumbers ) const;
103
104 bool operator==( const PIN_MAP& aOther ) const;
105
106private:
107 std::vector<PIN_MAP_ENTRY>::iterator findEntry( const wxString& aPinNumber );
108 std::vector<PIN_MAP_ENTRY>::const_iterator findEntry( const wxString& aPinNumber ) const;
109
110 wxString m_name;
111 std::vector<PIN_MAP_ENTRY> m_entries;
112};
113
114
123{
124public:
128 void AddOrReplace( PIN_MAP aMap );
129
133 void Remove( const wxString& aName );
134
135 const PIN_MAP* FindByName( const wxString& aName ) const;
136 PIN_MAP* FindByName( const wxString& aName );
137
138 const std::vector<PIN_MAP>& GetAll() const { return m_maps; }
139 bool IsEmpty() const { return m_maps.empty(); }
140
141 bool operator==( const PIN_MAP_SET& aOther ) const { return m_maps == aOther.m_maps; }
142 bool operator!=( const PIN_MAP_SET& aOther ) const { return !( *this == aOther ); }
143
144private:
145 std::vector<PIN_MAP> m_maps; // ordered for stable file output
146};
147
148
158{
160 wxString m_MapName;
161
162 bool operator==( const ASSOCIATED_FOOTPRINT& aOther ) const
163 {
164 return m_FootprintLibId == aOther.m_FootprintLibId && m_MapName == aOther.m_MapName;
165 }
166};
167
168
183
184
199{
202 std::vector<PIN_MAP_ENTRY> m_Edits;
203
209 bool IsDefault() const
210 {
212 }
213
219
220 bool operator==( const PIN_MAP_INSTANCE_OVERRIDE& aOther ) const
221 {
222 return m_Mode == aOther.m_Mode && m_ActiveMapName == aOther.m_ActiveMapName
223 && m_Edits == aOther.m_Edits;
224 }
225
226 bool operator!=( const PIN_MAP_INSTANCE_OVERRIDE& aOther ) const { return !( *this == aOther ); }
227};
228
229
238 const wxString& aName,
239 const std::unordered_map<wxString, std::vector<wxString>>& aAssignments );
240
241
249KICOMMON_API std::unordered_map<wxString, std::vector<wxString>>
250ParseLegacyPinAssignments( const nlohmann::json& aArray );
251
258KICOMMON_API PIN_MAP_SET ParsePinMapSet( const nlohmann::json& aParent );
259
266KICOMMON_API std::vector<ASSOCIATED_FOOTPRINT>
267ParseAssociatedFootprints( const nlohmann::json& aParent );
bool operator==(const wxAuiPaneInfo &aLhs, const wxAuiPaneInfo &aRhs)
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:45
A symbol-owned ordered set of named pin maps.
Definition pin_map.h:123
bool IsEmpty() const
Definition pin_map.h:139
const std::vector< PIN_MAP > & GetAll() const
Definition pin_map.h:138
void AddOrReplace(PIN_MAP aMap)
Insert aMap, replacing any existing entry with the same name.
Definition pin_map.cpp:113
void Remove(const wxString &aName)
Remove the map with the given name.
Definition pin_map.cpp:122
bool operator!=(const PIN_MAP_SET &aOther) const
Definition pin_map.h:142
const PIN_MAP * FindByName(const wxString &aName) const
Definition pin_map.cpp:133
bool operator==(const PIN_MAP_SET &aOther) const
Definition pin_map.h:141
std::vector< PIN_MAP > m_maps
Definition pin_map.h:145
A named pin map.
Definition pin_map.h:64
PIN_MAP()=default
void SetName(const wxString &aName)
Definition pin_map.h:70
const std::vector< PIN_MAP_ENTRY > & GetEntries() const
Definition pin_map.h:91
const wxString & GetName() const
Definition pin_map.h:69
bool IsEmpty() const
Definition pin_map.h:93
wxString m_name
Definition pin_map.h:110
std::vector< PIN_MAP_ENTRY > m_entries
Definition pin_map.h:111
#define KICOMMON_API
Definition kicommon.h:27
KICOMMON_API PIN_MAP_SET ParsePinMapSet(const nlohmann::json &aParent)
Parse the spec-form named maps from aParent["pin_maps"] into a PIN_MAP_SET (issue #2282).
Definition pin_map.cpp:221
KICOMMON_API std::unordered_map< wxString, std::vector< wxString > > ParseLegacyPinAssignments(const nlohmann::json &aArray)
Parse the legacy flat pin-assignment JSON array (MR !2540 form) into a symbol-pin to footprint-pad(s)...
Definition pin_map.cpp:187
PIN_MAP_OVERRIDE_MODE
Override mode stored on a SCH_SYMBOL_INSTANCE.
Definition pin_map.h:177
KICOMMON_API std::vector< ASSOCIATED_FOOTPRINT > ParseAssociatedFootprints(const nlohmann::json &aParent)
Parse the spec-form footprint associations from aParent["associated_footprints"] (issue #2282).
Definition pin_map.cpp:254
KICOMMON_API PIN_MAP MakeLegacyPinMap(const wxString &aName, const std::unordered_map< wxString, std::vector< wxString > > &aAssignments)
Build a single named PIN_MAP from a legacy symbol-pin to footprint-pad(s) assignment table (the flat ...
Definition pin_map.cpp:151
A first-class footprint choice on a LIB_SYMBOL, tied to a named pin map.
Definition pin_map.h:158
bool operator==(const ASSOCIATED_FOOTPRINT &aOther) const
Definition pin_map.h:162
LIB_ID m_FootprintLibId
Definition pin_map.h:159
One symbol-pin to footprint-pad mapping inside a PIN_MAP.
Definition pin_map.h:41
bool operator==(const PIN_MAP_ENTRY &aOther) const
Definition pin_map.h:45
wxString m_PadNumber
Definition pin_map.h:43
wxString m_PinNumber
Definition pin_map.h:42
Per-instance override of the active pin map and a sparse delta on top.
Definition pin_map.h:199
bool operator==(const PIN_MAP_INSTANCE_OVERRIDE &aOther) const
Definition pin_map.h:220
std::vector< PIN_MAP_ENTRY > m_Edits
Definition pin_map.h:202
bool operator!=(const PIN_MAP_INSTANCE_OVERRIDE &aOther) const
Definition pin_map.h:226
bool IsDefault() const
Definition pin_map.h:209
PIN_MAP_OVERRIDE_MODE m_Mode
Definition pin_map.h:200
bool IsDelegate() const
Definition pin_map.h:218