KiCad PCB EDA Suite
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 protected:
58  wxString m_Name;
59  wxString m_Description;
60 
62 
64 
66 
68  int m_ViaDia;
69  int m_ViaDrill;
70 
71  int m_uViaDia;
73 
77 
78 public:
79 
80  static const char Default[];
81 
87  NETCLASS( const wxString& aName );
88 
89  ~NETCLASS();
90 
91  wxString GetClass() const
92  {
93  return wxT( "NETCLASS" );
94  }
95 
96  const wxString& GetName() const
97  {
98  return m_Name;
99  }
100 
101  void SetName( const wxString& aName ) { m_Name = aName; }
102 
107  unsigned GetCount() const
108  {
109  return m_Members.size();
110  }
111 
116  void Clear()
117  {
118  m_Members.clear();
119  }
120 
126  void Add( const wxString& aNetname )
127  {
128  m_Members.insert( aNetname );
129  }
130 
131  typedef STRINGSET::iterator iterator;
132  iterator begin() { return m_Members.begin(); }
133  iterator end() { return m_Members.end(); }
134 
135  typedef STRINGSET::const_iterator const_iterator;
136  const_iterator begin() const { return m_Members.begin(); }
137  const_iterator end() const { return m_Members.end(); }
138 
143  void Remove( iterator aName )
144  {
145  m_Members.erase( aName );
146  }
147 
152  void Remove( const wxString& aName )
153  {
154  m_Members.erase( aName );
155  }
156 
157  STRINGSET& NetNames() { return m_Members; }
158 
159  const wxString& GetDescription() const { return m_Description; }
160  void SetDescription( const wxString& aDesc ) { m_Description = aDesc; }
161 
162  int GetClearance() const { return m_Clearance; }
163  void SetClearance( int aClearance ) { m_Clearance = aClearance; }
164 
165  int GetTrackWidth() const { return m_TrackWidth; }
166  void SetTrackWidth( int aWidth ) { m_TrackWidth = aWidth; }
167 
168  int GetViaDiameter() const { return m_ViaDia; }
169  void SetViaDiameter( int aDia ) { m_ViaDia = aDia; }
170 
171  int GetViaDrill() const { return m_ViaDrill; }
172  void SetViaDrill( int aSize ) { m_ViaDrill = aSize; }
173 
174  int GetuViaDiameter() const { return m_uViaDia; }
175  void SetuViaDiameter( int aSize ) { m_uViaDia = aSize; }
176 
177  int GetuViaDrill() const { return m_uViaDrill; }
178  void SetuViaDrill( int aSize ) { m_uViaDrill = aSize; }
179 
180  int GetDiffPairWidth() const { return m_diffPairWidth; }
181  void SetDiffPairWidth( int aSize ) { m_diffPairWidth = aSize; }
182 
183  int GetDiffPairGap() const { return m_diffPairGap; }
184  void SetDiffPairGap( int aSize ) { m_diffPairGap = aSize; }
185 
186  int GetDiffPairViaGap() const { return m_diffPairViaGap; }
187  void SetDiffPairViaGap( int aSize ) { m_diffPairViaGap = aSize; }
188 
195  void SetParams( const NETCLASS& aDefaults );
196 
206  void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const;
207 
208 #if defined(DEBUG)
209  void Show( int nestLevel, std::ostream& os ) const;
210 #endif
211 };
212 
213 
214 DECL_SPTR_FOR_SWIG( NETCLASSPTR, NETCLASS )
215 DECL_MAP_FOR_SWIG( NETCLASS_MAP, wxString, NETCLASSPTR )
216 
217 
218 
225 {
226 private:
227 
229  NETCLASS_MAP m_NetClasses;
230 
232  NETCLASSPTR m_default;
233 
234 public:
235  NETCLASSES();
236  ~NETCLASSES();
237 
242  void Clear()
243  {
244  m_NetClasses.clear();
245  }
246 
247  typedef NETCLASS_MAP::iterator iterator;
249  iterator end() { return m_NetClasses.end(); }
250 
251  typedef NETCLASS_MAP::const_iterator const_iterator;
252  const_iterator begin() const { return m_NetClasses.begin(); }
253  const_iterator end() const { return m_NetClasses.end(); }
254 
259  unsigned GetCount() const
260  {
261  return m_NetClasses.size();
262  }
263 
268  NETCLASSPTR GetDefault() const
269  {
270  return m_default;
271  }
272 
280  bool Add( const NETCLASSPTR& aNetclass );
281 
288  NETCLASSPTR Remove( const wxString& aNetName );
289 
296  NETCLASSPTR Find( const wxString& aName ) const;
297 
299  NETCLASS_MAP& NetClasses() { return m_NetClasses; }
300 };
301 
302 #endif // CLASS_NETCLASS_H
const wxString & GetName() const
Definition: netclass.h:96
int m_ViaDrill
via drill hole diameter
Definition: netclass.h:69
Class LINE_READER is an abstract class from which implementation specific LINE_READERs may be derived...
Definition: richio.h:81
void SetDiffPairWidth(int aSize)
Definition: netclass.h:181
int GetuViaDrill() const
Definition: netclass.h:177
int GetuViaDiameter() const
Definition: netclass.h:174
NETCLASSPTR m_default
the default NETCLASS
Definition: netclass.h:232
int GetClearance() const
Definition: netclass.h:162
#define DECL_SET_FOR_SWIG(TypeName, MemberType)
Definition: macros.h:149
NETCLASS_MAP & NetClasses()
Provide public access to m_NetClasses so it gets swigged.
Definition: netclass.h:299
int m_uViaDrill
microvia drill hole diameter
Definition: netclass.h:72
STRINGSET & NetNames()
for SWIG
Definition: netclass.h:157
int m_ViaDia
via diameter
Definition: netclass.h:68
int GetDiffPairViaGap() const
Definition: netclass.h:186
void SetDescription(const wxString &aDesc)
Definition: netclass.h:160
Class OUTPUTFORMATTER is an important interface (abstract class) used to output 8 bit text in a conve...
Definition: richio.h:327
iterator end()
Definition: netclass.h:249
int m_diffPairWidth
Definition: netclass.h:74
#define DECL_MAP_FOR_SWIG(TypeName, KeyType, ValueType)
Definition: macros.h:147
void SetTrackWidth(int aWidth)
Definition: netclass.h:166
wxString m_Description
Description shown in the file picker dialog.
const_iterator begin() const
Definition: netclass.h:136
int GetTrackWidth() const
Definition: netclass.h:165
NETCLASS_MAP::const_iterator const_iterator
Definition: netclass.h:251
void SetViaDrill(int aSize)
Definition: netclass.h:172
iterator begin()
Definition: netclass.h:132
STRINGSET m_Members
names of NET members of this class
Definition: netclass.h:61
std::set< std::string > STRINGSET
int GetDiffPairGap() const
Definition: netclass.h:183
This file contains miscellaneous commonly used macros and functions.
void SetName(const wxString &aName)
Definition: netclass.h:101
const_iterator end() const
Definition: netclass.h:253
void SetDiffPairGap(int aSize)
Definition: netclass.h:184
NETCLASS_MAP::iterator iterator
Definition: netclass.h:247
STRINGSET::iterator iterator
Definition: netclass.h:131
iterator begin()
Definition: netclass.h:248
Class NETCLASSES is a container for NETCLASS instances.
Definition: netclass.h:224
iterator end()
Definition: netclass.h:133
wxString GetClass() const
Definition: netclass.h:91
void SetClearance(int aClearance)
Definition: netclass.h:163
const_iterator begin() const
Definition: netclass.h:252
Class NETCLASS handles a collection of nets and the parameters used to route or test these nets...
Definition: netclass.h:55
int m_uViaDia
microvia diameter
Definition: netclass.h:71
int m_diffPairViaGap
Definition: netclass.h:76
const wxString & GetDescription() const
Definition: netclass.h:159
void SetuViaDiameter(int aSize)
Definition: netclass.h:175
int GetViaDiameter() const
Definition: netclass.h:168
void SetDiffPairViaGap(int aSize)
Definition: netclass.h:187
int GetDiffPairWidth() const
Definition: netclass.h:180
int GetViaDrill() const
Definition: netclass.h:171
unsigned GetCount() const
Function GetCount.
Definition: netclass.h:259
const_iterator end() const
Definition: netclass.h:137
void Clear()
Function Clear empties the collection of members.
Definition: netclass.h:116
void Remove(iterator aName)
Function Remove will remove NET name aName from the collection of members.
Definition: netclass.h:143
void Clear()
Function Clear destroys any contained NETCLASS instances except the Default one.
Definition: netclass.h:242
void SetuViaDrill(int aSize)
Definition: netclass.h:178
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:170
wxString m_Description
what this NETCLASS is for.
Definition: netclass.h:59
NETCLASSPTR GetDefault() const
Function GetDefault.
Definition: netclass.h:268
wxString m_Name
Name of the net class.
Definition: netclass.h:58
void Remove(const wxString &aName)
Function Remove will remove NET name aName from the collection of members.
Definition: netclass.h:152
STRINGSET::const_iterator const_iterator
Definition: netclass.h:135
void SetViaDiameter(int aDia)
Definition: netclass.h:169
int m_diffPairGap
Definition: netclass.h:75
NETCLASS_MAP m_NetClasses
all the NETCLASSes except the default one.
Definition: netclass.h:229
int m_TrackWidth
track width used to route NETs in this NETCLASS
Definition: netclass.h:67
int m_Clearance
The units on these parameters is Internal Units (1 nm)
Definition: netclass.h:65
#define DECL_SPTR_FOR_SWIG(TypeName, MemberType)
Definition: macros.h:148
unsigned GetCount() const
Function GetCount returns the number of nets in this NETCLASS, i.e.
Definition: netclass.h:107
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.
Definition: netclass.h:126