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 480 of file connectivity_items.h.

Member Typedef Documentation

◆ ITER

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

Definition at line 510 of file connectivity_items.h.

Constructor & Destructor Documentation

◆ CN_CLUSTER()

CN_CLUSTER::CN_CLUSTER ( )

Definition at line 349 of file connectivity_items.cpp.

350{
351 m_items.reserve( 64 );
352 m_originPad = nullptr;
353 m_originNet = -1;
354 m_conflicting = false;
355}
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 358 of file connectivity_items.cpp.

359{
360}

Member Function Documentation

◆ Add()

void CN_CLUSTER::Add ( CN_ITEM item)

Definition at line 407 of file connectivity_items.cpp.

408{
409 m_items.push_back( item );
410
411 int netCode = item->Net();
412
413 if( netCode <= 0 )
414 return;
415
416 if( m_originNet <= 0 )
417 m_originNet = netCode;
418
419 if( item->Parent()->Type() == PCB_PAD_T )
420 {
421 if( m_netRanks.count( netCode ) )
422 {
423 m_netRanks[netCode]++;
424
425 if( m_netRanks.count( m_originNet ) && m_netRanks[netCode] > m_netRanks[m_originNet] )
426 {
427 m_originPad = item;
428 m_originNet = netCode;
429 }
430 }
431 else
432 {
433 m_netRanks[netCode] = 1;
434
435 if( !m_originPad )
436 {
437 m_originPad = item;
438 m_originNet = netCode;
439 }
440 }
441
442 if( m_originPad && item->Net() != m_originNet )
443 m_conflicting = true;
444 }
445}
std::unordered_map< int, int > m_netRanks
int Net() const
allow parallel connection threads
BOARD_CONNECTED_ITEM * Parent() const
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition: typeinfo.h:87

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 512 of file connectivity_items.h.

512{ return m_items.begin(); };

References m_items.

◆ Contains() [1/2]

bool CN_CLUSTER::Contains ( const BOARD_CONNECTED_ITEM aItem)

Definition at line 378 of file connectivity_items.cpp.

379{
380 return std::find_if( m_items.begin(), m_items.end(),
381 [&aItem]( const CN_ITEM* item )
382 {
383 return item->Valid() && item->Parent() == aItem;
384 } ) != m_items.end();
385}
CN_ITEM represents a BOARD_CONNETED_ITEM in the connectivity system (ie: a pad, track/arc/via,...

References m_items.

◆ Contains() [2/2]

bool CN_CLUSTER::Contains ( const CN_ITEM aItem)

Definition at line 372 of file connectivity_items.cpp.

373{
374 return alg::contains( m_items, aItem );
375}
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.

◆ Dump()

void CN_CLUSTER::Dump ( )

Definition at line 388 of file connectivity_items.cpp.

389{
390 for( CN_ITEM* item : m_items )
391 {
392 wxLogTrace( wxT( "CN" ), wxT( " - item : %p bitem : %p type : %d inet %s\n" ),
393 item,
394 item->Parent(),
395 item->Parent()->Type(),
396 (const char*) item->Parent()->GetNetname().c_str() );
397 wxLogTrace( wxT( "CN" ), wxT( "- item : %p bitem : %p type : %d inet %s\n" ),
398 item,
399 item->Parent(),
400 item->Parent()->Type(),
401 (const char*) item->Parent()->GetNetname().c_str() );
402 item->Dump();
403 }
404}

References m_items.

◆ end()

ITER CN_CLUSTER::end ( )
inline

Definition at line 513 of file connectivity_items.h.

513{ return m_items.end(); };

References m_items.

◆ HasValidNet()

bool CN_CLUSTER::HasValidNet ( ) const
inline

Definition at line 493 of file connectivity_items.h.

493{ return m_originNet > 0; }

References m_originNet.

◆ IsConflicting()

bool CN_CLUSTER::IsConflicting ( ) const
inline

Definition at line 506 of file connectivity_items.h.

506{ return m_conflicting; }

References m_conflicting.

◆ IsOrphaned()

bool CN_CLUSTER::IsOrphaned ( ) const
inline

Definition at line 504 of file connectivity_items.h.

504{ return m_originPad == nullptr; }

References m_originPad.

◆ OriginNet()

int CN_CLUSTER::OriginNet ( ) const
inline

Definition at line 494 of file connectivity_items.h.

494{ return m_originNet; }

References m_originNet.

◆ OriginNetName()

wxString CN_CLUSTER::OriginNetName ( ) const

Definition at line 363 of file connectivity_items.cpp.

364{
365 if( !m_originPad || !m_originPad->Valid() )
366 return "<none>";
367 else
368 return m_originPad->Parent()->GetNetname();
369}
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 502 of file connectivity_items.h.

502{ return m_items.size(); }

References m_items.

Member Data Documentation

◆ m_conflicting

bool CN_CLUSTER::m_conflicting
private

Definition at line 483 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 486 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 487 of file connectivity_items.h.

Referenced by Add().

◆ m_originNet

int CN_CLUSTER::m_originNet
private

Definition at line 484 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 485 of file connectivity_items.h.

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


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