~pierre-parent-k/kicad/length-tunning

« back to all changes in this revision

Viewing changes to pcbnew/class_netclass.h

  • Committer: Pierre Parent
  • Date: 2014-07-06 10:32:13 UTC
  • mfrom: (4798.1.179 kicad)
  • Revision ID: pierre.parent@insa-rouen.fr-20140706103213-wjsdy0hc9q6wbz5v
Merge with lp:kicad 4977

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
 
34
34
#include <set>
35
35
#include <map>
 
36
#include <boost/shared_ptr.hpp>
36
37
 
37
38
#include <wx/string.h>
38
39
 
41
42
 
42
43
class LINE_READER;
43
44
class BOARD;
 
45
class BOARD_DESIGN_SETTINGS;
44
46
 
45
47
 
46
48
/**
53
55
{
54
56
private:
55
57
    // Default values used to init a NETCLASS
56
 
    static int DEFAULT_CLEARANCE;
57
 
    static int DEFAULT_VIA_DRILL;
58
 
    static int DEFAULT_UVIA_DRILL;
 
58
    static const int DEFAULT_CLEARANCE;
 
59
    static const int DEFAULT_VIA_DRILL;
 
60
    static const int DEFAULT_UVIA_DRILL;
59
61
 
60
62
protected:
61
 
 
62
 
    BOARD*      m_Parent;
63
63
    wxString    m_Name;                 ///< Name of the net class
64
64
    wxString    m_Description;          ///< what this NETCLASS is for.
65
65
 
66
 
    typedef std::set<wxString>       STRINGSET;
 
66
    typedef std::set<wxString> STRINGSET;
67
67
 
68
68
    STRINGSET   m_Members;              ///< names of NET members of this class
69
69
 
80
80
 
81
81
public:
82
82
 
83
 
    static const wxString Default;      ///< the name of the default NETCLASS
 
83
    static const wxChar Default[];      ///< the name of the default NETCLASS
84
84
 
85
85
    /**
86
86
     * Constructor
87
87
     * stuffs a NETCLASS instance with aParent, aName, and optionally the initialParameters
88
 
     * @param aParent = the parent board
89
88
     * @param aName = the name of this new netclass
90
 
     * @param initialParameters is a NETCLASS to copy parameters from, or if
91
 
     *  NULL tells me to copy default settings from BOARD::m_designSettings.
92
89
     */
93
 
    NETCLASS( BOARD* aParent, const wxString& aName, const NETCLASS* initialParameters = NULL );
 
90
    NETCLASS( const wxString& aName );
94
91
 
95
92
    ~NETCLASS();
96
93
 
115
112
        return m_Members.size();
116
113
    }
117
114
 
118
 
 
119
115
    /**
120
116
     * Function Clear
121
117
     * empties the collection of members.
125
121
        m_Members.clear();
126
122
    }
127
123
 
128
 
 
129
124
    /**
130
125
     * Function AddMember
131
126
     * adds \a aNetname to this NETCLASS if it is not already in this NETCLASS.
169
164
    void    SetClearance( int aClearance )  { m_Clearance = aClearance; }
170
165
 
171
166
    int     GetTrackWidth() const           { return m_TrackWidth; }
172
 
    int     GetTrackMinWidth() const;
173
167
    void    SetTrackWidth( int aWidth )     { m_TrackWidth = aWidth; }
174
168
 
175
169
    int     GetViaDiameter() const          { return m_ViaDia; }
176
 
    int     GetViaMinDiameter() const;
177
170
    void    SetViaDiameter( int aDia )      { m_ViaDia = aDia; }
178
171
 
179
172
    int     GetViaDrill() const             { return m_ViaDrill; }
180
 
    int     GetViaMinDrill() const;
181
173
    void    SetViaDrill( int aSize )        { m_ViaDrill = aSize; }
182
174
 
183
175
    int     GetuViaDiameter() const         { return m_uViaDia; }
184
 
    int     GetuViaMinDiameter() const;
185
176
    void    SetuViaDiameter( int aSize )    { m_uViaDia = aSize; }
186
177
 
187
178
    int     GetuViaDrill() const            { return m_uViaDrill; }
188
 
    int     GetuViaMinDrill() const;
189
179
    void    SetuViaDrill( int aSize )       { m_uViaDrill = aSize; }
190
180
 
191
 
 
192
181
    /**
193
182
     * Function SetParams
194
183
     * will set all the parameters by copying them from \a defaults.
195
184
     * Parameters are the values like m_ViaSize, etc, but do not include m_Description.
196
 
     * @param defaults is another NETCLASS to copy from.  If NULL, then copy
197
 
     *  from global preferences instead.
198
 
     */
