KiCad PCB EDA Suite
NETCLASSES Class Reference

A container for NETCLASS instances. More...

#include <netclass.h>

Public Types

typedef NETCLASS_MAP::iterator iterator
 
typedef NETCLASS_MAP::const_iterator const_iterator
 

Public Member Functions

 NETCLASSES ()
 
 ~NETCLASSES ()
 
void Clear ()
 Destroy any contained NETCLASS instances except the default one, and clears any members from the default one. More...
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
unsigned GetCount () const
 
NETCLASSPTR GetDefault () const
 
NETCLASSGetDefaultPtr () const
 
bool Add (const NETCLASSPTR &aNetclass)
 Add aNetclass and puts it into this NETCLASSES container. More...
 
NETCLASSPTR Remove (const wxString &aNetName)
 Remove a NETCLASS from this container but does not destroy/delete it. More...
 
NETCLASSPTR Find (const wxString &aName) const
 Search this container for a NETCLASS given by aName. More...
 
NETCLASS_MAP & NetClasses ()
 Provide public access to m_NetClasses so it gets swigged. More...
 

Private Attributes

NETCLASS_MAP m_NetClasses
 
NETCLASSPTR m_default
 

Detailed Description

A container for NETCLASS instances.

It owns all its NETCLASSes. This container will always have a default NETCLASS with the name given by const NETCLASS::Default.

Definition at line 218 of file netclass.h.

Member Typedef Documentation

◆ const_iterator

typedef NETCLASS_MAP::const_iterator NETCLASSES::const_iterator

Definition at line 238 of file netclass.h.

◆ iterator

typedef NETCLASS_MAP::iterator NETCLASSES::iterator

Definition at line 234 of file netclass.h.

Constructor & Destructor Documentation

◆ NETCLASSES()

NETCLASSES::NETCLASSES ( )

Definition at line 79 of file netclass.cpp.

80 {
81  m_default = std::make_shared<NETCLASS>( NETCLASS::Default );
82 }
NETCLASSPTR m_default
Definition: netclass.h:294
static const char Default[]
the name of the default NETCLASS
Definition: netclass.h:49

References NETCLASS::Default, and m_default.

◆ ~NETCLASSES()

NETCLASSES::~NETCLASSES ( )

Definition at line 85 of file netclass.cpp.

86 {
87 }

Member Function Documentation

◆ Add()

bool NETCLASSES::Add ( const NETCLASSPTR &  aNetclass)

Add aNetclass and puts it into this NETCLASSES container.

Parameters
aNetclassis netclass to add
Returns
true if the name within aNetclass is unique and it could be inserted OK, else false because the name was not unique.

Definition at line 90 of file netclass.cpp.

91 {
92  const wxString& name = aNetClass->GetName();
93 
94  if( name == NETCLASS::Default )
95  {
96  m_default = aNetClass;
97  return true;
98  }
99 
100  // Test for an existing netclass:
101  if( !Find( name ) )
102  {
103  // name not found, take ownership
104  m_NetClasses[name] = aNetClass;
105 
106  return true;
107  }
108  else
109  {
110  // name already exists
111  // do not "take ownership" and return false telling caller such.
112  return false;
113  }
114 }
NETCLASSPTR Find(const wxString &aName) const
Search this container for a NETCLASS given by aName.
Definition: netclass.cpp:132
NETCLASSPTR m_default
Definition: netclass.h:294
static const char Default[]
the name of the default NETCLASS
Definition: netclass.h:49
const char * name
Definition: DXF_plotter.cpp:56
NETCLASS_MAP m_NetClasses
Definition: netclass.h:293

References NETCLASS::Default, Find(), m_default, m_NetClasses, and name.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::getKiCadNet(), EAGLE_PLUGIN::loadClasses(), LEGACY_PLUGIN::loadNETCLASS(), NET_SETTINGS::NET_SETTINGS(), ALTIUM_PCB::ParseClasses6Data(), and PANEL_SETUP_NETCLASSES::TransferDataFromWindow().

◆ begin() [1/2]

◆ begin() [2/2]

const_iterator NETCLASSES::begin ( ) const
inline

Definition at line 239 of file netclass.h.

239 { return m_NetClasses.begin(); }
NETCLASS_MAP m_NetClasses
Definition: netclass.h:293

◆ Clear()

void NETCLASSES::Clear ( )
inline

Destroy any contained NETCLASS instances except the default one, and clears any members from the default one.

Definition at line 228 of file netclass.h.

