KiCad PCB EDA Suite
ARRAY_PAD_NAME_PROVIDER Class Reference

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

#include <array_pad_name_provider.h>

Public Member Functions

 ARRAY_PAD_NAME_PROVIDER (const MODULE *aMod, const ARRAY_OPTIONS &aArrayOpts)
 
wxString GetNextPadName ()
 Get the next available pad name. More...
 

Private Member Functions

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

Private Attributes

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

Detailed Description

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

Definition at line 36 of file array_pad_name_provider.h.

Constructor & Destructor Documentation

◆ ARRAY_PAD_NAME_PROVIDER()

ARRAY_PAD_NAME_PROVIDER::ARRAY_PAD_NAME_PROVIDER ( const MODULE aMod,
const ARRAY_OPTIONS aArrayOpts 
)
Parameters
aModthe module to gather existing names from (nullptr for no module) @oaram aArrayOpts the array options that provide the candidate names

Definition at line 29 of file array_pad_name_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 module, no reserved names either
45  if( aMod )
46  {
47  // reserve the name of each existing pad
48  for( auto pad : aMod->Pads() )
49  {
50  m_existing_pad_names.insert( pad->GetName() );
51  }
52  }
53  }
54 }
PADS & Pads()
Definition: class_module.h:181
std::set< wxString > m_existing_pad_names
const ARRAY_OPTIONS & m_arrayOpts
bool GetNumberingStartIsSpecified() const

References ARRAY_OPTIONS::GetNumberingStartIsSpecified(), m_current_pad_index, m_existing_pad_names, and MODULE::Pads().

Member Function Documentation

◆ getNextName()

wxString ARRAY_PAD_NAME_PROVIDER::getNextName ( int &  aIndex,
const std::set< wxString > &  aExisting 
)
private

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

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

Definition at line 63 of file array_pad_name_provider.cpp.

64 {
65  wxString next_name;
66 
67  do
68  {
69  next_name = m_arrayOpts.GetItemNumber( aIndex );
70  aIndex++;
71  } while( aExisting.count( next_name ) != 0 );
72 
73  return next_name;
74 }
const ARRAY_OPTIONS & m_arrayOpts
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 GetNextPadName().

◆ GetNextPadName()

wxString ARRAY_PAD_NAME_PROVIDER::GetNextPadName ( )

Get the next available pad name.

Definition at line 57 of file array_pad_name_provider.cpp.

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

References getNextName(), m_current_pad_index, and m_existing_pad_names.

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

Member Data Documentation

◆ m_arrayOpts

const ARRAY_OPTIONS& ARRAY_PAD_NAME_PROVIDER::m_arrayOpts
private

Definition at line 59 of file array_pad_name_provider.h.

Referenced by getNextName().

◆ m_current_pad_index

int ARRAY_PAD_NAME_PROVIDER::m_current_pad_index
private

Definition at line 61 of file array_pad_name_provider.h.

Referenced by ARRAY_PAD_NAME_PROVIDER(), and GetNextPadName().

◆ m_existing_pad_names

std::set<wxString> ARRAY_PAD_NAME_PROVIDER::m_existing_pad_names
private

Definition at line 60 of file array_pad_name_provider.h.

Referenced by ARRAY_PAD_NAME_PROVIDER(), and GetNextPadName().


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