37#include <unordered_map>
58 NETNAMES_MAP::iterator it, itEnd;
80 return (*result).second;
91 return (*result).second;
103 if ( i->second == aNet )
113 if ( i->second == aNet )
115 wxASSERT_MSG( removed, wxT(
"NETINFO_LIST::RemoveNet: target net found in m_netNames "
116 "but not m_netCodes!" ) );
133 std::vector<NETINFO_ITEM*> unusedNets;
138 for(
const auto& [ netCode, netInfo ] : existingNets )
140 if( netInfo->IsCurrent() )
142 m_netNames.insert( std::make_pair( netInfo->GetNetname(), netInfo ) );
143 m_netCodes.insert( std::make_pair( netCode, netInfo ) );
161 if( sameName !=
nullptr )
192 std::unordered_map<int, wxString> preservedNetChains;
193 std::unordered_map<int, KIID> preservedPad0;
194 std::unordered_map<int, KIID> preservedPad1;
213 auto it = preservedNetChains.find( net->
GetNetCode() );
214 if( it != preservedNetChains.end() )
217 auto ip0 = preservedPad0.find( net->
GetNetCode() );
218 if( ip0 != preservedPad0.end() )
221 auto ip1 = preservedPad1.find( net->
GetNetCode() );
222 if( ip1 != preservedPad1.end() )
226 m_parent->SynchronizeNetsAndNetClasses(
false );
227 m_parent->SetAreasNetCodesFromNetNames();
233 std::map<wxString, std::vector<wxString>> shortNameMap;
246 wxArrayString parts = wxSplit( net->
m_netname,
'/' );
247 std::vector<wxArrayString> aggregateParts;
248 std::optional<size_t> firstNonCommon;
250 for(
const wxString& longName : shortNameMap[net->
m_shortNetname] )
251 aggregateParts.push_back( wxSplit( longName,
'/' ) );
253 for(
size_t ii = 0; ii < parts.size() && !firstNonCommon; ++ii )
255 for(
const wxArrayString& otherParts : aggregateParts )
257 if( ii < otherParts.size() && otherParts[ii] == parts[ii] )
265 if( firstNonCommon.value_or( 0 ) > 0 && firstNonCommon.value() < parts.size() )
267 wxString disambiguatedName;
269 for(
size_t ii = firstNonCommon.value(); ii < parts.size(); ++ii )
271 if( !disambiguatedName.IsEmpty() )
272 disambiguatedName += wxS(
"/" );
274 disambiguatedName += parts[ii];
291void NETINFO_LIST::Show()
const
294 NETNAMES_MAP::const_iterator it, itEnd;
298 wxLogDebug( wxT(
"[%d]: netcode:%d netname:<%s>\n" ),
300 it->second->GetNetCode(),
301 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.