KiCad PCB EDA Suite
COMPONENT Class Reference

COMPONENT is used to store components and all of their related information found in a netlist. More...

#include <pcb_netlist.h>

Public Member Functions

 COMPONENT (const LIB_ID &aFPID, const wxString &aReference, const wxString &aValue, const KIID_PATH &aPath)
 
virtual ~COMPONENT ()
 
void AddNet (const wxString &aPinName, const wxString &aNetName, const wxString &aPinFunction)
 
unsigned GetNetCount () const
 
const COMPONENT_NETGetNet (unsigned aIndex) const
 
const COMPONENT_NETGetNet (const wxString &aPinName) const
 
void SortPins ()
 
void SetName (const wxString &aName)
 
const wxString & GetName () const
 
void SetLibrary (const wxString &aLibrary)
 
const wxString & GetLibrary () const
 
const wxString & GetReference () const
 
const wxString & GetValue () const
 
void SetFPID (const LIB_ID &aFPID)
 
void SetAltFPID (const LIB_ID &aFPID)
 
const LIB_IDGetFPID () const
 
const LIB_IDGetAltFPID () const
 
const KIID_PATHGetPath () const
 
void SetFootprintFilters (const wxArrayString &aFilterList)
 
const wxArrayString & GetFootprintFilters () const
 
void SetPinCount (int aPinCount)
 
int GetPinCount () const
 
MODULEGetModule (bool aRelease=false)
 
void SetModule (MODULE *aModule)
 
bool IsLibSource (const wxString &aLibrary, const wxString &aName) const
 
bool FootprintChanged () const
 
void Format (OUTPUTFORMATTER *aOut, int aNestLevel, int aCtl)
 

Private Attributes

COMPONENT_NETS m_nets
 list of nets shared by the component pins More...
 
wxArrayString m_footprintFilters
 Footprint filters found in netlist. More...
 
int m_pinCount
 Number of pins found in netlist. More...
 
wxString m_reference
 The component reference designator found in netlist. More...
 
wxString m_value
 The component value found in netlist. More...
 
KIID_PATH m_path
 A fully specified path to the component: [ sheetUUID, sheetUUID, .., componentUUID ]. More...
 
wxString m_name
 The name of the component in m_library used when it was placed on the schematic.. More...
 
wxString m_library
 The name of the component library where m_name was found. More...
 
LIB_ID m_fpid
 The LIB_ID of the footprint assigned to the component. More...
 
LIB_ID m_altFpid
 The alt LIB_ID of the footprint, when there are 2 different assigned footprints, One from the netlist, the other from the .cmp file. More...
 
std::unique_ptr< MODULEm_footprint
 The MODULE loaded for m_fpid. More...
 
bool m_footprintChanged
 Set to true if m_fpid was changed when the footprint link file was read. More...
 

Static Private Attributes

static COMPONENT_NET m_emptyNet
 

Detailed Description

COMPONENT is used to store components and all of their related information found in a netlist.

Definition at line 80 of file pcb_netlist.h.

Constructor & Destructor Documentation

◆ COMPONENT()

COMPONENT::COMPONENT ( const LIB_ID aFPID,
const wxString &  aReference,
const wxString &  aValue,
const KIID_PATH aPath 
)
inline

Definition at line 115 of file pcb_netlist.h.

119  {
120  m_fpid = aFPID;
121  m_reference = aReference;
122  m_value = aValue;
123  m_pinCount = 0;
124  m_path = aPath;
125  m_footprintChanged = false;
126  }
KIID_PATH m_path
A fully specified path to the component: [ sheetUUID, sheetUUID, .., componentUUID ].
Definition: pcb_netlist.h:89
bool m_footprintChanged
Set to true if m_fpid was changed when the footprint link file was read.
Definition: pcb_netlist.h:110
LIB_ID m_fpid
The LIB_ID of the footprint assigned to the component.
Definition: pcb_netlist.h:98
wxString m_value
The component value found in netlist.
Definition: pcb_netlist.h:86
wxString m_reference
The component reference designator found in netlist.
Definition: pcb_netlist.h:85
int m_pinCount
Number of pins found in netlist.
Definition: pcb_netlist.h:84

