KiCad PCB EDA Suite
NETINFO_LIST Class Reference

NETINFO_LIST is a container class for NETINFO_ITEM elements, which are the nets. More...

#include <netinfo.h>

Classes

class  iterator
 

Wrapper class, so you can iterate through NETINFO_ITEM*s, not std::pair<int/wxString, NETINFO_ITEM*>

More...
 

Public Member Functions

 NETINFO_LIST (BOARD *aParent)
 
 ~NETINFO_LIST ()
 
NETINFO_ITEMGetNetItem (int aNetCode) const
 Function GetItem. More...
 
NETINFO_ITEMGetNetItem (const wxString &aNetName) const
 Function GetItem. More...
 
unsigned GetNetCount () const
 Function GetNetCount. More...
 
void AppendNet (NETINFO_ITEM *aNewElement)
 Function AppendNet adds aNewElement to the end of the net list. More...
 
void RemoveNet (NETINFO_ITEM *aNet)
 Function RemoveNet Removes a new from the net list. More...
 
const NETNAMES_MAP & NetsByName () const
 Function GetPadCount. More...
 
const NETCODES_MAP & NetsByNetcode () const
 Return the netcode map, at least for python. More...
 
iterator begin () const
 
iterator end () const
 
BOARDGetParent () const
 

Static Public Member Functions

static NETINFO_ITEMOrphanedItem ()
 

NETINFO_ITEM meaning that there was no net assigned for an item, as there was no board storing net list available.

More...
 

Static Public Attributes

static const int UNCONNECTED = 0
 

Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are actually not connected items

More...
 
static const int ORPHANED = -1
 

Constant that forces initialization of a netinfo item to the NETINFO_ITEM ORPHANED (typically -1) when calling SetNetCode od board connected items

More...
 

Private Member Functions

void clear ()
 Function clear deletes the list of nets (and free memory) More...
 
void buildListOfNets ()
 Function buildListOfNets builds or rebuilds the list of NETINFO_ITEMs The list is sorted by names. More...
 
int getFreeNetCode ()
 Function getFreeNetCode returns the first available net code that is not used by any other net. More...
 

Private Attributes

BOARDm_Parent
 
NETNAMES_MAP m_netNames
 map of <wxString, NETINFO_ITEM*>, is NETINFO_ITEM owner More...
 
NETCODES_MAP m_netCodes
 map of <int, NETINFO_ITEM*> is NOT owner More...
 
int m_newNetCode
 possible value for new net code assignment More...
 

Friends

class BOARD
 

Detailed Description

NETINFO_LIST is a container class for NETINFO_ITEM elements, which are the nets.

That makes this class a container for the nets.

Definition at line 407 of file netinfo.h.

Constructor & Destructor Documentation

◆ NETINFO_LIST()

NETINFO_LIST::NETINFO_LIST ( BOARD aParent)

Definition at line 38 of file netinfo_list.cpp.

38  : m_Parent( aParent )
39 {
40  // Make sure that the unconnected net has number 0
41  AppendNet( new NETINFO_ITEM( aParent, wxEmptyString, 0 ) );
42 
43  m_newNetCode = 0;
44 }
BOARD * m_Parent
Definition: netinfo.h:568
void AppendNet(NETINFO_ITEM *aNewElement)
Function AppendNet adds aNewElement to the end of the net list.
int m_newNetCode
possible value for new net code assignment
Definition: netinfo.h:573
NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:65

References AppendNet(), and m_newNetCode.

◆ ~NETINFO_LIST()

NETINFO_LIST::~NETINFO_LIST ( )

Definition at line 47 of file netinfo_list.cpp.

48 {
49  clear();
50 }
void clear()
Function clear deletes the list of nets (and free memory)

References clear().

Member Function Documentation

◆ AppendNet()

void NETINFO_LIST::AppendNet ( NETINFO_ITEM aNewElement)

Function AppendNet adds aNewElement to the end of the net list.

Negative net code means it is going to be auto-assigned.

Definition at line 111 of file netinfo_list.cpp.

