KiCad PCB EDA Suite
NETCLASSES Class Reference

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...
 
NETCLASSGetDefaultPtr () const
 
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

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 221 of file netclass.h.

Member Typedef Documentation

◆ const_iterator

typedef NETCLASS_MAP::const_iterator NETCLASSES::const_iterator

Definition at line 248 of file netclass.h.

◆ iterator

typedef NETCLASS_MAP::iterator NETCLASSES::iterator

Definition at line 244 of file netclass.h.

Constructor & Destructor Documentation

◆ NETCLASSES()

NETCLASSES::NETCLASSES ( )

Definition at line 89 of file netclass.cpp.

90 {
91  m_default = std::make_shared<NETCLASS>( NETCLASS::Default );
92 }
NETCLASSPTR m_default
the default NETCLASS
Definition: netclass.h:229
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 95 of file netclass.cpp.

96 {
97 }

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 100 of file netclass.cpp.

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

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

Referenced by LEGACY_PLUGIN::loadNETCLASS(), NET_SETTINGS::NET_SETTINGS(), ALTIUM_PCB::ParseClasses6Data(), and PANEL_SETUP_NETCLASSES::TransferDataFromWindow().

◆ begin() [1/2]

iterator NETCLASSES::begin ( )
inline

◆ begin() [2/2]

const_iterator NETCLASSES::begin ( ) const
inline

Definition at line 249 of file netclass.h.

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

◆ Clear()

void NETCLASSES::Clear ( )
inline

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

Definition at line 239 of file netclass.h.

240  {
241  m_NetClasses.clear();
242  }
NETCLASS_MAP m_NetClasses
all the NETCLASSes except the default one.
Definition: netclass.h:226

Referenced by PCBNEW_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 250 of file netclass.h.

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

◆ 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 142 of file netclass.cpp.

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

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

Referenced by Add(), BOARD_DESIGN_SETTINGS::GetCurrentMicroViaDrill(), BOARD_DESIGN_SETTINGS::GetCurrentMicroViaSize(), PNS::SIZES_SETTINGS::Init(), DRC_RULES_PARSER::parseDRC_SELECTOR(), 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 256 of file netclass.h.

257  {
258  return m_NetClasses.size();
259  }
NETCLASS_MAP m_NetClasses
all the NETCLASSes except the default one.
Definition: netclass.h:226

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

◆ GetDefault()

◆ GetDefaultPtr()

NETCLASS* NETCLASSES::GetDefaultPtr ( ) const
inline

Definition at line 270 of file netclass.h.

271  {
272  return m_default.get();
273  }
NETCLASSPTR m_default
the default NETCLASS
Definition: netclass.h:229

Referenced by DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::buildFilterLists(), and BOARD_DESIGN_SETTINGS::GetDefault().

◆ NetClasses()

NETCLASS_MAP& NETCLASSES::NetClasses ( )
inline

Provide public access to m_NetClasses so it gets swigged.

Definition at line 301 of file netclass.h.

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

◆ 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 127 of file netclass.cpp.

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

References m_NetClasses.

Member Data Documentation

◆ m_default

NETCLASSPTR NETCLASSES::m_default
private

the default NETCLASS

Definition at line 229 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 226 of file netclass.h.

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


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