References m_footprintChanged, m_fpid, m_path, m_pinCount, m_reference, and m_value.

◆ ~COMPONENT()

virtual COMPONENT::~COMPONENT ( )
inlinevirtual

Definition at line 128 of file pcb_netlist.h.

128 { };

Member Function Documentation

◆ AddNet()

void COMPONENT::AddNet ( const wxString &  aPinName,
const wxString &  aNetName,
const wxString &  aPinFunction 
)
inline

Definition at line 130 of file pcb_netlist.h.

131  {
132  m_nets.push_back( COMPONENT_NET( aPinName, aNetName, aPinFunction ) );
133  }
COMPONENT_NETS m_nets
list of nets shared by the component pins
Definition: pcb_netlist.h:82
COMPONENT_NET is used to store the component pin name to net name (and pin function) associations sto...
Definition: pcb_netlist.h:44

References m_nets.

Referenced by LEGACY_NETLIST_READER::loadNet(), and KICAD_NETLIST_PARSER::parseNet().

◆ FootprintChanged()

bool COMPONENT::FootprintChanged ( ) const
inline

Definition at line 196 of file pcb_netlist.h.

196 { return m_footprintChanged; }
bool m_footprintChanged
Set to true if m_fpid was changed when the footprint link file was read.
Definition: pcb_netlist.h:110

References m_footprintChanged.

◆ Format()

void COMPONENT::Format ( OUTPUTFORMATTER aOut,
int  aNestLevel,
int  aCtl 
)

Definition at line 76 of file pcb_netlist.cpp.

77 {
78  int nl = aNestLevel;
79 
80  aOut->Print( nl, "(ref %s ", aOut->Quotew( m_reference ).c_str() );
81  aOut->Print( 0, "(fpid %s)\n", aOut->Quotew( m_fpid.Format() ).c_str() );
82 
83  if( ! ( aCtl & CTL_OMIT_EXTRA ) )
84  {
85  aOut->Print( nl+1, "(value %s)\n", aOut->Quotew( m_value ).c_str() );
86  aOut->Print( nl+1, "(name %s)\n", aOut->Quotew( m_name ).c_str() );
87  aOut->Print( nl+1, "(library %s)\n", aOut->Quotew( m_library ).c_str() );
88 
89  wxString path;
90 
91  for( const KIID& pathStep : m_path )
92  path += '/' + pathStep.AsString();
93 
94  aOut->Print( nl+1, "(timestamp %s)\n", aOut->Quotew( path ).c_str() );
95  }
96 
97  if( !( aCtl & CTL_OMIT_FILTERS ) && m_footprintFilters.GetCount() )
98  {
99  aOut->Print( nl+1, "(fp_filters" );
100 
101  for( unsigned i = 0; i < m_footprintFilters.GetCount(); ++i )
102  aOut->Print( 0, " %s", aOut->Quotew( m_footprintFilters[i] ).c_str() );
103 
104  aOut->Print( 0, ")\n" );
105  }
106 
107  if( !( aCtl & CTL_OMIT_NETS ) && m_nets.size() )
108  {
109  int llen = aOut->Print( nl+1, "(nets " );
110 
111  for( unsigned i = 0; i < m_nets.size(); ++i )
112  {
113  if( llen > 80 )
114  {
115  aOut->Print( 0, "\n" );
116  llen = aOut->Print( nl+1, " " );
117  }
118 
119  llen += m_nets[i].Format( aOut, 0, aCtl );
120  }
121 
122  aOut->Print( 0, ")\n" );
123  }
124 
125  aOut->Print( nl, ")\n" ); // </ref>
126 }
KIID_PATH m_path
A fully specified path to the component: [ sheetUUID, sheetUUID, .., componentUUID ].
Definition: pcb_netlist.h:89
wxString m_name
The name of the component in m_library used when it was placed on the schematic..
Definition: pcb_netlist.h:92
wxString m_library
The name of the component library where m_name was found.
Definition: pcb_netlist.h:95
wxArrayString m_footprintFilters
Footprint filters found in netlist.
Definition: pcb_netlist.h:83
COMPONENT_NETS m_nets
list of nets shared by the component pins
Definition: pcb_netlist.h:82
Definition: common.h:68
#define CTL_OMIT_FILTERS
Definition: pcb_netlist.h:349
std::string Quotew(const wxString &aWrapee)
Definition: richio.cpp:472
#define CTL_OMIT_NETS
Omit pads net names (useless in library)
UTF8 Format() const
Definition: lib_id.cpp:237
LIB_ID m_fpid
The LIB_ID of the footprint assigned to the component.
Definition: pcb_netlist.h:98
wxString m_value
The component value found in netlist.
Definition: pcb_netlist.h:86
wxString m_reference
The component reference designator found in netlist.
Definition: pcb_netlist.h:85
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404
#define CTL_OMIT_EXTRA
Definition: pcb_netlist.h:347

