KiCad PCB EDA Suite
COMPONENT Class Reference

Store all of the related footprint 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, const std::vector< KIID > &aKiids)
 
virtual ~COMPONENT ()
 
void AddNet (const wxString &aPinName, const wxString &aNetName, const wxString &aPinFunction, const wxString &aPinType)
 
unsigned GetNetCount () const
 
const COMPONENT_NETGetNet (unsigned aIndex) const
 
const COMPONENT_NETGetNet (const wxString &aPinName) const
 
void ClearNets ()
 
void SortPins ()
 
void SetName (const wxString &aName)
 
const wxString & GetName () const
 
void SetLibrary (const wxString &aLibrary)
 
const wxString & GetLibrary () const
 
void SetReference (const wxString &aReference)
 
const wxString & GetReference () const
 
void SetValue (const wxString &aValue)
 
const wxString & GetValue () const
 
void SetProperties (std::map< wxString, wxString > &aProps)
 
const std::map< wxString, wxString > & GetProperties () const
 
void SetFPID (const LIB_ID &aFPID)
 
const LIB_IDGetFPID () const
 
void SetAltFPID (const LIB_ID &aFPID)
 
const LIB_IDGetAltFPID () const
 
const KIID_PATHGetPath () const
 
const std::vector< KIID > & GetKIIDs () const
 
void SetFootprintFilters (const wxArrayString &aFilters)
 
const wxArrayString & GetFootprintFilters () const
 
void SetPinCount (int aPinCount)
 
int GetPinCount () const
 
FOOTPRINTGetFootprint (bool aRelease=false)
 
void SetFootprint (FOOTPRINT *aFootprint)
 
bool IsLibSource (const wxString &aLibrary, const wxString &aName) const
 
void Format (OUTPUTFORMATTER *aOut, int aNestLevel, int aCtl)
 

Private Attributes

std::vector< COMPONENT_NETm_nets
 list of nets shared by the component pins More...
 
wxArrayString m_footprintFilters
 
int m_pinCount
 
wxString m_reference
 
wxString m_value
 
KIID_PATH m_path
 A fully specified path to the component (but not the component: [ sheetUUID, sheetUUID, .. ]. More...
 
std::vector< KIIDm_kiids
 A vector of possible KIIDs corresponding to all units in a symbol. 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< FOOTPRINTm_footprint
 The FOOTPRINT loaded for #m_FPID. More...
 
std::map< wxString, wxString > m_properties
 Component-specific properties found in the netlist. More...
 

Static Private Attributes

static COMPONENT_NET m_emptyNet
 

Detailed Description

Store all of the related footprint information found in a netlist.

Definition at line 84 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,
const std::vector< KIID > &  aKiids 
)
inline

Definition at line 87 of file pcb_netlist.h.

