KiCad PCB EDA Suite
CN_CLUSTER Class Reference

#include <connectivity_items.h>

Public Types

using ITER = decltype(m_items)::iterator
 

Public Member Functions

 CN_CLUSTER ()
 
 ~CN_CLUSTER ()
 
bool HasValidNet () const
 
int OriginNet () const
 
wxString OriginNetName () const
 
bool Contains (const CN_ITEM *aItem)
 
bool Contains (const BOARD_CONNECTED_ITEM *aItem)
 
void Dump ()
 
int Size () const
 
bool IsOrphaned () const
 
bool IsConflicting () const
 
void Add (CN_ITEM *item)
 
ITER begin ()
 
ITER end ()
 

Private Attributes

bool m_conflicting
 
int m_originNet
 
CN_ITEMm_originPad
 
std::vector< CN_ITEM * > m_items
 
std::unordered_map< int, int > m_netRanks
 

Detailed Description

Definition at line 450 of file connectivity_items.h.

Member Typedef Documentation

◆ ITER

using CN_CLUSTER::ITER = decltype(m_items)::iterator

Definition at line 480 of file connectivity_items.h.

Constructor & Destructor Documentation

◆ CN_CLUSTER()

CN_CLUSTER::CN_CLUSTER ( )

Definition at line 418 of file connectivity_items.cpp.

419 {
420  m_items.reserve( 64 );
421  m_originPad = nullptr;
422  m_originNet = -1;
423  m_conflicting = false;
424 }
std::vector< CN_ITEM * > m_items
CN_ITEM * m_originPad

References m_conflicting, m_items, m_originNet, and m_originPad.

◆ ~CN_CLUSTER()

CN_CLUSTER::~CN_CLUSTER ( )

Definition at line 427 of file connectivity_items.cpp.

428 {
429 }

Member Function Documentation

◆ Add()

void CN_CLUSTER::Add ( CN_ITEM item)

Definition at line 476 of file connectivity_items.cpp.

477 {
478  m_items.push_back( item );
479 
480  int netCode = item->Net();
481 
482  if( netCode <= 0 )
483  return;
484 
485  if( m_originNet <= 0 )
486  {
487  m_originNet = netCode;
488  }
489 
490  if( item->Parent()->Type() == PCB_PAD_T )
491  {
492  if( m_netRanks.count( netCode ) )
493  {
494  m_netRanks[netCode]++;
495 
496  if( m_netRanks.count( m_originNet ) && m_netRanks[netCode] > m_netRanks[m_originNet] )
497  {
498  m_originPad = item;
499  m_originNet = netCode;
500  }
501  }
502  else
503  {
504  m_netRanks[netCode] = 1;
505 
506  if( !m_originPad )
507  {
508  m_originPad = item;
509  m_originNet = netCode;
510  }
511  }
512 
513  if( m_originPad && item->Net() != m_originNet )
514  {
515  m_conflicting = true;
516  }
517  }
518 }
class PAD, a pad in a footprint
Definition: typeinfo.h:89
BOARD_CONNECTED_ITEM * Parent() const
int Net() const
allow parallel connection threads
std::unordered_map< int, int > m_netRanks
std::vector< CN_ITEM * > m_items
CN_ITEM * m_originPad
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References m_conflicting, m_items, m_netRanks, m_originNet, m_originPad, CN_ITEM::Net(), CN_ITEM::Parent(), PCB_PAD_T, and EDA_ITEM::Type().

◆ begin()

ITER CN_CLUSTER::begin ( )
inline

Definition at line 482 of file connectivity_items.h.

482 { return m_items.begin(); };
std::vector< CN_ITEM * > m_items

References m_items.

◆ Contains() [1/2]

bool CN_CLUSTER::Contains ( const CN_ITEM aItem)

Definition at line 441 of file connectivity_items.cpp.

442 {
443  return alg::contains( m_items, aItem );
444 }
std::vector< CN_ITEM * > m_items
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:99

References alg::contains(), and m_items.

◆ Contains() [2/2]

bool CN_CLUSTER::Contains ( const BOARD_CONNECTED_ITEM aItem)