References CTL_OMIT_EXTRA, CTL_OMIT_FILTERS, CTL_OMIT_NETS, LIB_ID::Format(), m_footprintFilters, m_fpid, m_library, m_name, m_nets, m_path, m_reference, m_value, OUTPUTFORMATTER::Print(), and OUTPUTFORMATTER::Quotew().

◆ GetAltFPID()

const LIB_ID& COMPONENT::GetAltFPID ( ) const
inline

Definition at line 166 of file pcb_netlist.h.

166 { return m_altFpid; }
LIB_ID m_altFpid
The alt LIB_ID of the footprint, when there are 2 different assigned footprints, One from the netlist...
Definition: pcb_netlist.h:104

References m_altFpid.

Referenced by CVPCB_MAINFRAME::ReadNetListAndFpFiles().

◆ GetFootprintFilters()

const wxArrayString& COMPONENT::GetFootprintFilters ( ) const
inline

Definition at line 175 of file pcb_netlist.h.

175 { return m_footprintFilters; }
wxArrayString m_footprintFilters
Footprint filters found in netlist.
Definition: pcb_netlist.h:83

References m_footprintFilters.

Referenced by CVPCB_MAINFRAME::AutomaticFootprintMatching(), CVPCB_MAINFRAME::DisplayStatus(), and FOOTPRINTS_LISTBOX::SetFootprints().

◆ GetFPID()

◆ GetLibrary()

const wxString& COMPONENT::GetLibrary ( ) const
inline

Definition at line 147 of file pcb_netlist.h.

147 { return m_library; }
wxString m_library
The name of the component library where m_name was found.
Definition: pcb_netlist.h:95

References m_library.

◆ GetModule()

MODULE* COMPONENT::GetModule ( bool  aRelease = false)
inline

Definition at line 184 of file pcb_netlist.h.

185  {
186  return ( aRelease ) ? m_footprint.release() : m_footprint.get();
187  }
std::unique_ptr< MODULE > m_footprint
The MODULE loaded for m_fpid.
Definition: pcb_netlist.h:107

References m_footprint.

◆ GetName()

const wxString& COMPONENT::GetName ( void  ) const
inline

Definition at line 144 of file pcb_netlist.h.

144 { return m_name; }
wxString m_name
The name of the component in m_library used when it was placed on the schematic..
Definition: pcb_netlist.h:92

References m_name.

◆ GetNet() [1/2]

const COMPONENT_NET& COMPONENT::GetNet ( unsigned  aIndex) const
inline

Definition at line 137 of file pcb_netlist.h.