199
 
    void    SetParams( const NETCLASS* defaults = NULL );
 
185
     * @param aDefaults is another NETCLASS object to copy from.
 
186
     */
 
187
    void SetParams( const NETCLASS& aDefaults );
 
188
 
 
189
    /**
 
190
     * Function SetParams
 
191
     * will set all the parameters by copying them from board design settings.
 
192
     * @param aSettings is a BOARD_DESIGN_SETTINGS object to copy from. Clearance, via drill and
 
193
     * microvia drill values are taken from the defaults.
 
194
     */
 
195
    void SetParams( const BOARD_DESIGN_SETTINGS& aSettings );
200
196
 
201
197
    /**
202
198
     * Function Format
215
211
#endif
216
212
};
217
213
 
 
214
typedef boost::shared_ptr<NETCLASS> NETCLASSPTR;
218
215
 
219
216
/**
220
217
 * Class NETCLASSES
225
222
class NETCLASSES
226
223
{
227
224
private:
228
 
    BOARD*                  m_Parent;
229
 
 
230
 
    typedef std::map<wxString, NETCLASS*>   NETCLASSMAP;
 
225
    typedef std::map<wxString, NETCLASSPTR> NETCLASSMAP;
231
226
 
232
227
    /// all the NETCLASSes except the default one.
233
228
    NETCLASSMAP             m_NetClasses;
234
229
 
235
230
    /// the default NETCLASS.
236
 
    NETCLASS                m_Default;
 
231
    NETCLASSPTR             m_Default;
237
232
 
238
233
public:
239
 
    NETCLASSES( BOARD* aParent = NULL );
 
234
    NETCLASSES();
240
235
    ~NETCLASSES();
241
236
 
242
237
    /**
243
238
     * Function Clear
244
239
     * destroys any contained NETCLASS instances except the Default one.
245
240
     */
246
 
    void Clear();
 
241
    void Clear()
 
242
    {
 
243
        m_NetClasses.clear();
 
244
    }
247
245
 
248
 
    typedef NETCLASSMAP::iterator       iterator;
 
246
    typedef NETCLASSMAP::iterator iterator;
249
247
    iterator begin() { return m_NetClasses.begin(); }
250
248
    iterator end()   { return m_NetClasses.end(); }
251
249
 
253
251
    const_iterator begin() const { return m_NetClasses.begin(); }
254
252
    const_iterator end()   const { return m_NetClasses.end(); }
255
253
 
256
 
 
257
254
    /**
258
255
     * Function GetCount
259
256
     * @return the number of netclasses, excluding the default one.
263
260
        return m_NetClasses.size();
264
261
    }
265
262
 
266
 
    NETCLASS* GetDefault() const
 
263
    /**
 
264
     * Function GetDefault
 
265
     * @return the default net class.
 
266
     */
 
267
    NETCLASSPTR GetDefault() const
267
268
    {
268
 
        return (NETCLASS*) &m_Default;
 
269
        return m_Default;
269
270
    }
270
271
 
271
272
    /**
275
276
     * @return true if the name within aNetclass is unique and it could be inserted OK,
276
277
     *  else false because the name was not unique and caller still owns aNetclass.
277
278
     */
278
 
    bool Add( NETCLASS* aNetclass );
 
279
    bool Add( NETCLASSPTR aNetclass );
279
280
 
280
281
    /**
281
282
     * Function Remove
282
283
     * removes a NETCLASS from this container but does not destroy/delete it.
283
284
     * @param aNetName is the name of the net to delete, and it may not be NETCLASS::Default.
284
 
     * @return NETCLASS* - the NETCLASS associated with aNetName if found and removed, else NULL.
285
 
     * You have to delete the returned value if you intend to destroy the NETCLASS.
 
285
     * @return NETCLASSPTR - the NETCLASS associated with aNetName if found and removed, else NULL.
286
286
     */
287
 
    NETCLASS* Remove( const wxString& aNetName );
 
287
    NETCLASSPTR Remove( const wxString& aNetName );
288
288
 
289
289
    /**
290
290
     * Function Find
291
291
     * searches this container for a NETCLASS given by \a aName.
292
292
     * @param aName is the name of the NETCLASS to search for.
293
 
     * @return NETCLASS* - if found, else NULL.
 
293
     * @return NETCLASSPTR - if found, else NULL.
294
294
     */
295
 
    NETCLASS* Find( const wxString& aName ) const;
 
295
    NETCLASSPTR Find( const wxString& aName ) const;
296
296
 
297
297
};
298
298