229  {
230  m_NetClasses.clear();
231  m_default->Clear();
232  }
NETCLASSPTR m_default
Definition: netclass.h:294
NETCLASS_MAP m_NetClasses
Definition: netclass.h:293

Referenced by PCB_CONTROL::AppendBoard(), NET_SETTINGS::NET_SETTINGS(), and PANEL_SETUP_NETCLASSES::TransferDataFromWindow().

◆ end() [1/2]

iterator NETCLASSES::end ( )
inline

◆ end() [2/2]

const_iterator NETCLASSES::end ( ) const
inline

Definition at line 240 of file netclass.h.

240 { return m_NetClasses.end(); }
NETCLASS_MAP m_NetClasses
Definition: netclass.h:293

◆ Find()

NETCLASSPTR NETCLASSES::Find ( const wxString &  aName) const

Search this container for a NETCLASS given by aName.

Parameters
aNameis the name of the NETCLASS to search for.
Returns
a pointer to the NETCLASS if found, else NULL.

Definition at line 132 of file netclass.cpp.

133 {
134  if( aName == NETCLASS::Default )
135  return GetDefault();
136 
137  NETCLASS_MAP::const_iterator found = m_NetClasses.find( aName );
138 
139  if( found == m_NetClasses.end() )
140  return NETCLASSPTR();
141  else
142  return found->second;
143 }
static const char Default[]
the name of the default NETCLASS
Definition: netclass.h:49
NETCLASSPTR GetDefault() const
Definition: netclass.h:253
NETCLASS_MAP m_NetClasses
Definition: netclass.h:293

References NETCLASS::Default, GetDefault(), and m_NetClasses.

Referenced by Add(), SCH_EDITOR_CONTROL::AssignNetclass(), BOARD_DESIGN_SETTINGS::GetCurrentMicroViaDrill(), BOARD_DESIGN_SETTINGS::GetCurrentMicroViaSize(), SCH_EDIT_FRAME::KiwayMailIn(), SCH_ITEM::NetClass(), APPEARANCE_CONTROLS::onNetclassContextMenu(), APPEARANCE_CONTROLS::showNetclass(), BOARD::SynchronizeNetsAndNetClasses(), and PANEL_SETUP_NETCLASSES::TransferDataFromWindow().

◆ GetCount()

unsigned NETCLASSES::GetCount ( ) const
inline
Returns
the number of netclasses excluding the default one.

Definition at line 245 of file netclass.h.

246  {
247  return m_NetClasses.size();
248  }
NETCLASS_MAP m_NetClasses
Definition: netclass.h:293

Referenced by DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::buildNetclassesGrid(), NET_SETTINGS::NET_SETTINGS(), and PANEL_SETUP_NETCLASSES::TransferDataToWindow().

◆ GetDefault()

◆ GetDefaultPtr()

◆ NetClasses()

NETCLASS_MAP& NETCLASSES::NetClasses ( )
inline

Provide public access to m_NetClasses so it gets swigged.

Definition at line 290 of file netclass.h.

290 { return m_NetClasses; }
NETCLASS_MAP m_NetClasses
Definition: netclass.h:293

Referenced by APPEARANCE_CONTROLS::onNetclassContextMenu(), and APPEARANCE_CONTROLS::rebuildNets().

◆ Remove()

NETCLASSPTR NETCLASSES::Remove ( const wxString &  aNetName)

Remove a NETCLASS from this container but does not destroy/delete it.

Parameters
aNetNameis the name of the net to delete, and it may not be NETCLASS::Default.
Returns
a pointer to the NETCLASS associated with aNetName if found and removed, else NULL.

Definition at line 117 of file netclass.cpp.

118 {
119  NETCLASS_MAP::iterator found = m_NetClasses.find( aNetName );
120 
121  if( found != m_NetClasses.end() )
122  {
123  std::shared_ptr<NETCLASS> netclass = found->second;
124  m_NetClasses.erase( found );
125  return netclass;
126  }
127 
128  return NETCLASSPTR();
129 }
NETCLASS_MAP m_NetClasses
Definition: netclass.h:293

References m_NetClasses.

Member Data Documentation

◆ m_default

NETCLASSPTR NETCLASSES::m_default
private

Definition at line 294 of file netclass.h.

Referenced by Add(), and NETCLASSES().

◆ m_NetClasses

NETCLASS_MAP NETCLASSES::m_NetClasses
private

Definition at line 293 of file netclass.h.

Referenced by Add(), Find(), and Remove().


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