137 { return m_nets[aIndex]; }
COMPONENT_NETS m_nets
list of nets shared by the component pins
Definition: pcb_netlist.h:82

References m_nets.

Referenced by TEST_NETLISTS_FIXTURE::compareNetlists(), BOARD_NETLIST_UPDATER::testConnectivity(), BOARD_NETLIST_UPDATER::updateComponentPadConnections(), and BOARD_NETLIST_UPDATER::updateCopperZoneNets().

◆ GetNet() [2/2]

const COMPONENT_NET & COMPONENT::GetNet ( const wxString &  aPinName) const

Definition at line 64 of file pcb_netlist.cpp.

65 {
66  for( unsigned i = 0; i < m_nets.size(); i++ )
67  {
68  if( m_nets[i].GetPinName() == aPinName )
69  return m_nets[i];
70  }
71 
72  return m_emptyNet;
73 }
static COMPONENT_NET m_emptyNet
Definition: pcb_netlist.h:112
COMPONENT_NETS m_nets
list of nets shared by the component pins
Definition: pcb_netlist.h:82

References m_emptyNet, and m_nets.

◆ GetNetCount()

unsigned COMPONENT::GetNetCount ( ) const
inline

Definition at line 135 of file pcb_netlist.h.

135 { return m_nets.size(); }
COMPONENT_NETS m_nets
list of nets shared by the component pins
Definition: pcb_netlist.h:82

References m_nets.

Referenced by TEST_NETLISTS_FIXTURE::compareNetlists(), BOARD_NETLIST_UPDATER::testConnectivity(), and BOARD_NETLIST_UPDATER::updateCopperZoneNets().

◆ GetPath()

const KIID_PATH& COMPONENT::GetPath ( ) const
inline

Definition at line 168 of file pcb_netlist.h.

168 { return m_path; }
KIID_PATH m_path
A fully specified path to the component: [ sheetUUID, sheetUUID, .., componentUUID ].
Definition: pcb_netlist.h:89

References m_path.

Referenced by TEST_NETLISTS_FIXTURE::compareNetlists(), PCB_EDIT_FRAME::LoadFootprints(), BOARD_NETLIST_UPDATER::updateComponentParameters(), and BOARD_NETLIST_UPDATER::UpdateNetlist().

◆ GetPinCount()

int COMPONENT::GetPinCount ( ) const
inline

Definition at line 182 of file pcb_netlist.h.

182 { return m_pinCount; }
int m_pinCount
Number of pins found in netlist.
Definition: pcb_netlist.h:84

References m_pinCount.

Referenced by CVPCB_MAINFRAME::DisplayStatus(), and FOOTPRINTS_LISTBOX::SetFootprints().

◆ GetReference()

◆ GetValue()

const wxString& COMPONENT::GetValue ( ) const
inline

◆ IsLibSource()

bool COMPONENT::IsLibSource ( const wxString &  aLibrary,
const wxString &  aName 
) const
inline

Definition at line 191 of file pcb_netlist.h.

192  {
193  return aLibrary == m_library && aName == m_name;
194  }
wxString m_name
The name of the component in m_library used when it was placed on the schematic..
Definition: pcb_netlist.h:92
wxString m_library
The name of the component library where m_name was found.
Definition: pcb_netlist.h:95

References m_library, and m_name.

Referenced by KICAD_NETLIST_PARSER::parseLibPartList().

◆ SetAltFPID()

void COMPONENT::SetAltFPID ( const LIB_ID aFPID)
inline

Definition at line 159 of file pcb_netlist.h.

160  {
161  m_altFpid = aFPID;
162  }
LIB_ID m_altFpid
The alt LIB_ID of the footprint, when there are 2 different assigned footprints, One from the netlist...
Definition: pcb_netlist.h:104

References m_altFpid.

Referenced by CMP_READER::Load().

◆ SetFootprintFilters()

void COMPONENT::SetFootprintFilters ( const wxArrayString &  aFilterList)
inline