Definition at line 447 of file connectivity_items.cpp.

448 {
449  return std::find_if( m_items.begin(), m_items.end(),
450  [ &aItem ] ( const CN_ITEM* item )
451  {
452  return item->Valid() && item->Parent() == aItem;
453  } ) != m_items.end();
454 }
std::vector< CN_ITEM * > m_items

References m_items.

◆ Dump()

void CN_CLUSTER::Dump ( )

Definition at line 457 of file connectivity_items.cpp.

458 {
459  for( auto item : m_items )
460  {
461  wxLogTrace( "CN", " - item : %p bitem : %p type : %d inet %s\n",
462  item,
463  item->Parent(),
464  item->Parent()->Type(),
465  (const char*) item->Parent()->GetNetname().c_str() );
466  wxLogTrace( "CN", "- item : %p bitem : %p type : %d inet %s\n",
467  item,
468  item->Parent(),
469  item->Parent()->Type(),
470  (const char*) item->Parent()->GetNetname().c_str() );
471  item->Dump();
472  }
473 }
std::vector< CN_ITEM * > m_items

References m_items.

◆ end()

ITER CN_CLUSTER::end ( )
inline

Definition at line 483 of file connectivity_items.h.

483 { return m_items.end(); };
std::vector< CN_ITEM * > m_items

References m_items.

◆ HasValidNet()

bool CN_CLUSTER::HasValidNet ( ) const
inline

Definition at line 463 of file connectivity_items.h.

463 { return m_originNet > 0; }

References m_originNet.

◆ IsConflicting()

bool CN_CLUSTER::IsConflicting ( ) const
inline

Definition at line 476 of file connectivity_items.h.

476 { return m_conflicting; }

References m_conflicting.

◆ IsOrphaned()

bool CN_CLUSTER::IsOrphaned ( ) const
inline

Definition at line 474 of file connectivity_items.h.

474 { return m_originPad == nullptr; }
CN_ITEM * m_originPad

References m_originPad.

◆ OriginNet()

int CN_CLUSTER::OriginNet ( ) const
inline

Definition at line 464 of file connectivity_items.h.

464 { return m_originNet; }

References m_originNet.

◆ OriginNetName()

wxString CN_CLUSTER::OriginNetName ( ) const

Definition at line 432 of file connectivity_items.cpp.

433 {
434  if( !m_originPad || !m_originPad->Valid() )
435  return "<none>";
436  else
437  return m_originPad->Parent()->GetNetname();
438 }
BOARD_CONNECTED_ITEM * Parent() const
CN_ITEM * m_originPad
bool Valid() const

References BOARD_CONNECTED_ITEM::GetNetname(), m_originPad, CN_ITEM::Parent(), and CN_ITEM::Valid().

◆ Size()

int CN_CLUSTER::Size ( ) const
inline

Definition at line 472 of file connectivity_items.h.

472 { return m_items.size(); }
std::vector< CN_ITEM * > m_items

References m_items.

Member Data Documentation

◆ m_conflicting

bool CN_CLUSTER::m_conflicting
private

Definition at line 453 of file connectivity_items.h.

Referenced by Add(), CN_CLUSTER(), and IsConflicting().

◆ m_items

std::vector<CN_ITEM*> CN_CLUSTER::m_items
private

Definition at line 456 of file connectivity_items.h.

Referenced by Add(), begin(), CN_CLUSTER(), Contains(), Dump(), end(), and Size().

◆ m_netRanks

std::unordered_map<int, int> CN_CLUSTER::m_netRanks
private

Definition at line 457 of file connectivity_items.h.

Referenced by Add().

◆ m_originNet

int CN_CLUSTER::m_originNet
private

Definition at line 454 of file connectivity_items.h.

Referenced by Add(), CN_CLUSTER(), HasValidNet(), and OriginNet().

◆ m_originPad

CN_ITEM* CN_CLUSTER::m_originPad
private

Definition at line 455 of file connectivity_items.h.

Referenced by Add(), CN_CLUSTER(), IsOrphaned(), and OriginNetName().


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