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 <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 415 of file netinfo.h.

Constructor & Destructor Documentation

NETINFO_LIST::NETINFO_LIST ( BOARD aParent)

Definition at line 44 of file netinfo_list.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
Definition: netinfo.h:578
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:583
Class NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:69
NETINFO_LIST::~NETINFO_LIST ( )

Definition at line 53 of file netinfo_list.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 netinfo_list.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 <wxString, NETINFO_ITEM*>, is NETINFO_ITEM owner
Definition: netinfo.h:580
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: netinfo.h:74
int GetNet() const
Function GetNet.
Definition: netinfo.h:231
Class NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:69
const wxString & GetNetname() const
Function GetNetname.
Definition: netinfo.h:239
NETCODES_MAP m_netCodes
map of <int, NETINFO_ITEM*> is NOT owner
Definition: netinfo.h:581
iterator NETINFO_LIST::begin ( ) const
inline

Definition at line 532 of file netinfo.h.

References NETINFO_MAPPING::iterator::iterator().

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

533  {
534  return iterator( m_netNames.begin() );
535  }
NETNAMES_MAP m_netNames
map of <wxString, NETINFO_ITEM*>, is NETINFO_ITEM owner
Definition: netinfo.h:580
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 netinfo_list.cpp.

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

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<int/wxString, NETINFO_ITEM*>
Definition: netinfo.h:486
BOARD * m_Parent
Definition: netinfo.h:578
void SynchronizeNetsAndNetClasses()
Function SynchronizeNetsAndNetClasses copies NETCLASS info to each NET, based on NET membership in a ...
Definition: netclass.cpp:160
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
Definition: netinfo.h:532
iterator end() const
Definition: netinfo.h:537
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 netinfo_list.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 <wxString, NETINFO_ITEM*>, is NETINFO_ITEM owner
Definition: netinfo.h:580
int m_newNetCode
possible value for new net code assignment
Definition: netinfo.h:583
NETCODES_MAP m_netCodes
map of <int, NETINFO_ITEM*> is NOT owner
Definition: netinfo.h:581
iterator NETINFO_LIST::end ( ) const
inline

Definition at line 537 of file netinfo.h.

References NETINFO_MAPPING::iterator::iterator().

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

538  {
539  return iterator( m_netNames.end() );
540  }
NETNAMES_MAP m_netNames
map of <wxString, NETINFO_ITEM*>, is NETINFO_ITEM owner
Definition: netinfo.h:580
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 netinfo_list.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
Definition: netinfo.h:583
NETCODES_MAP m_netCodes
map of <int, NETINFO_ITEM*> is NOT owner
Definition: netinfo.h:581
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 442 of file netinfo.h.

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

442 { return m_netNames.size(); }
NETNAMES_MAP m_netNames
map of <wxString, NETINFO_ITEM*>, is NETINFO_ITEM owner
Definition: netinfo.h:580
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 netinfo_list.cpp.

References m_netCodes.

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

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 <int, NETINFO_ITEM*> is NOT owner
Definition: netinfo.h:581
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 netinfo_list.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 <wxString, NETINFO_ITEM*>, is NETINFO_ITEM owner
Definition: netinfo.h:580
BOARD* NETINFO_LIST::GetParent ( ) const
inline

Definition at line 543 of file netinfo.h.

544  {
545  return m_Parent;
546  }
BOARD * m_Parent
Definition: netinfo.h:578
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 462 of file netinfo.h.

462 { return m_netNames; }
NETNAMES_MAP m_netNames
map of <wxString, NETINFO_ITEM*>, is NETINFO_ITEM owner
Definition: netinfo.h:580
const NETCODES_MAP& NETINFO_LIST::NetsByNetcode ( ) const
inline

Return the netcode map, at least for python.

Definition at line 465 of file netinfo.h.

465 { return m_netCodes; }
NETCODES_MAP m_netCodes
map of <int, NETINFO_ITEM*> is NOT owner
Definition: netinfo.h:581
void NETINFO_LIST::RemoveNet ( NETINFO_ITEM aNet)

Function RemoveNet Removes a new from the net list.

Definition at line 93 of file netinfo_list.cpp.

References i, 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 <wxString, NETINFO_ITEM*>, is NETINFO_ITEM owner
Definition: netinfo.h:580
int m_newNetCode
possible value for new net code assignment
Definition: netinfo.h:583
int m_NetCode
A number equivalent to the net name.
Definition: netinfo.h:74
size_t i
Definition: json11.cpp:597
#define min(a, b)
Definition: auxiliary.h:85
NETCODES_MAP m_netCodes
map of <int, NETINFO_ITEM*> is NOT owner
Definition: netinfo.h:581

Friends And Related Function Documentation

friend class BOARD
friend

Definition at line 417 of file netinfo.h.

Member Data Documentation

NETCODES_MAP NETINFO_LIST::m_netCodes
private

map of <int, NETINFO_ITEM*> is NOT owner

Definition at line 581 of file netinfo.h.

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

NETNAMES_MAP NETINFO_LIST::m_netNames
private

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

Definition at line 580 of file netinfo.h.

Referenced by AppendNet(), buildListOfNets(), clear(), GetNetItem(), and RemoveNet().

int NETINFO_LIST::m_newNetCode
private

possible value for new net code assignment

Definition at line 583 of file netinfo.h.

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

BOARD* NETINFO_LIST::m_Parent
private

Definition at line 578 of file netinfo.h.

Referenced by buildListOfNets().

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 473 of file netinfo.h.

Referenced by MODULE::ClearAllNets(), NETINFO_MAPPING::iterator::operator->(), and BOARD::SanitizeNetcodes().

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 477 of file netinfo.h.

Referenced by BOARD::FindNet(), NETINFO_MAPPING::iterator::operator->(), and BOARD_CONNECTED_ITEM::SetNetCode().


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