KiCad PCB EDA Suite
class_netclass.h
Go to the documentation of this file.
1 
5 /*
6  * This program source code file is part of KiCad, a free EDA CAD application.
7  *
8  * Copyright (C) 2009 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
9  * Copyright (C) 2009 Jean-Pierre Charras, jean-pierre.charras@inpg.fr
10  * Copyright (C) 2009 KiCad Developers, see change_log.txt for contributors.
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, you may find one here:
24  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
25  * or you may search the http://www.gnu.org website for the version 2 license,
26  * or you may write to the Free Software Foundation, Inc.,
27  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
28  */
29 
30 
31 #ifndef CLASS_NETCLASS_H
32 #define CLASS_NETCLASS_H
33 
34 
35 #include <macros.h>
36 #include <set>
37 #include <memory>
38 #include <richio.h>
39 
40 
41 class LINE_READER;
42 class BOARD;
44 
45 
46 DECL_SET_FOR_SWIG( STRINGSET, wxString )
47 
48 
49 
55 class NETCLASS
56 {
57 private:
58  // Default values used to init a NETCLASS
59  static const int DEFAULT_CLEARANCE;
60  static const int DEFAULT_VIA_DRILL;
61  static const int DEFAULT_UVIA_DRILL;
62  static const int DEFAULT_VIA_DIAMETER;
63  static const int DEFAULT_UVIA_DIAMETER;
64  static const int DEFAULT_TRACK_WIDTH;
65  static const int DEFAULT_DIFF_PAIR_WIDTH;
66  static const int DEFAULT_DIFF_PAIR_GAP;
67 
68 protected:
69  wxString m_Name;
70  wxString m_Description;
71 
73 
75 
77 
79  int m_ViaDia;
80  int m_ViaDrill;
81 
82  int m_uViaDia;
84 
87 
88 public:
89 
90  static const char Default[];
91 
97  NETCLASS( const wxString& aName );
98 
99  ~NETCLASS();
100 
101  wxString GetClass() const
102  {
103  return wxT( "NETCLASS" );
104  }
105 
106  const wxString& GetName() const
107  {
108  return m_Name;
109  }
110 
111  void SetName( const wxString& aName ) { m_Name = aName; }
112 
117  unsigned GetCount() const
118  {
119  return m_Members.size();
120  }
121 
126  void Clear()
127  {
128  m_Members.clear();
129  }
130 
136  void Add( const wxString& aNetname )
137  {
138  m_Members.insert( aNetname );
139  }
140 
141  typedef STRINGSET::iterator iterator;
142  iterator begin() { return m_Members.begin(); }
143  iterator end() { return m_Members.end(); }
144 
145  typedef STRINGSET::const_iterator const_iterator;
146  const_iterator begin() const { return m_Members.begin(); }
147  const_iterator end() const { return m_Members.end(); }
148 
153  void Remove( iterator aName )
154  {
155  m_Members.erase( aName );
156  }
157 
162  void Remove( const wxString& aName )
163  {
164  m_Members.erase( aName );
165  }
166 
167  STRINGSET& NetNames() { return m_Members; }
168 
169  const wxString& GetDescription() const { return m_Description; }
170  void SetDescription( const wxString& aDesc ) { m_Description = aDesc; }
171 
172  int GetClearance() const { return m_Clearance; }
173  void SetClearance( int aClearance ) { m_Clearance = aClearance; }
174 
175  int GetTrackWidth() const { return m_TrackWidth; }
176  void SetTrackWidth( int aWidth ) { m_TrackWidth = aWidth; }
177 
178  int GetViaDiameter() const { return m_ViaDia; }
179  void SetViaDiameter( int aDia ) { m_ViaDia = aDia; }
180 
181  int GetViaDrill() const { return m_ViaDrill; }
182  void SetViaDrill( int aSize ) { m_ViaDrill = aSize; }
183 
184  int GetuViaDiameter() const { return m_uViaDia; }
185  void SetuViaDiameter( int aSize ) { m_uViaDia = aSize; }
186 
187  int GetuViaDrill() const { return m_uViaDrill; }
188  void SetuViaDrill( int aSize ) { m_uViaDrill = aSize; }
189 
190  int GetDiffPairWidth() const { return m_diffPairWidth; }
191  void SetDiffPairWidth( int aSize ) { m_diffPairWidth = aSize; }
192 
193  int GetDiffPairGap() const { return m_diffPairGap; }
194  void SetDiffPairGap( int aSize ) { m_diffPairGap = aSize; }
195 
202  void SetParams( const NETCLASS& aDefaults );
203 
213  void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
214  throw( IO_ERROR );
215 
216 #if defined(DEBUG)
217  void Show( int nestLevel, std::ostream& os ) const;
218 #endif
219 };
220 
221 
222 DECL_SPTR_FOR_SWIG( NETCLASSPTR, NETCLASS )
223 DECL_MAP_FOR_SWIG( NETCLASS_MAP, wxString, NETCLASSPTR );
224 
225 
233 {
234 private:
235 
237  NETCLASS_MAP m_NetClasses;
238 
240  NETCLASSPTR m_Default;
241 
242 public:
243  NETCLASSES();
244  ~NETCLASSES();
245 
250  void Clear()
251  {
252  m_NetClasses.clear();
253  }
254 
255  typedef NETCLASS_MAP::iterator iterator;
256  iterator begin() { return m_NetClasses.begin(); }
257  iterator end() { return m_NetClasses.end(); }
258 
259  typedef NETCLASS_MAP::const_iterator const_iterator;
260  const_iterator begin() const { return m_NetClasses.begin(); }
261  const_iterator end() const { return m_NetClasses.end(); }
262 
267  unsigned GetCount() const
268  {
269  return m_NetClasses.size();
270  }
271 
276  NETCLASSPTR GetDefault() const
277  {
278  return m_Default;
279  }
280 
288  bool Add( NETCLASSPTR aNetclass );
289 
296  NETCLASSPTR Remove( const wxString& aNetName );
297 
304  NETCLASSPTR Find( const wxString& aName ) const;
305 
307  NETCLASS_MAP& NetClasses() { return m_NetClasses; }
308 };
309 
310 #endif // CLASS_NETCLASS_H
const wxString & GetName() const
int m_ViaDrill
via drill hole diameter
Class LINE_READER is an abstract class from which implementation specific LINE_READERs may be derived...
Definition: richio.h:81
void SetDiffPairWidth(int aSize)
int GetuViaDrill() const
int GetuViaDiameter() const
int GetClearance() const
#define DECL_SET_FOR_SWIG(TypeName, MemberType)
Definition: macros.h:149
static const int DEFAULT_UVIA_DIAMETER
NETCLASS_MAP & NetClasses()
Provide public access to m_NetClasses so it gets swigged.
int m_uViaDrill
microvia drill hole diameter
STRINGSET & NetNames()
for SWIG
NETCLASSPTR m_Default
the default NETCLASS.
int m_ViaDia
via diameter
void SetDescription(const wxString &aDesc)
Class OUTPUTFORMATTER is an important interface (abstract class) used to output 8 bit text in a conve...
Definition: richio.h:327
iterator end()
int m_diffPairWidth
static const int DEFAULT_DIFF_PAIR_GAP
void SetTrackWidth(int aWidth)
const_iterator begin() const
int GetTrackWidth() const
NETCLASS_MAP::const_iterator const_iterator
void SetViaDrill(int aSize)
iterator begin()
STRINGSET m_Members
names of NET members of this class
std::set< std::string > STRINGSET
int GetDiffPairGap() const
This file contains miscellaneous commonly used macros and functions.
void SetName(const wxString &aName)
const_iterator end() const
void SetDiffPairGap(int aSize)
NETCLASS_MAP::iterator iterator
STRINGSET::iterator iterator
wxString m_Description
Description shown in the file picker dialog.
iterator begin()
Class NETCLASSES is a container for NETCLASS instances.
iterator end()
DECL_MAP_FOR_SWIG(NETCLASS_MAP, wxString, NETCLASSPTR)
wxString GetClass() const
void SetClearance(int aClearance)
const_iterator begin() const
Class NETCLASS handles a collection of nets and the parameters used to route or test these nets...
int m_uViaDia
microvia diameter
static const int DEFAULT_UVIA_DRILL
const wxString & GetDescription() const
void SetuViaDiameter(int aSize)
int GetViaDiameter() const
static const int DEFAULT_VIA_DIAMETER
static const int DEFAULT_VIA_DRILL
int GetDiffPairWidth() const
int GetViaDrill() const
unsigned GetCount() const
Function GetCount.
const_iterator end() const
void Clear()
Function Clear empties the collection of members.
void Remove(iterator aName)
Function Remove will remove NET name aName from the collection of members.
void Clear()
Function Clear destroys any contained NETCLASS instances except the Default one.
void SetuViaDrill(int aSize)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:166
wxString m_Description
what this NETCLASS is for.
NETCLASSPTR GetDefault() const
Function GetDefault.
wxString m_Name
Name of the net class.
void Remove(const wxString &aName)
Function Remove will remove NET name aName from the collection of members.
static const int DEFAULT_TRACK_WIDTH
STRINGSET::const_iterator const_iterator
void SetViaDiameter(int aDia)
int m_diffPairGap
NETCLASS_MAP m_NetClasses
all the NETCLASSes except the default one.
int m_TrackWidth
track width used to route NETs in this NETCLASS
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:47
int m_Clearance
The units on these parameters is Internal Units (1 nm)
#define DECL_SPTR_FOR_SWIG(TypeName, MemberType)
Definition: macros.h:148
static const int DEFAULT_DIFF_PAIR_WIDTH
static const int DEFAULT_CLEARANCE
NETCLASSES m_NetClasses
List of current netclasses. There is always the default netclass.
unsigned GetCount() const
Function GetCount returns the number of nets in this NETCLASS, i.e.
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
void Add(const wxString &aNetname)
Function Add adds aNetname to this NETCLASS if it is not already in this NETCLASS.