KiCad PCB EDA Suite
NETCLASSES Class Reference

Class NETCLASSES is a container for NETCLASS instances. More...

#include <class_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 (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 231 of file class_netclass.h.

Member Typedef Documentation

typedef NETCLASS_MAP::const_iterator NETCLASSES::const_iterator

Definition at line 258 of file class_netclass.h.

typedef NETCLASS_MAP::iterator NETCLASSES::iterator

Definition at line 254 of file class_netclass.h.

Constructor & Destructor Documentation

NETCLASSES::NETCLASSES ( )

Definition at line 91 of file class_netclass.cpp.

References NETCLASS::Default, and m_default.

92 {
93  m_default = std::make_shared<NETCLASS>( NETCLASS::Default );
94 }
NETCLASSPTR m_default
the default NETCLASS
static const char Default[]
the name of the default NETCLASS
NETCLASSES::~NETCLASSES ( )

Definition at line 97 of file class_netclass.cpp.

98 {
99 }

Member Function Documentation

bool NETCLASSES::Add ( 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 102 of file class_netclass.cpp.

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

Referenced by DIALOG_DESIGN_RULES::CopyRulesListToBoard(), and LEGACY_PLUGIN::loadNETCLASS().

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

Definition at line 259 of file class_netclass.h.

259 { return m_NetClasses.begin(); }
NETCLASS_MAP m_NetClasses
all the NETCLASSes except the default one.
void NETCLASSES::Clear ( )
inline

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

Definition at line 249 of file class_netclass.h.

Referenced by PCBNEW_CONTROL::AppendBoard(), PCB_EDIT_FRAME::AppendBoardFile(), and DIALOG_DESIGN_RULES::CopyRulesListToBoard().

250  {
251  m_NetClasses.clear();
252  }
NETCLASS_MAP m_NetClasses
all the NETCLASSes except the default one.
const_iterator NETCLASSES::end ( ) const
inline

Definition at line 260 of file class_netclass.h.

260 { return m_NetClasses.end(); }
NETCLASS_MAP m_NetClasses
all the NETCLASSes except the default one.
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 144 of file class_netclass.cpp.

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

Referenced by Add(), DIALOG_DESIGN_RULES::CopyRulesListToBoard(), BOARD_DESIGN_SETTINGS::GetCurrentMicroViaDrill(), BOARD_DESIGN_SETTINGS::GetCurrentMicroViaSize(), ROUTER_TOOL::getNetclassDimensions(), PNS::SIZES_SETTINGS::Init(), PNS_PCBNEW_RULE_RESOLVER::PNS_PCBNEW_RULE_RESOLVER(), BOARD_DESIGN_SETTINGS::SetCurrentNetClass(), and BOARD::SynchronizeNetsAndNetClasses().

145 {
146  if( aName == NETCLASS::Default )
147  return GetDefault();
148 
149  NETCLASS_MAP::const_iterator found = m_NetClasses.find( aName );
150 
151  if( found == m_NetClasses.end() )
152  return NETCLASSPTR();
153  else
154  return found->second;
155 }
static const char Default[]
the name of the default NETCLASS
NETCLASSPTR GetDefault() const
Function GetDefault.
NETCLASS_MAP m_NetClasses
all the NETCLASSes except the default one.
unsigned NETCLASSES::GetCount ( ) const
inline

Function GetCount.

Returns
the number of netclasses, excluding the default one.

Definition at line 266 of file class_netclass.h.

Referenced by DIALOG_DESIGN_RULES::InitRulesList().

267  {
268  return m_NetClasses.size();
269  }
NETCLASS_MAP m_NetClasses
all the NETCLASSes except the default one.
NETCLASS_MAP& NETCLASSES::NetClasses ( )
inline

Provide public access to m_NetClasses so it gets swigged.

Definition at line 306 of file class_netclass.h.

References BOARD_DESIGN_SETTINGS::m_NetClasses.

306 { return m_NetClasses; }
NETCLASS_MAP m_NetClasses
all the NETCLASSes except the default one.
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 129 of file class_netclass.cpp.

References m_NetClasses.

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

Member Data Documentation

NETCLASSPTR NETCLASSES::m_default
private

the default NETCLASS

Definition at line 239 of file class_netclass.h.

Referenced by Add(), and NETCLASSES().

NETCLASS_MAP NETCLASSES::m_NetClasses
private

all the NETCLASSes except the default one.

Definition at line 236 of file class_netclass.h.

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


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