KiCad PCB EDA Suite
DSN::PADSTACK Class Reference

Hold either a via or a pad definition. More...

#include <specctra.h>

Inheritance diagram for DSN::PADSTACK:
DSN::ELEM_HOLDER DSN::ELEM

Public Member Functions

 PADSTACK ()
 Cannot take ELEM* aParent because PADSTACKSET confuses this with a copy constructor and causes havoc. More...
 
 ~PADSTACK ()
 
const std::string & GetPadstackId ()
 
void SetPadstackId (const char *aPadstackId)
 
void Format (OUTPUTFORMATTER *out, int nestLevel) override
 Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format. More...
 
void FormatContents (OUTPUTFORMATTER *out, int nestLevel) override
 Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format. More...
 
UNIT_RESGetUnits () const override
 Return the units for this section. More...
 
int FindElem (DSN_T aType, int instanceNum=0)
 Find a particular instance number of a given type of ELEM. More...
 
int Length () const
 Return the number of ELEMs in this holder. More...
 
void Append (ELEM *aElem)
 
ELEMReplace (int aIndex, ELEM *aElem)
 
ELEMRemove (int aIndex)
 
void Insert (int aIndex, ELEM *aElem)
 
ELEMAt (int aIndex) const
 
ELEMoperator[] (int aIndex) const
 
void Delete (int aIndex)
 
DSN_T Type () const
 
const char * Name () const
 
void SetParent (ELEM *aParent)
 

Static Public Member Functions

static int Compare (PADSTACK *lhs, PADSTACK *rhs)
 Compare two objects of this type and returns <0, 0, or >0. More...
 

Protected Member Functions

std::string makeHash ()
 Return a string which uniquely represents this ELEM among other ELEMs of the same derived class as "this" one. More...
 

Protected Attributes

DSN_T type
 
ELEMparent
 

Static Protected Attributes

static STRING_FORMATTER sf
 

Private Types

typedef boost::ptr_vector< ELEMELEM_ARRAY
 

Private Attributes

std::string hash
 a hash string used by Compare(), not Format()ed/exported. More...
 
std::string padstack_id
 
UNIT_RESunit
 
DSN_T rotate
 
DSN_T absolute
 
DSN_T attach
 
std::string via_id
 
RULErules
 
ELEM_ARRAY kids
 ELEM pointers. More...
 

Friends

class SPECCTRA_DB
 

Detailed Description

Hold either a via or a pad definition.

Definition at line 2126 of file specctra.h.

Member Typedef Documentation

◆ ELEM_ARRAY

typedef boost::ptr_vector<ELEM> DSN::ELEM_HOLDER::ELEM_ARRAY
privateinherited

Definition at line 358 of file specctra.h.

Constructor & Destructor Documentation

◆ PADSTACK()

DSN::PADSTACK::PADSTACK ( )
inline

Cannot take ELEM* aParent because PADSTACKSET confuses this with a copy constructor and causes havoc.

Instead set parent with LIBRARY::AddPadstack()

Definition at line 2134 of file specctra.h.

2134 :
2135 ELEM_HOLDER( T_padstack, nullptr )
2136 {
2137 unit = 0;
2138 rotate = T_on;
2139 absolute = T_off;
2140 rules = 0;
2141 attach = T_off;
2142 }
ELEM_HOLDER(DSN_T aType, ELEM *aParent=0)
Definition: specctra.h:292
DSN_T rotate
Definition: specctra.h:2231
DSN_T absolute
Definition: specctra.h:2232
DSN_T attach
Definition: specctra.h:2233
UNIT_RES * unit
Definition: specctra.h:2227
RULE * rules
Definition: specctra.h:2236

References absolute, attach, rotate, rules, and unit.

◆ ~PADSTACK()

DSN::PADSTACK::~PADSTACK ( )
inline

Definition at line 2144 of file specctra.h.

2145 {
2146 delete unit;
2147 delete rules;
2148 }

References rules, and unit.

Member Function Documentation

◆ Append()

void DSN::ELEM_HOLDER::Append ( ELEM aElem)
inlineinherited

◆ At()

ELEM * DSN::ELEM_HOLDER::At ( int  aIndex) const
inlineinherited

Definition at line 341 of file specctra.h.