Definition at line 170 of file pcb_netlist.h.

171  {
172  m_footprintFilters = aFilterList;
173  }
wxArrayString m_footprintFilters
Footprint filters found in netlist.
Definition: pcb_netlist.h:83

References m_footprintFilters.

Referenced by LEGACY_NETLIST_READER::loadFootprintFilters(), and KICAD_NETLIST_PARSER::parseLibPartList().

◆ SetFPID()

void COMPONENT::SetFPID ( const LIB_ID aFPID)
inline

Definition at line 153 of file pcb_netlist.h.

154  {
155  m_footprintChanged = !m_fpid.empty() && (m_fpid != aFPID);
156  m_fpid = aFPID;
157  }
bool empty() const
Definition: lib_id.h:186
bool m_footprintChanged
Set to true if m_fpid was changed when the footprint link file was read.
Definition: pcb_netlist.h:110
LIB_ID m_fpid
The LIB_ID of the footprint assigned to the component.
Definition: pcb_netlist.h:98

References LIB_ID::empty(), m_footprintChanged, and m_fpid.

Referenced by CVPCB_MAINFRAME::AssociateFootprint(), CMP_READER::Load(), CVPCB_MAINFRAME::ReadNetListAndFpFiles(), and CVPCB_MAINFRAME::ReadSchematicNetlist().

◆ SetLibrary()

void COMPONENT::SetLibrary ( const wxString &  aLibrary)
inline

Definition at line 146 of file pcb_netlist.h.

146 { m_library = aLibrary; }
wxString m_library
The name of the component library where m_name was found.
Definition: pcb_netlist.h:95

References m_library.

Referenced by KICAD_NETLIST_PARSER::parseComponent().

◆ SetModule()

void COMPONENT::SetModule ( MODULE aModule)

Definition at line 47 of file pcb_netlist.cpp.

48 {
49  m_footprint.reset( aModule );
50 
51  if( aModule == NULL )
52  return;
53 
54  aModule->SetReference( m_reference );
55  aModule->SetValue( m_value );
56  aModule->SetFPID( m_fpid );
57  aModule->SetPath( m_path );
58 }
KIID_PATH m_path
A fully specified path to the component: [ sheetUUID, sheetUUID, .., componentUUID ].
Definition: pcb_netlist.h:89
#define NULL
void SetReference(const wxString &aReference)
Function SetReference.
Definition: class_module.h:443
LIB_ID m_fpid
The LIB_ID of the footprint assigned to the component.
Definition: pcb_netlist.h:98
wxString m_value
The component value found in netlist.
Definition: pcb_netlist.h:86
void SetValue(const wxString &aValue)
Function SetValue.
Definition: class_module.h:467
wxString m_reference
The component reference designator found in netlist.
Definition: pcb_netlist.h:85
void SetPath(const KIID_PATH &aPath)
Definition: class_module.h:225
std::unique_ptr< MODULE > m_footprint
The MODULE loaded for m_fpid.
Definition: pcb_netlist.h:107
void SetFPID(const LIB_ID &aFPID)
Definition: class_module.h:216

References m_footprint, m_fpid, m_path, m_reference, m_value, NULL, MODULE::SetFPID(), MODULE::SetPath(), MODULE::SetReference(), and MODULE::SetValue().

Referenced by PCB_EDIT_FRAME::LoadFootprints().

◆ SetName()

void COMPONENT::SetName ( const wxString &  aName)
inline

Definition at line 143 of file pcb_netlist.h.

143 { m_name = aName;}
wxString m_name
The name of the component in m_library used when it was placed on the schematic..
Definition: pcb_netlist.h:92

References m_name.

Referenced by LEGACY_NETLIST_READER::loadComponent(), and KICAD_NETLIST_PARSER::parseComponent().

◆ SetPinCount()

void COMPONENT::SetPinCount ( int  aPinCount)
inline

