KiCad PCB EDA Suite
NETCLASSES Class Reference

Class NETCLASSES is 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 ()
 Function Clear destroys any contained NETCLASS instances except the Default one. More...
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
unsigned GetCount () const
 Function GetCount. More...
 
NETCLASSPTR GetDefault () const
 Function GetDefault. More...
 
bool Add (const NETCLASSPTR &aNetclass)
 Function Add takes aNetclass and puts it into this NETCLASSES container. More...
 
NETCLASSPTR Remove (const wxString &aNetName)
 Function Remove removes a NETCLASS from this container but does not destroy/delete it. More...
 
NETCLASSPTR Find (const wxString &aName) const
 Function Find searches 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
 all the NETCLASSes except the default one. More...
 
NETCLASSPTR m_default
 the default NETCLASS More...
 

Detailed Description

Class NETCLASSES is a container for NETCLASS instances.

It owns all its NETCLASSes (=> it will delete them at time of destruction). This container will always have a default NETCLASS with the name given by const NETCLASS::Default.

Definition at line 224 of file netclass.h.

Member Typedef Documentation

◆ const_iterator

typedef NETCLASS_MAP::const_iterator NETCLASSES::const_iterator

Definition at line 251 of file netclass.h.

◆ iterator

typedef NETCLASS_MAP::iterator NETCLASSES::iterator

Definition at line 247 of file netclass.h.

Constructor & Destructor Documentation

◆ NETCLASSES()

NETCLASSES::NETCLASSES ( )

Definition at line 88 of file netclass.cpp.

89 {
90  m_default = std::make_shared<NETCLASS>( NETCLASS::Default );
91 }
NETCLASSPTR m_default
the default NETCLASS
Definition: netclass.h:232
static const char Default[]
the name of the default NETCLASS
Definition: netclass.h:80

References NETCLASS::Default, and m_default.

◆ ~NETCLASSES()

NETCLASSES::~NETCLASSES ( )

Definition at line 94 of file netclass.cpp.

95 {
96 }

Member Function Documentation

◆ Add()

bool NETCLASSES::Add ( const NETCLASSPTR &  aNetclass)

Function Add takes 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 99 of file netclass.cpp.

100 {
101  const wxString& name = aNetClass->GetName();
102 
103  if( name == NETCLASS::Default )
104  {
105  m_default = aNetClass;
106  return true;
107  }
108 
109  // Test for an existing netclass:
110  if( !Find( name ) )
111  {
112  // name not found, take ownership
113  m_NetClasses[name] = aNetClass;
114 
115  return true;
116  }
117  else
118  {
119  // name already exists
120  // do not "take ownership" and return false telling caller such.
121  return false;
122  }
123 }
NETCLASSPTR Find(const wxString &aName) const
Function Find searches this container for a NETCLASS given by aName.
Definition: netclass.cpp:141
NETCLASSPTR m_default
the default NETCLASS
Definition: netclass.h:232
static const char Default[]
the name of the default NETCLASS
Definition: netclass.h:80
const char * name
Definition: DXF_plotter.cpp:61
NETCLASS_MAP m_NetClasses
all the NETCLASSes except the default one.
Definition: netclass.h:229

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

Referenced by LEGACY_PLUGIN::loadNETCLASS(), PARAM_CFG_NETCLASSES::ReadParam(), and PANEL_SETUP_NETCLASSES::TransferDataFromWindow().

◆ begin() [1/2]

◆ begin() [2/2]

const_iterator NETCLASSES::begin ( ) const
inline

Definition at line 252 of file netclass.h.

252 { return m_NetClasses.begin(); }
NETCLASS_MAP m_NetClasses
all the NETCLASSes except the default one.
Definition: netclass.h:229

References begin(), and BOARD_DESIGN_SETTINGS::m_NetClasses.

◆ Clear()

void NETCLASSES::Clear ( )
inline

Function Clear destroys any contained NETCLASS instances except the Default one.

Definition at line 242 of file netclass.h.

243  {
244  m_NetClasses.clear();
245  }
NETCLASS_MAP m_NetClasses
all the NETCLASSes except the default one.
Definition: netclass.h:229