342 {
343 // we have varying sized objects and are using polymorphism, so we
344 // must return a pointer not a reference.
345 return (ELEM*) &kids[aIndex];
346 }
ELEM(DSN_T aType, ELEM *aParent=0)
Definition: specctra.cpp:3749

References DSN::ELEM_HOLDER::kids.

Referenced by DSN::CONTROL::Format(), DSN::ELEM_HOLDER::FormatContents(), DSN::STRUCTURE::FormatContents(), and DSN::ELEM_HOLDER::operator[]().

◆ Compare()

int DSN::PADSTACK::Compare ( PADSTACK lhs,
PADSTACK rhs 
)
static

Compare two objects of this type and returns <0, 0, or >0.

Definition at line 3817 of file specctra.cpp.

3818{
3819 if( !lhs->hash.size() )
3820 lhs->hash = lhs->makeHash();
3821
3822 if( !rhs->hash.size() )
3823 rhs->hash = rhs->makeHash();
3824
3825 int result = lhs->hash.compare( rhs->hash );
3826
3827 if( result )
3828 return result;
3829
3830 // Via names hold the drill diameters, so we have to include those to discern
3831 // between two vias with same copper size but with different drill sizes.
3832 result = lhs->padstack_id.compare( rhs->padstack_id );
3833
3834 return result;
3835}

References hash, DSN::ELEM::makeHash(), and padstack_id.

Referenced by DSN::LIBRARY::FindVia(), and DSN::operator<().

◆ Delete()

void DSN::ELEM_HOLDER::Delete ( int  aIndex)
inlineinherited

Definition at line 353 of file specctra.h.

353{ kids.erase( kids.begin() + aIndex ); }

References DSN::ELEM_HOLDER::kids.

◆ FindElem()

int DSN::ELEM_HOLDER::FindElem ( DSN_T  aType,
int  instanceNum = 0 
)
inherited

Find a particular instance number of a given type of ELEM.

Parameters
aTypeThe type of ELEM to find
instanceNumThe instance number of to find: 0 for first, 1 for second, etc.
Returns
int - The index into the kids array or -1 if not found.

Definition at line 3791 of file specctra.cpp.

3792{
3793 int repeats=0;
3794
3795 for( unsigned i = 0; i < kids.size(); ++i )
3796 {
3797 if( kids[i].Type() == aType )
3798 {
3799 if( repeats == instanceNum )
3800 return i;
3801
3802 ++repeats;
3803 }
3804 }
3805
3806 return -1;
3807}
DSN_T Type() const
Definition: specctra.h:210

References DSN::ELEM_HOLDER::kids, and DSN::ELEM::Type().

◆ Format()

void DSN::PADSTACK::Format ( OUTPUTFORMATTER out,
int  nestLevel 
)
inlineoverridevirtual

Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.

Parameters
outThe formatter to write to.
nestLevelA multiple of the number of spaces to precede the output with.
Exceptions
IO_ERRORif a system error writing the output, such as a full disk.

Reimplemented from DSN::ELEM.

Definition at line 2165 of file specctra.h.

2166 {
2167 const char* quote = out->GetQuoteChar( padstack_id.c_str() );
2168
2169 out->Print( nestLevel, "(%s %s%s%s\n", Name(), quote, padstack_id.c_str(), quote );
2170
2171 FormatContents( out, nestLevel+1 );
2172
2173 out->Print( nestLevel, ")\n" );
2174 }
const char * Name() const
Definition: specctra.cpp:3760
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:2177
std::string padstack_id
Definition: specctra.h:2226
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:431
static const char * GetQuoteChar(const char *wrapee, const char *quote_char)
Perform quote character need determination according to the Specctra DSN specification.
Definition: richio.cpp:353

References FormatContents(), OUTPUTFORMATTER::GetQuoteChar(), DSN::ELEM::Name(), padstack_id, and OUTPUTFORMATTER::Print().

◆ FormatContents()

void DSN::PADSTACK::FormatContents ( OUTPUTFORMATTER out,
int  nestLevel 
)
inlineoverridevirtual

Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.

This is the same as Format() except that the outer wrapper is not included.

Parameters
outThe formatter to write to.
nestLevelA multiple of the number of spaces to precede the output with.
Exceptions
IO_ERRORif a system error writing the output, such as a full disk.

Reimplemented from DSN::ELEM_HOLDER.

