KiCad PCB EDA Suite
NETINFO_LIST Class Reference

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

#include <class_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 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...
 
static NETINFO_ITEM ORPHANED_ITEM = NETINFO_ITEM( NULL, wxEmptyString, NETINFO_LIST::UNCONNECTED )
 

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

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...
 
void buildPadsFullList ()
 Function buildPadsFullList creates the pad list, and initializes: m_Pads (list of pads) set m_Status_Pcb = LISTE_PAD_OK; and clear for all pads in list the m_SubRatsnest member; clear m_Pcb->m_FullRatsnest. 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

Class 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 class_netinfo.h.

Constructor & Destructor Documentation

NETINFO_LIST::NETINFO_LIST ( BOARD aParent)

Definition at line 44 of file class_netinfolist.cpp.

References AppendNet(), and m_newNetCode.

44  : m_Parent( aParent )
45 {
46  // Make sure that the unconnected net has number 0
47  AppendNet( new NETINFO_ITEM( aParent, wxEmptyString, 0 ) );
48 
49  m_newNetCode = 0;
50 }
BOARD * m_Parent
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
Class NETINFO_ITEM handles the data for a net.
Definition: class_netinfo.h:69
NETINFO_LIST::~NETINFO_LIST ( )

Definition at line 53 of file class_netinfolist.cpp.

References clear().

54 {
55  clear();
56 }
void clear()
Function clear deletes the list of nets (and free memory)

Member Function Documentation

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 117 of file class_netinfolist.cpp.

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

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

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

Definition at line 524 of file class_netinfo.h.

References m_netNames.

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

525  {
526  return iterator( m_netNames.begin() );
527  }
NETNAMES_MAP m_netNames
map of , is NETINFO_ITEM owner
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 Must be called after editing pads (netname, or deleting) or after read a netlist set to 1 flag NET_CODE_OK of m_Pcb->m_Status_Pcb; 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 157 of file class_netinfolist.cpp.

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

Referenced by BOARD::BuildListOfNets().

158 {
159  // Restore the initial state of NETINFO_ITEMs
160  for( NETINFO_LIST::iterator net( begin() ), netEnd( end() ); net != netEnd; ++net )
161  net->Clear();
162 
165 }
Wrapper class, so you can iterate through NETINFO_ITEM*s, not std::pair
BOARD * m_Parent
void SynchronizeNetsAndNetClasses()
Function SynchronizeNetsAndNetClasses copies NETCLASS info to each NET, based on NET membership in a ...
int SetAreasNetCodesFromNetNames(void)
Function SetAreasNetCodesFromNetNames Set the .m_NetCode member of all copper areas, according to the area Net Name The SetNetCodesFromNetNames is an equivalent to net name, for fast comparisons.
iterator begin() const
iterator end() const
void NETINFO_LIST::buildPadsFullList ( )
private

Function buildPadsFullList creates the pad list, and initializes: m_Pads (list of pads) set m_Status_Pcb = LISTE_PAD_OK; and clear for all pads in list the m_SubRatsnest member; clear m_Pcb->m_FullRatsnest.

void NETINFO_LIST::clear ( )
private

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

Definition at line 59 of file class_netinfolist.cpp.

References m_netCodes, m_netNames, and m_newNetCode.

Referenced by ~NETINFO_LIST().

60 {
61  NETNAMES_MAP::iterator it, itEnd;
62  for( it = m_netNames.begin(), itEnd = m_netNames.end(); it != itEnd; ++it )
63  delete it->second;
64 
65  m_netNames.clear();
66  m_netCodes.clear();
67  m_newNetCode = 0;
68 }
NETNAMES_MAP m_netNames
map of , is NETINFO_ITEM owner
int m_newNetCode
possible value for new net code assignment
NETCODES_MAP m_netCodes
map of is NOT owner
iterator NETINFO_LIST::end ( ) const
inline

Definition at line 529 of file class_netinfo.h.

References m_netNames.

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

530  {
531  return iterator( m_netNames.end() );
532  }
NETNAMES_MAP m_netNames
map of , is NETINFO_ITEM owner
int NETINFO_LIST::getFreeNetCode ( )
private

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

Definition at line 182 of file class_netinfolist.cpp.

References m_netCodes, and m_newNetCode.