Definition at line 177 of file pcb_netlist.h.

178  {
179  m_pinCount = aPinCount;
180  }
int m_pinCount
Number of pins found in netlist.
Definition: pcb_netlist.h:84

References m_pinCount.

Referenced by KICAD_NETLIST_PARSER::parseLibPartList().

◆ SortPins()

void COMPONENT::SortPins ( )
inline

Definition at line 141 of file pcb_netlist.h.

141 { sort( m_nets.begin(), m_nets.end() ); }
COMPONENT_NETS m_nets
list of nets shared by the component pins
Definition: pcb_netlist.h:82

References m_nets.

Member Data Documentation

◆ m_altFpid

LIB_ID COMPONENT::m_altFpid
private

The alt LIB_ID of the footprint, when there are 2 different assigned footprints, One from the netlist, the other from the .cmp file.

this one is a copy of the netlist footprint assignment

Definition at line 104 of file pcb_netlist.h.

Referenced by GetAltFPID(), and SetAltFPID().

◆ m_emptyNet

COMPONENT_NET COMPONENT::m_emptyNet
staticprivate

Definition at line 112 of file pcb_netlist.h.

Referenced by GetNet().

◆ m_footprint

std::unique_ptr< MODULE > COMPONENT::m_footprint
private

The MODULE loaded for m_fpid.

Definition at line 107 of file pcb_netlist.h.

Referenced by GetModule(), and SetModule().

◆ m_footprintChanged

bool COMPONENT::m_footprintChanged
private

Set to true if m_fpid was changed when the footprint link file was read.

Definition at line 110 of file pcb_netlist.h.

Referenced by COMPONENT(), FootprintChanged(), and SetFPID().

◆ m_footprintFilters

wxArrayString COMPONENT::m_footprintFilters
private

Footprint filters found in netlist.

Definition at line 83 of file pcb_netlist.h.

Referenced by Format(), GetFootprintFilters(), and SetFootprintFilters().

◆ m_fpid

LIB_ID COMPONENT::m_fpid
private

The LIB_ID of the footprint assigned to the component.

Definition at line 98 of file pcb_netlist.h.

Referenced by COMPONENT(), Format(), GetFPID(), SetFPID(), and SetModule().

◆ m_library

wxString COMPONENT::m_library
private

The name of the component library where m_name was found.

Definition at line 95 of file pcb_netlist.h.

Referenced by Format(), GetLibrary(), IsLibSource(), and SetLibrary().

◆ m_name

wxString COMPONENT::m_name
private

The name of the component in m_library used when it was placed on the schematic..

Definition at line 92 of file pcb_netlist.h.

Referenced by Format(), GetName(), IsLibSource(), and SetName().

◆ m_nets

COMPONENT_NETS COMPONENT::m_nets
private

list of nets shared by the component pins

Definition at line 82 of file pcb_netlist.h.

Referenced by AddNet(), Format(), GetNet(), GetNetCount(), and SortPins().

◆ m_path

KIID_PATH COMPONENT::m_path
private

A fully specified path to the component: [ sheetUUID, sheetUUID, .., componentUUID ].

Definition at line 89 of file pcb_netlist.h.

Referenced by COMPONENT(), Format(), GetPath(), and SetModule().

◆ m_pinCount

int COMPONENT::m_pinCount
private

Number of pins found in netlist.

Definition at line 84 of file pcb_netlist.h.

Referenced by COMPONENT(), GetPinCount(), and SetPinCount().

◆ m_reference

wxString COMPONENT::m_reference
private

The component reference designator found in netlist.

Definition at line 85 of file pcb_netlist.h.

Referenced by COMPONENT(), Format(), GetReference(), and SetModule().

◆ m_value

wxString COMPONENT::m_value
private

The component value found in netlist.

Definition at line 86 of file pcb_netlist.h.

Referenced by COMPONENT(), Format(), GetValue(), and SetModule().


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