112 {
113  // if there is a net with such name then just assign the correct number
114  NETINFO_ITEM* sameName = GetNetItem( aNewElement->GetNetname() );
115 
116  if( sameName != NULL )
117  {
118  aNewElement->m_NetCode = sameName->GetNet();
119 
120  return;
121  }
122  // be sure that net codes are consecutive
123  // negative net code means that it has to be auto assigned
124  else if( ( aNewElement->m_NetCode != (int) m_netCodes.size() ) || ( aNewElement->m_NetCode < 0 ) )
125  {
126  aNewElement->m_NetCode = getFreeNetCode();
127  }
128 
129  // net names & codes are supposed to be unique
130  assert( GetNetItem( aNewElement->GetNetname() ) == NULL );
131  assert( GetNetItem( aNewElement->GetNet() ) == NULL );
132 
133  // add an entry for fast look up by a net name using a map
134  m_netNames.insert( std::make_pair( aNewElement->GetNetname(), aNewElement ) );
135  m_netCodes.insert( std::make_pair( aNewElement->GetNet(), aNewElement ) );
136 }
NETNAMES_MAP m_netNames
map of <wxString, NETINFO_ITEM*>, is NETINFO_ITEM owner
Definition: netinfo.h:570
int getFreeNetCode()
Function getFreeNetCode returns the first available net code that is not used by any other net.
#define NULL
const wxString & GetNetname() const
Function GetNetname.
Definition: netinfo.h:231
int m_NetCode
A number equivalent to the net name.
Definition: netinfo.h:70
NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:65
int GetNet() const
Function GetNet.
Definition: netinfo.h:223
NETINFO_ITEM * GetNetItem(int aNetCode) const
Function GetItem.
NETCODES_MAP m_netCodes
map of <int, NETINFO_ITEM*> is NOT owner
Definition: netinfo.h:571

References getFreeNetCode(), NETINFO_ITEM::GetNet(), GetNetItem(), NETINFO_ITEM::GetNetname(), NETINFO_ITEM::m_NetCode, m_netCodes, m_netNames, and NULL.

Referenced by NET_SELECTOR_COMBOPOPUP::Accept(), BOARD::Add(), and NETINFO_LIST().

◆ begin()

iterator NETINFO_LIST::begin ( ) const
inline

Definition at line 532 of file netinfo.h.

533  {
534  return iterator( m_netNames.begin() );
535  }
NETNAMES_MAP m_netNames
map of <wxString, NETINFO_ITEM*>, is NETINFO_ITEM owner
Definition: netinfo.h:570

References m_netNames.

Referenced by BOARD::BeginNets(), buildListOfNets(), BOARD::SynchronizeNetsAndNetClasses(), and TestForExistingItem().

◆ buildListOfNets()

void NETINFO_LIST::buildListOfNets ( )
private

Function buildListOfNets builds or rebuilds the list of NETINFO_ITEMs The list is sorted by names.

Compute and update the net_codes for PADS et and equipots (.m_NetCode member) net_codes are >= 1 (net_code = 0 means not connected) Update the net buffer m_Pcb->m_NbNodes and m_Pcb->m_NbNets are updated Be aware NETINFO_ITEM* BOARD::FindNet( const wxString& aNetname ) when search a net by its net name does a binary search and expects to have a nets list sorted by an alphabetic case sensitive sort So do not change Build_Pads_Full_List() which build a sorted list of pads.

Definition at line 149 of file netinfo_list.cpp.

150 {
151  // Restore the initial state of NETINFO_ITEMs
152  for( NETINFO_LIST::iterator net( begin() ), netEnd( end() ); net != netEnd; ++net )
153  net->Clear();
154 
157 }
iterator end() const
Definition: netinfo.h:537
Wrapper class, so you can iterate through NETINFO_ITEM*s, not std::pair<int/wxString,...
Definition: netinfo.h:486
BOARD * m_Parent
Definition: netinfo.h:568
void SynchronizeNetsAndNetClasses()
Function SynchronizeNetsAndNetClasses copies NETCLASS info to each NET, based on NET membership in a ...
iterator begin() const
Definition: netinfo.h:532
int SetAreasNetCodesFromNetNames(void)
Function SetAreasNetCodesFromNetNames Set the .m_NetCode member of all copper areas,...

References begin(), end(), m_Parent, BOARD::SetAreasNetCodesFromNetNames(), and BOARD::SynchronizeNetsAndNetClasses().

Referenced by BOARD::BuildListOfNets().

◆ clear()

void NETINFO_LIST::clear ( )
private

Function clear deletes the list of nets (and free memory)

Definition at line 53 of file netinfo_list.cpp.

54 {
55  NETNAMES_MAP::iterator it, itEnd;
56  for( it = m_netNames.begin(), itEnd = m_netNames.end(); it != itEnd; ++it )
57  delete it->second;
58 
59  m_netNames.clear();
60  m_netCodes.clear();
61  m_newNetCode = 0;
62 }
NETNAMES_MAP m_netNames
map of <wxString, NETINFO_ITEM*>, is NETINFO_ITEM owner
Definition: netinfo.h:570
int m_newNetCode
possible value for new net code assignment
Definition: netinfo.h:573
NETCODES_MAP m_netCodes
map of <int, NETINFO_ITEM*> is NOT owner
Definition: netinfo.h:571