Referenced by AppendNet().

183 {
184  do {
185  if( m_newNetCode < 0 )
186  m_newNetCode = 0;
187  } while( m_netCodes.count( ++m_newNetCode ) != 0 );
188 
189  return m_newNetCode;
190 }
int m_newNetCode
possible value for new net code assignment
NETCODES_MAP m_netCodes
map of is NOT owner
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 class_netinfo.h.

References m_netNames.

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

434 { return m_netNames.size(); }
NETNAMES_MAP m_netNames
map of , is NETINFO_ITEM owner
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 71 of file class_netinfolist.cpp.

References m_netCodes.

Referenced by AppendNet(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::buildNetsList(), DIALOG_SELECT_NET_FROM_LIST::buildNetsList(), and BOARD::FindNet().

72 {
73  NETCODES_MAP::const_iterator result = m_netCodes.find( aNetCode );
74 
75  if( result != m_netCodes.end() )
76  return (*result).second;
77 
78  return NULL;
79 }
NETCODES_MAP m_netCodes
map of is NOT owner
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 82 of file class_netinfolist.cpp.

References m_netNames.

83 {
84  NETNAMES_MAP::const_iterator result = m_netNames.find( aNetName );
85 
86  if( result != m_netNames.end() )
87  return (*result).second;
88 
89  return NULL;
90 }
NETNAMES_MAP m_netNames
map of , is NETINFO_ITEM owner
BOARD* NETINFO_LIST::GetParent ( ) const
inline

Definition at line 535 of file class_netinfo.h.

References m_Parent.

536  {
537  return m_Parent;
538  }
BOARD * m_Parent
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 class_netinfo.h.

454 { return m_netNames; }
NETNAMES_MAP m_netNames
map of , is NETINFO_ITEM owner
const NETCODES_MAP& NETINFO_LIST::NetsByNetcode ( ) const
inline

Return the netcode map, at least for python.

Definition at line 457 of file class_netinfo.h.

References m_netCodes.

457 { return m_netCodes; }
NETCODES_MAP m_netCodes
map of is NOT owner
void NETINFO_LIST::RemoveNet ( NETINFO_ITEM aNet)

Function RemoveNet Removes a new from the net list.

Definition at line 93 of file class_netinfolist.cpp.

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

Referenced by BOARD::Remove().

94 {
95  for( NETCODES_MAP::iterator i = m_netCodes.begin(); i != m_netCodes.end(); ++i )
96  {
97  if ( i->second == aNet )
98  {
99  m_netCodes.erase(i);
100  break;
101  }
102  }
103 
104  for( NETNAMES_MAP::iterator i = m_netNames.begin(); i != m_netNames.end(); ++i )
105  {
106  if ( i->second == aNet )
107  {
108  m_netNames.erase(i);
109  break;
110  }
111  }
112 
114 }
NETNAMES_MAP m_netNames
map of , is NETINFO_ITEM owner
int m_newNetCode
possible value for new net code assignment
int m_NetCode
A number equivalent to the net name.
Definition: class_netinfo.h:74
#define min(a, b)
Definition: auxiliary.h:85
NETCODES_MAP m_netCodes
map of is NOT owner

Friends And Related Function Documentation

friend class BOARD
friend

Definition at line 409 of file class_netinfo.h.

Member Data Documentation

NETCODES_MAP NETINFO_LIST::m_netCodes
private

map of <int, NETINFO_ITEM*> is NOT owner

Definition at line 573 of file class_netinfo.h.

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

NETNAMES_MAP NETINFO_LIST::m_netNames
private

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

Definition at line 572 of file class_netinfo.h.

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

int NETINFO_LIST::m_newNetCode
private

possible value for new net code assignment

Definition at line 575 of file class_netinfo.h.

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

BOARD* NETINFO_LIST::m_Parent
private

Definition at line 570 of file class_netinfo.h.

Referenced by buildListOfNets(), and GetParent().

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 class_netinfo.h.

Referenced by MODULE::ClearAllNets().

NETINFO_ITEM NETINFO_LIST::ORPHANED_ITEM = NETINFO_ITEM( NULL, wxEmptyString, NETINFO_LIST::UNCONNECTED )
static

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 class_netinfo.h.

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


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