Definition at line 2177 of file specctra.h.

2178 {
2179 if( unit )
2180 unit->Format( out, nestLevel );
2181
2182 // format the kids, which in this class are the shapes
2183 ELEM_HOLDER::FormatContents( out, nestLevel );
2184
2185 out->Print( nestLevel, "%s", "" );
2186
2187 // spec for <attach_descriptor> says default is on, so
2188 // print the off condition to override this.
2189 if( attach == T_off )
2190 {
2191 out->Print( 0, "(attach off)" );
2192 }
2193 else if( attach == T_on )
2194 {
2195 const char* quote = out->GetQuoteChar( via_id.c_str() );
2196
2197 out->Print( 0, "(attach on (use_via %s%s%s))", quote, via_id.c_str(), quote );
2198 }
2199
2200 if( rotate == T_off ) // print the non-default
2201 out->Print( 0, "(rotate %s)", GetTokenText( rotate ) );
2202
2203 if( absolute == T_on ) // print the non-default
2204 out->Print( 0, "(absolute %s)", GetTokenText( absolute ) );
2205
2206 out->Print( 0, "\n" );
2207
2208 if( rules )
2209 rules->Format( out, nestLevel );
2210 }
virtual void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.cpp:3784
std::string via_id
Definition: specctra.h:2234
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:500
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:422
const char * GetTokenText(T aTok)
The DSN namespace and returns the C string representing a SPECCTRA_DB::keyword.
Definition: specctra.cpp:70

References absolute, attach, DSN::UNIT_RES::Format(), DSN::RULE::Format(), DSN::ELEM_HOLDER::FormatContents(), OUTPUTFORMATTER::GetQuoteChar(), DSN::GetTokenText(), OUTPUTFORMATTER::Print(), rotate, rules, unit, and via_id.

Referenced by Format().

◆ GetPadstackId()

const std::string & DSN::PADSTACK::GetPadstackId ( )
inline

Definition at line 2150 of file specctra.h.

2151 {
2152 return padstack_id;
2153 }

References padstack_id.

Referenced by DSN::LIBRARY::FindPADSTACK().

◆ GetUnits()

UNIT_RES * DSN::PADSTACK::GetUnits ( ) const
inlineoverridevirtual

Return the units for this section.

Derived classes may override this to check for section specific overrides.

Returns
an element from a local or parent scope.

Reimplemented from DSN::ELEM.

Definition at line 2213 of file specctra.h.

2214 {
2215 if( unit )
2216 return unit;
2217
2218 return ELEM::GetUnits();
2219 }
virtual UNIT_RES * GetUnits() const
Return the units for this section.
Definition: specctra.cpp:3765

References DSN::ELEM::GetUnits(), and unit.

◆ Insert()

void DSN::ELEM_HOLDER::Insert ( int  aIndex,
ELEM aElem 
)
inlineinherited

Definition at line 339 of file specctra.h.

339{ kids.insert( kids.begin() + aIndex, aElem ); }

References DSN::ELEM_HOLDER::kids.

◆ Length()

int DSN::ELEM_HOLDER::Length ( ) const
inlineinherited

Return the number of ELEMs in this holder.

Returns
the count of children elements.

Definition at line 317 of file specctra.h.

318 {
319 return kids.size();
320 }

References DSN::ELEM_HOLDER::kids.

Referenced by DSN::CONTROL::Format(), DSN::ELEM_HOLDER::FormatContents(), DSN::STRUCTURE::FormatContents(), and DSN::SPECCTRA_DB::makeVIA().

◆ makeHash()

std::string DSN::ELEM::makeHash ( )
inlineprotectedinherited

Return a string which uniquely represents this ELEM among other ELEMs of the same derived class as "this" one.

It is not usable for all derived classes, only those which plan for it by implementing a FormatContents() function that captures all info which will be used in the subsequent string compare. THIS SHOULD NORMALLY EXCLUDE THE TYPENAME, AND INSTANCE NAME OR ID AS WELL.

Definition at line 263 of file specctra.h.

264 {
265 sf.Clear();
266 FormatContents( &sf, 0 );
268
269 return sf.GetString();
270 }
virtual void FormatContents(OUTPUTFORMATTER *out, int nestLevel)
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:242
static STRING_FORMATTER sf
Definition: specctra.h:273
void StripUseless()
Removes whitespace, '(', and ')' from the string.
Definition: richio.cpp:517
const std::string & GetString()
Definition: richio.h:438
void Clear()
Clear the buffer and empties the internal string.
Definition: richio.h:428