92 {
93 m_fpid = aFPID;
94 m_reference = aReference;
95 m_value = aValue;
96 m_pinCount = 0;
97 m_path = aPath;
98 m_kiids = aKiids;
99 }
int m_pinCount
Definition: pcb_netlist.h:171
KIID_PATH m_path
A fully specified path to the component (but not the component: [ sheetUUID, sheetUUID,...
Definition: pcb_netlist.h:176
wxString m_value
Definition: pcb_netlist.h:173
std::vector< KIID > m_kiids
A vector of possible KIIDs corresponding to all units in a symbol.
Definition: pcb_netlist.h:179
wxString m_reference
Definition: pcb_netlist.h:172
LIB_ID m_fpid
The LIB_ID of the footprint assigned to the component.
Definition: pcb_netlist.h:188

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

◆ ~COMPONENT()

virtual COMPONENT::~COMPONENT ( )
inlinevirtual

Definition at line 101 of file pcb_netlist.h.

101{ };

Member Function Documentation

◆ AddNet()

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

Definition at line 103 of file pcb_netlist.h.

105 {
106 m_nets.emplace_back( aPinName, aNetName, aPinFunction, aPinType );
107 }
std::vector< COMPONENT_NET > m_nets
list of nets shared by the component pins
Definition: pcb_netlist.h:168

References m_nets.

Referenced by BOARD_EDITOR_CONTROL::ExportNetlist(), PCB_EDIT_FRAME::KiwayMailIn(), FOOTPRINT_VIEWER_FRAME::KiwayMailIn(), LEGACY_NETLIST_READER::loadNet(), and KICAD_NETLIST_PARSER::parseNet().

◆ ClearNets()

void COMPONENT::ClearNets ( )
inline

Definition at line 115 of file pcb_netlist.h.

115{ m_nets.clear(); }

References m_nets.

Referenced by FOOTPRINT_VIEWER_FRAME::KiwayMailIn().

◆ Format()

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

Definition at line 74 of file pcb_netlist.cpp.

75{
76 int nl = aNestLevel;
77
78 aOut->Print( nl, "(ref %s ", aOut->Quotew( m_reference ).c_str() );
79 aOut->Print( 0, "(fpid %s)\n", aOut->Quotew( m_fpid.Format() ).c_str() );
80
81 if( !( aCtl & CTL_OMIT_EXTRA ) )
82 {
83 aOut->Print( nl+1, "(value %s)\n", aOut->Quotew( m_value ).c_str() );
84 aOut->Print( nl+1, "(name %s)\n", aOut->Quotew( m_name ).c_str() );
85 aOut->Print( nl+1, "(library %s)\n", aOut->Quotew( m_library ).c_str() );
86
87 wxString path;
88
89 for( const KIID& pathStep : m_path )
90 path += '/' + pathStep.AsString();
91
92 if( !( aCtl & CTL_OMIT_FP_UUID ) && !m_kiids.empty() )
93 path += '/' + m_kiids.front().AsString();
94
95 aOut->Print( nl+1, "(timestamp %s)\n", aOut->Quotew( path ).c_str() );
96 }
97
98 if( !( aCtl & CTL_OMIT_FILTERS ) && m_footprintFilters.GetCount() )
99 {
100 aOut->Print( nl+1, "(fp_filters" );
101
102 for( unsigned i = 0; i < m_footprintFilters.GetCount(); ++i )
103 aOut->Print( 0, " %s", aOut->Quotew( m_footprintFilters[i] ).c_str() );
104
105 aOut->Print( 0, ")\n" );
106 }
107
108 if( !( aCtl & CTL_OMIT_NETS ) && m_nets.size() )
109 {
110 int llen = aOut->Print( nl+1, "(nets " );
111
112 for( unsigned i = 0; i < m_nets.size(); ++i )
113 {
114 if( llen > 80 )
115 {
116 aOut->Print( 0, "\n" );
117 llen = aOut->Print( nl+1, " " );
118 }
119
120 llen += m_nets[i].Format( aOut, 0, aCtl );
121 }
122
123 aOut->Print( 0, ")\n" );
124 }
125
126 aOut->Print( nl, ")\n" ); // </ref>
127}
wxArrayString m_footprintFilters
Definition: pcb_netlist.h:170
wxString m_name
The name of the component in m_library used when it was placed on the schematic.
Definition: pcb_netlist.h:182
wxString m_library
The name of the component library where m_name was found.
Definition: pcb_netlist.h:185
Definition: kiid.h:48
UTF8 Format() const
Definition: lib_id.cpp:117
std::string Quotew(const wxString &aWrapee) const
Definition: richio.cpp:499
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:431
#define CTL_OMIT_EXTRA
Definition: pcb_netlist.h:286
#define CTL_OMIT_NETS
Definition: pcb_netlist.h:287
#define CTL_OMIT_FP_UUID
Don't prefix the footprint UUID to the sheet path.
Definition: pcb_netlist.h:289
#define CTL_OMIT_FILTERS
Definition: pcb_netlist.h:288

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

◆ GetAltFPID()

const LIB_ID & COMPONENT::GetAltFPID ( ) const
inline

Definition at line 141 of file pcb_netlist.h.

141{ 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:193

References m_altFpid.

Referenced by CVPCB_MAINFRAME::readNetListAndFpFiles().

◆ GetFootprint()

FOOTPRINT * COMPONENT::GetFootprint ( bool  aRelease = false)
inline

Definition at line 153 of file pcb_netlist.h.

154 {
155 return ( aRelease ) ? m_footprint.release() : m_footprint.get();
156 }
std::unique_ptr< FOOTPRINT > m_footprint
The FOOTPRINT loaded for #m_FPID.
Definition: pcb_netlist.h:196

References m_footprint.

◆ GetFootprintFilters()

const wxArrayString & COMPONENT::GetFootprintFilters ( ) const
inline

◆ GetFPID()

◆ GetKIIDs()

◆ GetLibrary()

const wxString & COMPONENT::GetLibrary ( ) const
inline

Definition at line 123 of file pcb_netlist.h.

123{ return m_library; }

References m_library.

◆ GetName()

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

Definition at line 120 of file pcb_netlist.h.

120{ return m_name; }

References m_name.

◆ GetNet() [1/2]

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

Definition at line 62 of file pcb_netlist.cpp.

63{
64 for( const COMPONENT_NET& net : m_nets )
65 {
66 if( net.GetPinName() == aPinName )
67 return net;
68 }
69
70 return m_emptyNet;
71}
Used to store the component pin name to net name (and pin function) associations stored in a netlist.
Definition: pcb_netlist.h:44
static COMPONENT_NET m_emptyNet
Definition: pcb_netlist.h:201

References m_emptyNet, and m_nets.

◆ GetNet() [2/2]

◆ GetNetCount()

◆ GetPath()

◆ GetPinCount()

int COMPONENT::GetPinCount ( ) const
inline

Definition at line 151 of file pcb_netlist.h.

151{ return m_pinCount; }

References m_pinCount.

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

◆ GetProperties()

const std::map< wxString, wxString > & COMPONENT::GetProperties ( ) const
inline

Definition at line 135 of file pcb_netlist.h.

135{ return m_properties; }
std::map< wxString, wxString > m_properties
Component-specific properties found in the netlist.
Definition: pcb_netlist.h:199

References m_properties.

Referenced by BOARD_NETLIST_UPDATER::updateFootprintParameters(), and BOARD_NETLIST_UPDATER::UpdateNetlist().

◆ GetReference()

◆ GetValue()

◆ IsLibSource()

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

Definition at line 160 of file pcb_netlist.h.

161 {
162 return aLibrary == m_library && aName == m_name;
163 }

References m_library, and m_name.

Referenced by KICAD_NETLIST_PARSER::parseLibPartList().

◆ SetAltFPID()

void COMPONENT::SetAltFPID ( const LIB_ID aFPID)
inline

Definition at line 140 of file pcb_netlist.h.

140{ m_altFpid = aFPID; }

References m_altFpid.

Referenced by CMP_READER::Load().

◆ SetFootprint()

void COMPONENT::SetFootprint ( FOOTPRINT aFootprint)

Definition at line 40 of file pcb_netlist.cpp.

41{
42 m_footprint.reset( aFootprint );
44
45 if( !m_kiids.empty() )
46 path.push_back( m_kiids.front() );
47
48 if( aFootprint == nullptr )
49 return;
50
51 aFootprint->SetReference( m_reference );
52 aFootprint->SetValue( m_value );
53 aFootprint->SetFPID( m_fpid );
54 aFootprint->SetPath( path );
55 aFootprint->SetProperties( m_properties );
56}
void SetFPID(const LIB_ID &aFPID)
Definition: footprint.h:213
void SetPath(const KIID_PATH &aPath)
Definition: footprint.h:225
void SetReference(const wxString &aReference)
Definition: footprint.h:528
void SetValue(const wxString &aValue)
Definition: footprint.h:555
void SetProperties(const std::map< wxString, wxString > &aProps)
Definition: footprint.h:575

References m_footprint, m_fpid, m_kiids, m_path, m_properties, m_reference, m_value, path, FOOTPRINT::SetFPID(), FOOTPRINT::SetPath(), FOOTPRINT::SetProperties(), FOOTPRINT::SetReference(), and FOOTPRINT::SetValue().

Referenced by PCB_EDIT_FRAME::LoadFootprints().

◆ SetFootprintFilters()

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

◆ SetFPID()

void COMPONENT::SetFPID ( const LIB_ID aFPID)
inline

◆ SetLibrary()

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

Definition at line 122 of file pcb_netlist.h.

122{ m_library = aLibrary; }

References m_library.

Referenced by KICAD_NETLIST_PARSER::parseComponent().

◆ SetName()

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

Definition at line 119 of file pcb_netlist.h.

119{ m_name = aName;}

References m_name.

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

◆ SetPinCount()

void COMPONENT::SetPinCount ( int  aPinCount)
inline

Definition at line 150 of file pcb_netlist.h.

150{ m_pinCount = aPinCount; }

References m_pinCount.

Referenced by KICAD_NETLIST_PARSER::parseLibPartList().

◆ SetProperties()

void COMPONENT::SetProperties ( std::map< wxString, wxString > &  aProps)
inline

Definition at line 131 of file pcb_netlist.h.

132 {
133 m_properties = std::move( aProps );
134 }

References m_properties.

Referenced by KICAD_NETLIST_PARSER::parseComponent().

◆ SetReference()

void COMPONENT::SetReference ( const wxString &  aReference)
inline

Definition at line 125 of file pcb_netlist.h.

125{ m_reference = aReference; }

References m_reference.

Referenced by FOOTPRINT_VIEWER_FRAME::KiwayMailIn().

◆ SetValue()

void COMPONENT::SetValue ( const wxString &  aValue)
inline

Definition at line 128 of file pcb_netlist.h.

128{ m_value = aValue; }

References m_value.

Referenced by FOOTPRINT_VIEWER_FRAME::KiwayMailIn().

◆ SortPins()

void COMPONENT::SortPins ( )
inline

Definition at line 117 of file pcb_netlist.h.

117{ sort( m_nets.begin(), m_nets.end() ); }

References m_nets.

Referenced by KICAD_NETLIST_READER::LoadNetlist().

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 193 of file pcb_netlist.h.

Referenced by GetAltFPID(), and SetAltFPID().

◆ m_emptyNet

COMPONENT_NET COMPONENT::m_emptyNet
staticprivate

Definition at line 201 of file pcb_netlist.h.

Referenced by GetNet().

◆ m_footprint

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

The FOOTPRINT loaded for #m_FPID.

Definition at line 196 of file pcb_netlist.h.

Referenced by GetFootprint(), and SetFootprint().

◆ m_footprintFilters

wxArrayString COMPONENT::m_footprintFilters
private

Definition at line 170 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 188 of file pcb_netlist.h.

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

◆ m_kiids

std::vector<KIID> COMPONENT::m_kiids
private

A vector of possible KIIDs corresponding to all units in a symbol.

Definition at line 179 of file pcb_netlist.h.

Referenced by COMPONENT(), Format(), GetKIIDs(), and SetFootprint().

◆ m_library

wxString COMPONENT::m_library
private

The name of the component library where m_name was found.

Definition at line 185 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 182 of file pcb_netlist.h.

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

◆ m_nets

std::vector<COMPONENT_NET> COMPONENT::m_nets
private

list of nets shared by the component pins

Definition at line 168 of file pcb_netlist.h.

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

◆ m_path

KIID_PATH COMPONENT::m_path
private

A fully specified path to the component (but not the component: [ sheetUUID, sheetUUID, .. ].

Definition at line 176 of file pcb_netlist.h.

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

◆ m_pinCount

int COMPONENT::m_pinCount
private

Definition at line 171 of file pcb_netlist.h.

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

◆ m_properties

std::map<wxString, wxString> COMPONENT::m_properties
private

Component-specific properties found in the netlist.

Definition at line 199 of file pcb_netlist.h.

Referenced by GetProperties(), SetFootprint(), and SetProperties().

◆ m_reference

wxString COMPONENT::m_reference
private

Definition at line 172 of file pcb_netlist.h.

Referenced by COMPONENT(), Format(), GetReference(), SetFootprint(), and SetReference().

◆ m_value

wxString COMPONENT::m_value
private

Definition at line 173 of file pcb_netlist.h.

Referenced by COMPONENT(), Format(), GetValue(), SetFootprint(), and SetValue().


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