References m_netCodes, m_netNames, and m_newNetCode.

Referenced by ~NETINFO_LIST().

◆ end()

iterator NETINFO_LIST::end ( ) const
inline

Definition at line 537 of file netinfo.h.

538  {
539  return iterator( m_netNames.end() );
540  }
NETNAMES_MAP m_netNames
map of <wxString, NETINFO_ITEM*>, is NETINFO_ITEM owner
Definition: netinfo.h:570

References m_netNames.

Referenced by buildListOfNets(), BOARD::EndNets(), BOARD::SynchronizeNetsAndNetClasses(), and TestForExistingItem().

◆ getFreeNetCode()

int NETINFO_LIST::getFreeNetCode ( )
private

Function getFreeNetCode returns the first available net code that is not used by any other net.

Definition at line 175 of file netinfo_list.cpp.

176 {
177  do {
178  if( m_newNetCode < 0 )
179  m_newNetCode = 0;
180  } while( m_netCodes.count( ++m_newNetCode ) != 0 );
181 
182  return m_newNetCode;
183 }
int m_newNetCode
possible value for new net code assignment
Definition: netinfo.h:573
NETCODES_MAP m_netCodes
map of <int, NETINFO_ITEM*> is NOT owner
Definition: netinfo.h:571

References m_netCodes, and m_newNetCode.

Referenced by AppendNet().

◆ GetNetCount()

unsigned NETINFO_LIST::GetNetCount ( ) const
inline

Function GetNetCount.

Returns
the number of nets ( always >= 1 ) because the first net is the "not connected" net and always exists

Definition at line 434 of file netinfo.h.

434 { return m_netNames.size(); }
NETNAMES_MAP m_netNames
map of <wxString, NETINFO_ITEM*>, is NETINFO_ITEM owner
Definition: netinfo.h:570

References m_netNames.

Referenced by BOARD::FindNet(), BOARD::GetMsgPanelInfo(), BOARD::GetNetCount(), and BOARD::SortedNetnamesList().

◆ GetNetItem() [1/2]

NETINFO_ITEM * NETINFO_LIST::GetNetItem ( int  aNetCode) const

Function GetItem.

Parameters
aNetCode= netcode to identify a given NETINFO_ITEM
Returns
NETINFO_ITEM* - by aNetCode, or NULL if not found

Definition at line 65 of file netinfo_list.cpp.

66 {
67  NETCODES_MAP::const_iterator result = m_netCodes.find( aNetCode );
68 
69  if( result != m_netCodes.end() )
70  return (*result).second;
71 
72  return NULL;
73 }
#define NULL
NETCODES_MAP m_netCodes
map of <int, NETINFO_ITEM*> is NOT owner
Definition: netinfo.h:571

References m_netCodes, and NULL.

Referenced by NET_SELECTOR_COMBOPOPUP::Accept(), AppendNet(), BOARD::FindNet(), NET_SELECTOR_COMBOPOPUP::GetSelectedNetname(), NET_SELECTOR_COMBOPOPUP::GetStringValue(), and NET_SELECTOR_COMBOPOPUP::SetSelectedNet().

◆ GetNetItem() [2/2]

NETINFO_ITEM * NETINFO_LIST::GetNetItem ( const wxString &  aNetName) const

Function GetItem.

Parameters
aNetName= net name to identify a given NETINFO_ITEM
Returns
NETINFO_ITEM* - by aNetName, or NULL if not found

Definition at line 76 of file netinfo_list.cpp.

77 {
78  NETNAMES_MAP::const_iterator result = m_netNames.find( aNetName );
79 
80  if( result != m_netNames.end() )
81  return (*result).second;
82 
83  return NULL;
84 }
NETNAMES_MAP m_netNames
map of <wxString, NETINFO_ITEM*>, is NETINFO_ITEM owner
Definition: netinfo.h:570
#define NULL

References m_netNames, and NULL.

◆ GetParent()

BOARD* NETINFO_LIST::GetParent ( void  ) const
inline

Definition at line 543 of file netinfo.h.

544  {
545  return m_Parent;
546  }
BOARD * m_Parent
Definition: netinfo.h:568

References m_Parent.

Referenced by NET_SELECTOR_COMBOPOPUP::Accept().

◆ NetsByName()

const NETNAMES_MAP& NETINFO_LIST::NetsByName ( ) const
inline

Function GetPadCount.

Returns
the number of pads in boardReturn the name map, at least for python.

Definition at line 454 of file netinfo.h.

454 { return m_netNames; }
NETNAMES_MAP m_netNames
map of <wxString, NETINFO_ITEM*>, is NETINFO_ITEM owner
Definition: netinfo.h:570