References STRING_FORMATTER::Clear(), DSN::ELEM::FormatContents(), STRING_FORMATTER::GetString(), DSN::ELEM::sf, and STRING_FORMATTER::StripUseless().

Referenced by DSN::IMAGE::Compare(), and Compare().

◆ Name()

◆ operator[]()

ELEM * DSN::ELEM_HOLDER::operator[] ( int  aIndex) const
inlineinherited

Definition at line 348 of file specctra.h.

349 {
350 return At( aIndex );
351 }
ELEM * At(int aIndex) const
Definition: specctra.h:341

References DSN::ELEM_HOLDER::At().

◆ Remove()

ELEM * DSN::ELEM_HOLDER::Remove ( int  aIndex)
inlineinherited

Definition at line 333 of file specctra.h.

334 {
335 ELEM_ARRAY::auto_type ret = kids.release( kids.begin() + aIndex );
336 return ret.release();
337 }

References DSN::ELEM_HOLDER::kids.

◆ Replace()

ELEM * DSN::ELEM_HOLDER::Replace ( int  aIndex,
ELEM aElem 
)
inlineinherited

Definition at line 327 of file specctra.h.

328 {
329 ELEM_ARRAY::auto_type ret = kids.replace( aIndex, aElem );
330 return ret.release();
331 }

References DSN::ELEM_HOLDER::kids.

◆ SetPadstackId()

void DSN::PADSTACK::SetPadstackId ( const char *  aPadstackId)
inline

Definition at line 2160 of file specctra.h.

2161 {
2162 padstack_id = aPadstackId;
2163 }

References padstack_id.

Referenced by DSN::SPECCTRA_DB::makePADSTACK(), and DSN::SPECCTRA_DB::makeVia().

◆ SetParent()

◆ Type()

Friends And Related Function Documentation

◆ SPECCTRA_DB

friend class SPECCTRA_DB
friend

Definition at line 2222 of file specctra.h.

Member Data Documentation

◆ absolute

DSN_T DSN::PADSTACK::absolute
private

Definition at line 2232 of file specctra.h.

Referenced by DSN::SPECCTRA_DB::doPADSTACK(), FormatContents(), and PADSTACK().

◆ attach

DSN_T DSN::PADSTACK::attach
private

Definition at line 2233 of file specctra.h.

Referenced by DSN::SPECCTRA_DB::doPADSTACK(), FormatContents(), and PADSTACK().

◆ hash

std::string DSN::PADSTACK::hash
private

a hash string used by Compare(), not Format()ed/exported.

Definition at line 2224 of file specctra.h.

Referenced by Compare().

◆ kids

◆ padstack_id

std::string DSN::PADSTACK::padstack_id
private

◆ parent

ELEM* DSN::ELEM::parent
protectedinherited

Definition at line 276 of file specctra.h.

Referenced by DSN::ELEM::GetUnits(), and DSN::ELEM::SetParent().

◆ rotate

DSN_T DSN::PADSTACK::rotate
private

Definition at line 2231 of file specctra.h.

Referenced by DSN::SPECCTRA_DB::doPADSTACK(), FormatContents(), and PADSTACK().

◆ rules

RULE* DSN::PADSTACK::rules
private

Definition at line 2236 of file specctra.h.

Referenced by DSN::SPECCTRA_DB::doPADSTACK(), FormatContents(), PADSTACK(), and ~PADSTACK().

◆ sf

STRING_FORMATTER DSN::ELEM::sf
staticprotectedinherited

Definition at line 273 of file specctra.h.

Referenced by DSN::ELEM::makeHash().

◆ type

DSN_T DSN::ELEM::type
protectedinherited

Definition at line 275 of file specctra.h.

Referenced by DSN::UNIT_RES::Format(), DSN::ELEM::Name(), and DSN::ELEM::Type().

◆ unit

UNIT_RES* DSN::PADSTACK::unit
private

◆ via_id

std::string DSN::PADSTACK::via_id
private

Definition at line 2234 of file specctra.h.

Referenced by DSN::SPECCTRA_DB::doPADSTACK(), and FormatContents().


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