33#include <unordered_map>
54 NETNAMES_MAP::iterator it, itEnd;
76 return (*result).second;
87 return (*result).second;
99 if ( i->second == aNet )
109 if ( i->second == aNet )
111 wxASSERT_MSG( removed, wxT(
"NETINFO_LIST::RemoveNet: target net found in m_netNames "
112 "but not m_netCodes!" ) );
129 std::vector<NETINFO_ITEM*> unusedNets;
134 for(
const auto& [ netCode, netInfo ] : existingNets )
136 if( netInfo->IsCurrent() )
138 m_netNames.insert( std::make_pair( netInfo->GetNetname(), netInfo ) );
139 m_netCodes.insert( std::make_pair( netCode, netInfo ) );
157 if( sameName !=
nullptr )
188 std::unordered_map<int, wxString> preservedNetChains;
189 std::unordered_map<int, KIID> preservedPad0;
190 std::unordered_map<int, KIID> preservedPad1;
209 auto it = preservedNetChains.find( net->
GetNetCode() );
210 if( it != preservedNetChains.end() )
213 auto ip0 = preservedPad0.find( net->
GetNetCode() );
214 if( ip0 != preservedPad0.end() )
217 auto ip1 = preservedPad1.find( net->
GetNetCode() );
218 if( ip1 != preservedPad1.end() )
222 m_parent->SynchronizeNetsAndNetClasses(
false );
223 m_parent->SetAreasNetCodesFromNetNames();
229 std::map<wxString, std::vector<wxString>> shortNameMap;
242 wxArrayString parts = wxSplit( net->
m_netname,
'/' );
243 std::vector<wxArrayString> aggregateParts;
244 std::optional<size_t> firstNonCommon;
246 for(
const wxString& longName : shortNameMap[net->
m_shortNetname] )
247 aggregateParts.push_back( wxSplit( longName,
'/' ) );
249 for(
size_t ii = 0; ii < parts.size() && !firstNonCommon; ++ii )
251 for(
const wxArrayString& otherParts : aggregateParts )
253 if( ii < otherParts.size() && otherParts[ii] == parts[ii] )
261 if( firstNonCommon.value_or( 0 ) > 0 && firstNonCommon.value() < parts.size() )
263 wxString disambiguatedName;
265 for(
size_t ii = firstNonCommon.value(); ii < parts.size(); ++ii )
267 if( !disambiguatedName.IsEmpty() )
268 disambiguatedName += wxS(
"/" );
270 disambiguatedName += parts[ii];
287void NETINFO_LIST::Show()
const
290 NETNAMES_MAP::const_iterator it, itEnd;
294 wxLogDebug( wxT(
"[%d]: netcode:%d netname:<%s>\n" ),
296 it->second->GetNetCode(),
297 TO_UTF8( it->second->GetNetname() ) );
COMMIT & Removed(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Handle the data for a net.
wxString m_shortNetname
Short net name, like vout from /sheet/subsheet/vout.
const wxString & GetNetChain() const
const KIID & GetTerminalPadUuid(int aIndex) const
wxString m_displayNetname
Unescaped netname for display.
const wxString & GetNetname() const
void Clear()
Set all fields to their default values.
void SetTerminalPadUuid(int aIndex, const KIID &aUuid)
int m_netCode
A number equivalent to the net name.
void SetNetChain(const wxString &aNetChain)
wxString m_netname
Full net name like /sheet/subsheet/vout used by Eeschema.
int getFreeNetCode()
Return the first available net code that is not used by any other net.
void RemoveUnusedNets(BOARD_COMMIT *aCommit)
static const int UNCONNECTED
Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are ...
NETCODES_MAP m_netCodes
map of <int, NETINFO_ITEM*> is NOT owner
static const int ORPHANED
Constant that forces initialization of a netinfo item to the NETINFO_ITEM ORPHANED (typically -1) whe...
int m_newNetCode
possible value for new net code assignment
unsigned GetNetCount() const
void detachAll()
Drop all entries from the lookup maps without freeing the items.
void RemoveNet(NETINFO_ITEM *aNet)
Remove a net from the net list.
NETINFO_ITEM * GetNetItem(int aNetCode) const
NETINFO_LIST(BOARD *aParent)
void clear()
Delete the list of nets (and free memory).
NETNAMES_MAP m_netNames
map of <wxString, NETINFO_ITEM*>, is NETINFO_ITEM owner
void AppendNet(NETINFO_ITEM *aNewElement)
Add aNewElement to the end of the net list.
bool m_DisplayNetnamesDirty
void RebuildDisplayNetnames() const
void buildListOfNets()
Rebuild the list of NETINFO_ITEMs.
This file contains miscellaneous commonly used macros and functions.
std::map< int, NETINFO_ITEM * > NETCODES_MAP
wxString UnescapeString(const wxString &aSource)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
wxString result
Test unit parsing edge cases and error handling.