References BOARD_DESIGN_SETTINGS::m_NetClasses.

Referenced by PCBNEW_CONTROL::AppendBoard(), PCB_EDIT_FRAME::AppendBoardFile(), PARAM_CFG_NETCLASSES::ReadParam(), and PANEL_SETUP_NETCLASSES::TransferDataFromWindow().

◆ end() [1/2]

◆ end() [2/2]

const_iterator NETCLASSES::end ( ) const
inline

Definition at line 253 of file netclass.h.

253 { return m_NetClasses.end(); }
NETCLASS_MAP m_NetClasses
all the NETCLASSes except the default one.
Definition: netclass.h:229

References end(), and BOARD_DESIGN_SETTINGS::m_NetClasses.

◆ Find()

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

Function Find searches this container for a NETCLASS given by aName.

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

Definition at line 141 of file netclass.cpp.

142 {
143  if( aName == NETCLASS::Default )
144  return GetDefault();
145 
146  NETCLASS_MAP::const_iterator found = m_NetClasses.find( aName );
147 
148  if( found == m_NetClasses.end() )
149  return NETCLASSPTR();
150  else
151  return found->second;
152 }
static const char Default[]
the name of the default NETCLASS
Definition: netclass.h:80
NETCLASSPTR GetDefault() const
Function GetDefault.
Definition: netclass.h:268
NETCLASS_MAP m_NetClasses
all the NETCLASSes except the default one.
Definition: netclass.h:229

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

Referenced by Add(), BOARD_DESIGN_SETTINGS::GetCurrentMicroViaDrill(), BOARD_DESIGN_SETTINGS::GetCurrentMicroViaSize(), PNS::SIZES_SETTINGS::Init(), PNS_PCBNEW_RULE_RESOLVER::PNS_PCBNEW_RULE_RESOLVER(), BOARD_DESIGN_SETTINGS::SetCurrentNetClass(), BOARD::SynchronizeNetsAndNetClasses(), and PANEL_SETUP_NETCLASSES::TransferDataFromWindow().

◆ GetCount()

unsigned NETCLASSES::GetCount ( ) const
inline

Function GetCount.

Returns
the number of netclasses, excluding the default one.

Definition at line 259 of file netclass.h.

260  {
261  return m_NetClasses.size();
262  }
NETCLASS_MAP m_NetClasses
all the NETCLASSes except the default one.
Definition: netclass.h:229

References BOARD_DESIGN_SETTINGS::m_NetClasses.

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

◆ GetDefault()

◆ NetClasses()

NETCLASS_MAP& NETCLASSES::NetClasses ( )
inline

Provide public access to m_NetClasses so it gets swigged.

Definition at line 299 of file netclass.h.

299 { return m_NetClasses; }
NETCLASS_MAP m_NetClasses
all the NETCLASSes except the default one.
Definition: netclass.h:229

References BOARD_DESIGN_SETTINGS::m_NetClasses.

◆ Remove()

NETCLASSPTR NETCLASSES::Remove ( const wxString &  aNetName)

Function Remove removes 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
NETCLASSPTR - the NETCLASS associated with aNetName if found and removed, else NULL.

Definition at line 126 of file netclass.cpp.

127 {
128  NETCLASS_MAP::iterator found = m_NetClasses.find( aNetName );
129 
130  if( found != m_NetClasses.end() )
131  {
132  std::shared_ptr<NETCLASS> netclass = found->second;
133  m_NetClasses.erase( found );
134  return netclass;
135  }
136 
137  return NETCLASSPTR();
138 }
NETCLASS_MAP m_NetClasses
all the NETCLASSes except the default one.
Definition: netclass.h:229

References m_NetClasses.

Member Data Documentation

◆ m_default

NETCLASSPTR NETCLASSES::m_default
private

the default NETCLASS

Definition at line 232 of file netclass.h.

Referenced by Add(), and NETCLASSES().

◆ m_NetClasses

NETCLASS_MAP NETCLASSES::m_NetClasses
private

all the NETCLASSes except the default one.

Definition at line 229 of file netclass.h.

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


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