◆ NetsByNetcode()

const NETCODES_MAP& NETINFO_LIST::NetsByNetcode ( ) const
inline

Return the netcode map, at least for python.

Definition at line 457 of file netinfo.h.

457 { return m_netCodes; }
NETCODES_MAP m_netCodes
map of <int, NETINFO_ITEM*> is NOT owner
Definition: netinfo.h:571

References m_netCodes.

Referenced by DIALOG_SELECT_NET_FROM_LIST::buildNetsList().

◆ OrphanedItem()

static NETINFO_ITEM* NETINFO_LIST::OrphanedItem ( )
inlinestatic

NETINFO_ITEM meaning that there was no net assigned for an item, as there was no board storing net list available.

Definition at line 469 of file netinfo.h.

470  {
471  static NETINFO_ITEM* g_orphanedItem;
472 
473  if( !g_orphanedItem )
474  g_orphanedItem = new NETINFO_ITEM( nullptr, wxEmptyString, NETINFO_LIST::UNCONNECTED );
475 
476  return g_orphanedItem;
477  }
NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:65
static const int UNCONNECTED
Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are ...
Definition: netinfo.h:461

References UNCONNECTED.

Referenced by BOARD::FindNet(), PCBNEW_CONTROL::Paste(), BOARD_CONNECTED_ITEM::SetNet(), and BOARD_CONNECTED_ITEM::SetNetCode().

◆ RemoveNet()

void NETINFO_LIST::RemoveNet ( NETINFO_ITEM aNet)

Function RemoveNet Removes a new from the net list.

Definition at line 87 of file netinfo_list.cpp.

88 {
89  for( NETCODES_MAP::iterator i = m_netCodes.begin(); i != m_netCodes.end(); ++i )
90  {
91  if ( i->second == aNet )
92  {
93  m_netCodes.erase(i);
94  break;
95  }
96  }
97 
98  for( NETNAMES_MAP::iterator i = m_netNames.begin(); i != m_netNames.end(); ++i )
99  {
100  if ( i->second == aNet )
101  {
102  m_netNames.erase(i);
103  break;
104  }
105  }
106 
107  m_newNetCode = std::min( m_newNetCode, aNet->m_NetCode - 1 );
108 }
NETNAMES_MAP m_netNames
map of <wxString, NETINFO_ITEM*>, is NETINFO_ITEM owner
Definition: netinfo.h:570
int m_newNetCode
possible value for new net code assignment
Definition: netinfo.h:573
int m_NetCode
A number equivalent to the net name.
Definition: netinfo.h:70
NETCODES_MAP m_netCodes
map of <int, NETINFO_ITEM*> is NOT owner
Definition: netinfo.h:571

References NETINFO_ITEM::m_NetCode, m_netCodes, m_netNames, and m_newNetCode.

Referenced by NET_SELECTOR_COMBOPOPUP::Accept(), and BOARD::Remove().

Friends And Related Function Documentation

◆ BOARD

friend class BOARD
friend

Definition at line 409 of file netinfo.h.

Member Data Documentation

◆ m_netCodes

NETCODES_MAP NETINFO_LIST::m_netCodes
private

map of <int, NETINFO_ITEM*> is NOT owner

Definition at line 571 of file netinfo.h.

Referenced by AppendNet(), clear(), getFreeNetCode(), GetNetItem(), NetsByNetcode(), and RemoveNet().

◆ m_netNames

NETNAMES_MAP NETINFO_LIST::m_netNames
private

map of <wxString, NETINFO_ITEM*>, is NETINFO_ITEM owner

Definition at line 570 of file netinfo.h.

Referenced by AppendNet(), begin(), clear(), end(), GetNetCount(), GetNetItem(), and RemoveNet().

◆ m_newNetCode

int NETINFO_LIST::m_newNetCode
private

possible value for new net code assignment

Definition at line 573 of file netinfo.h.

Referenced by clear(), getFreeNetCode(), NETINFO_LIST(), and RemoveNet().

◆ m_Parent

BOARD* NETINFO_LIST::m_Parent
private

Definition at line 568 of file netinfo.h.

Referenced by buildListOfNets(), and GetParent().

◆ ORPHANED

const int NETINFO_LIST::ORPHANED = -1
static

Constant that forces initialization of a netinfo item to the NETINFO_ITEM ORPHANED (typically -1) when calling SetNetCode od board connected items

Definition at line 465 of file netinfo.h.

Referenced by MODULE::ClearAllNets(), PCB_PARSER::parseD_PAD(), and BOARD::SanitizeNetcodes().

◆ UNCONNECTED


The documentation for this class was generated from the following files: