KiCad PCB EDA Suite
ARRAY_PAD_NUMBER_PROVIDER Class Reference

Simple class that sequentially provides numbers from an ARRAY_OPTIONS object, making sure that they do not conflict with numbers already existing in a FOOTPRINT. More...

#include <array_pad_number_provider.h>

Public Member Functions

 ARRAY_PAD_NUMBER_PROVIDER (const FOOTPRINT *aFootprint, const ARRAY_OPTIONS &aArrayOpts)
 
wxString GetNextPadNumber ()
 Get the next available pad name. More...
 

Private Member Functions

wxString getNextNumber (int &aIndex, const std::set< wxString > &aExisting)
 Get the next number from a given index/list combo. More...
 

Private Attributes

const ARRAY_OPTIONSm_arrayOpts
 
std::set< wxString > m_existing_pad_numbers
 
int m_current_pad_index
 

Detailed Description

Simple class that sequentially provides numbers from an ARRAY_OPTIONS object, making sure that they do not conflict with numbers already existing in a FOOTPRINT.

Definition at line 35 of file array_pad_number_provider.h.

Constructor & Destructor Documentation

◆ ARRAY_PAD_NUMBER_PROVIDER()

ARRAY_PAD_NUMBER_PROVIDER::ARRAY_PAD_NUMBER_PROVIDER ( const FOOTPRINT aFootprint,
const ARRAY_OPTIONS aArrayOpts 
)
Parameters
aFootprintthe footprint to gather existing numbers from (nullptr for no footprint)
aArrayOptsthe array options that provide the candidate numbers

Definition at line 29 of file array_pad_number_provider.cpp.

31 : m_arrayOpts( aArrayOpts )
32{
33 // start by numbering the first new item
35
36 // construct the set of existing pad numbers
37 if( aArrayOpts.GetNumberingStartIsSpecified() )
38 {
39 // if we start from a specified point, we don't look at existing
40 // names, so it's just an empty "reserved" set
41 }
42 else
43 {
44 // no footprint, no reserved names either
45 if( aFootprint )
46 {
47 // reserve the name of each existing pad
48 for( PAD* pad : aFootprint->Pads() )
49 m_existing_pad_numbers.insert( pad->GetNumber() );
50 }
51 }
52}
bool GetNumberingStartIsSpecified() const
std::set< wxString > m_existing_pad_numbers
PADS & Pads()
Definition: footprint.h:175
Definition: pad.h:59

References ARRAY_OPTIONS::GetNumberingStartIsSpecified(), m_current_pad_index, m_existing_pad_numbers, pad, and FOOTPRINT::Pads().

Member Function Documentation

◆ getNextNumber()

wxString ARRAY_PAD_NUMBER_PROVIDER::getNextNumber ( int &  aIndex,
const std::set< wxString > &  aExisting 
)
private

Get the next number from a given index/list combo.

Parameters
aIndexindex to start at, will be updated
aExistingthe set of existing numbers to skip
Returns
the first number found that's not in aExisting

Definition at line 61 of file array_pad_number_provider.cpp.

63{
64 wxString next_number;
65
66 do
67 {
68 next_number = m_arrayOpts.GetItemNumber( aIndex );
69 aIndex++;
70 } while( aExisting.count( next_number ) != 0 );
71
72 return next_number;
73}
virtual wxString GetItemNumber(int n) const =0
Get the position number (name) for the n'th array point.

References ARRAY_OPTIONS::GetItemNumber(), and m_arrayOpts.

Referenced by GetNextPadNumber().

◆ GetNextPadNumber()

wxString ARRAY_PAD_NUMBER_PROVIDER::GetNextPadNumber ( )

Get the next available pad name.

Definition at line 55 of file array_pad_number_provider.cpp.

56{
58}
wxString getNextNumber(int &aIndex, const std::set< wxString > &aExisting)
Get the next number from a given index/list combo.

References getNextNumber(), m_current_pad_index, and m_existing_pad_numbers.

Referenced by CheckPadNumberProvider(), and ARRAY_CREATOR::Invoke().

Member Data Documentation

◆ m_arrayOpts

const ARRAY_OPTIONS& ARRAY_PAD_NUMBER_PROVIDER::m_arrayOpts
private

Definition at line 58 of file array_pad_number_provider.h.

Referenced by getNextNumber().

◆ m_current_pad_index

int ARRAY_PAD_NUMBER_PROVIDER::m_current_pad_index
private

Definition at line 60 of file array_pad_number_provider.h.

Referenced by ARRAY_PAD_NUMBER_PROVIDER(), and GetNextPadNumber().

◆ m_existing_pad_numbers

std::set<wxString> ARRAY_PAD_NUMBER_PROVIDER::m_existing_pad_numbers
private

Definition at line 59 of file array_pad_number_provider.h.

Referenced by ARRAY_PAD_NUMBER_PROVIDER(), and GetNextPadNumber().


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