KiCad PCB EDA Suite
DSN::PADSTACK Class Reference

PADSTACK holds 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 ()
 Constructor 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
 Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format. More...
 
void FormatContents (OUTPUTFORMATTER *out, int nestLevel) override
 Function FormatContents writes the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format. More...
 
UNIT_RESGetUnits () const override
 Function GetUnits returns the units for this section. More...
 
int FindElem (DSN_T aType, int instanceNum=0)
 Function FindElem finds a particular instance number of a given type of ELEM. More...
 
int Length () const
 Function Length returns the number of ELEMs in this ELEM. 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)
 Function Compare compares two objects of this type and returns <0, 0, or >0. More...
 

Protected Member Functions

std::string makeHash ()
 Function makeHash returns a string which uniquely represents this ELEM amoung 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 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
 

Friends

class SPECCTRA_DB
 

Detailed Description

PADSTACK holds either a via or a pad definition.

Definition at line 2114 of file specctra.h.

Constructor & Destructor Documentation

◆ PADSTACK()

DSN::PADSTACK::PADSTACK ( )
inline

Constructor PADSTACK() cannot take ELEM* aParent because PADSTACKSET confuses this with a copy constructor and causes havoc.

Instead set parent with LIBRARY::AddPadstack()

Definition at line 2140 of file specctra.h.

2140  :
2141  ELEM_HOLDER( T_padstack, NULL )
2142  {
2143  unit = 0;
2144  rotate = T_on;
2145  absolute = T_off;
2146  rules = 0;
2147  attach = T_off;
2148  }
RULE * rules
Definition: specctra.h:2130
UNIT_RES * unit
Definition: specctra.h:2121
#define NULL
DSN_T rotate
Definition: specctra.h:2125
DSN_T attach
Definition: specctra.h:2127
DSN_T absolute
Definition: specctra.h:2126
ELEM_HOLDER(DSN_T aType, ELEM *aParent=0)
Definition: specctra.h:290

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

◆ ~PADSTACK()

DSN::PADSTACK::~PADSTACK ( )
inline

Definition at line 2149 of file specctra.h.

2150  {
2151  delete unit;
2152  delete rules;
2153  }
RULE * rules
Definition: specctra.h:2130
UNIT_RES * unit
Definition: specctra.h:2121

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 342 of file specctra.h.

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

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

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

Definition at line 3566 of file specctra.cpp.

3567 {
3568  if( !lhs->hash.size() )
3569  lhs->hash = lhs->makeHash();
3570 
3571  if( !rhs->hash.size() )
3572  rhs->hash = rhs->makeHash();
3573 
3574  int result = lhs->hash.compare( rhs->hash );
3575  if( result )
3576  return result;
3577 
3578  // Via names hold the drill diameters, so we have to include those to discern
3579  // between two vias with same copper size but with different drill sizes.
3580  result = lhs->padstack_id.compare( rhs->padstack_id );
3581 
3582  return result;
3583 }

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 354 of file specctra.h.

355  {
356  kids.erase( kids.begin()+aIndex );
357  }
ELEM_ARRAY kids
ELEM pointers.
Definition: specctra.h:286

References DSN::ELEM_HOLDER::kids.

◆ FindElem()

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

Function FindElem finds 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 3536 of file specctra.cpp.

3537 {
3538  int repeats=0;
3539 
3540  for( unsigned i = 0; i < kids.size(); ++i )
3541  {
3542  if( kids[i].Type() == aType )
3543  {
3544  if( repeats == instanceNum )
3545  return i;
3546 
3547  ++repeats;
3548  }
3549  }
3550 
3551  return -1;
3552 }
ELEM_ARRAY kids
ELEM pointers.
Definition: specctra.h:286
DSN_T Type() const
Definition: specctra.h:230

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

◆ Format()

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

Function Format writes 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 preceed the output with.
Exceptions
IO_ERRORif a system error writing the output, such as a full disk.

Reimplemented from DSN::ELEM.

Definition at line 2172 of file specctra.h.

2173  {
2174  const char* quote = out->GetQuoteChar( padstack_id.c_str() );
2175 
2176  out->Print( nestLevel, "(%s %s%s%s\n",
2177  Name(),
2178  quote, padstack_id.c_str(), quote );
2179 
2180  FormatContents( out, nestLevel+1 );
2181 
2182  out->Print( nestLevel, ")\n" );
2183  }
const char * Name() const
Definition: specctra.cpp:3505
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:331
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Function FormatContents writes the contents as ASCII out to an OUTPUTFORMATTER according to the SPECC...
Definition: specctra.h:2187
std::string padstack_id
Definition: specctra.h:2120
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:408

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

◆ FormatContents()

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

Function FormatContents writes 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 preceed 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 2187 of file specctra.h.

2188  {
2189  if( unit )
2190  unit->Format( out, nestLevel );
2191 
2192  // format the kids, which in this class are the shapes
2193  ELEM_HOLDER::FormatContents( out, nestLevel );
2194 
2195  out->Print( nestLevel, "%s", "" );
2196 
2197  // spec for <attach_descriptor> says default is on, so
2198  // print the off condition to override this.
2199  if( attach == T_off )
2200  {
2201  out->Print( 0, "(attach off)" );
2202  }
2203  else if( attach == T_on )
2204  {
2205  const char* quote = out->GetQuoteChar( via_id.c_str() );
2206 
2207  out->Print( 0, "(attach on (use_via %s%s%s))",
2208  quote, via_id.c_str(), quote );
2209  }
2210 
2211  if( rotate == T_off ) // print the non-default
2212  out->Print( 0, "(rotate %s)", GetTokenText( rotate ) );
2213 
2214  if( absolute == T_on ) // print the non-default
2215  out->Print( 0, "(absolute %s)", GetTokenText( absolute ) );
2216 
2217  out->Print( 0, "\n" );
2218 
2219  if( rules )
2220  rules->Format( out, nestLevel );
2221  }
RULE * rules
Definition: specctra.h:2130
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:501
UNIT_RES * unit
Definition: specctra.h:2121
std::string via_id
Definition: specctra.h:2128
void Format(OUTPUTFORMATTER *out, int nestLevel) override
Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN f...
Definition: specctra.h:425
DSN_T rotate
Definition: specctra.h:2125
DSN_T attach
Definition: specctra.h:2127
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:331
virtual void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Function FormatContents writes the contents as ASCII out to an OUTPUTFORMATTER according to the SPECC...
Definition: specctra.cpp:3529
const char * GetTokenText(T aTok)
Function GetTokenText is in the DSN namespace and returns the C string representing a SPECCTRA_DB::ke...
Definition: specctra.cpp:69
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:408
DSN_T absolute
Definition: specctra.h:2126

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 2155 of file specctra.h.

2156  {
2157  return padstack_id;
2158  }
std::string padstack_id
Definition: specctra.h:2120

References padstack_id.

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

◆ GetUnits()

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

Function GetUnits returns the units for this section.

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

Returns
UNIT_RES* - from a local or parent scope

Reimplemented from DSN::ELEM.

Definition at line 2224 of file specctra.h.

2225  {
2226  if( unit )
2227  return unit;
2228 
2229  return ELEM::GetUnits();
2230  }
UNIT_RES * unit
Definition: specctra.h:2121
virtual UNIT_RES * GetUnits() const
Function GetUnits returns the units for this section.
Definition: specctra.cpp:3510

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

◆ Insert()

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

Definition at line 337 of file specctra.h.

338  {
339  kids.insert( kids.begin()+aIndex, aElem );
340  }
ELEM_ARRAY kids
ELEM pointers.
Definition: specctra.h:286

References DSN::ELEM_HOLDER::kids.

◆ Length()

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

Function Length returns the number of ELEMs in this ELEM.

Returns
int - the count of children

Definition at line 315 of file specctra.h.

316  {
317  return kids.size();
318  }
ELEM_ARRAY kids
ELEM pointers.
Definition: specctra.h:286

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

Function makeHash returns a string which uniquely represents this ELEM amoung other ELEMs of the same derived class as "this" one.

It is not useable 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 211 of file specctra.h.

212  {
213  sf.Clear();
214  FormatContents( &sf, 0 );
215  sf.StripUseless();
216 
217  return sf.GetString();
218  }
virtual void FormatContents(OUTPUTFORMATTER *out, int nestLevel)
Function FormatContents writes the contents as ASCII out to an OUTPUTFORMATTER according to the SPECC...
Definition: specctra.h:263
const std::string & GetString()
Definition: richio.h:435
void StripUseless()
Removes whitespace, '(', and ')' from the string.
Definition: richio.cpp:494
static STRING_FORMATTER sf
Definition: specctra.h:221
void Clear()
Clear the buffer and empties the internal string.
Definition: richio.h:425

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 349 of file specctra.h.

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

References DSN::ELEM_HOLDER::At().

◆ Remove()

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

Definition at line 331 of file specctra.h.

332  {
333  ELEM_ARRAY::auto_type ret = kids.release( kids.begin()+aIndex );
334  return ret.release();
335  }
ELEM_ARRAY kids
ELEM pointers.
Definition: specctra.h:286

References DSN::ELEM_HOLDER::kids.

◆ Replace()

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

Definition at line 325 of file specctra.h.

326  {
327  ELEM_ARRAY::auto_type ret = kids.replace( aIndex, aElem );
328  return ret.release();
329  }
ELEM_ARRAY kids
ELEM pointers.
Definition: specctra.h:286

References DSN::ELEM_HOLDER::kids.

◆ SetPadstackId()

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

Definition at line 2167 of file specctra.h.

2168  {
2169  padstack_id = aPadstackId;
2170  }
std::string padstack_id
Definition: specctra.h:2120

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 2116 of file specctra.h.

Member Data Documentation

◆ absolute

DSN_T DSN::PADSTACK::absolute
private

Definition at line 2126 of file specctra.h.

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

◆ attach

DSN_T DSN::PADSTACK::attach
private

Definition at line 2127 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 2118 of file specctra.h.

Referenced by Compare().

◆ padstack_id

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

◆ parent

ELEM* DSN::ELEM::parent
protectedinherited

Definition at line 199 of file specctra.h.

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

◆ rotate

DSN_T DSN::PADSTACK::rotate
private

Definition at line 2125 of file specctra.h.

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

◆ rules

RULE* DSN::PADSTACK::rules
private

Definition at line 2130 of file specctra.h.

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

◆ sf

STRING_FORMATTER DSN::ELEM::sf
staticprotectedinherited

Definition at line 221 of file specctra.h.

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

◆ type

DSN_T DSN::ELEM::type
protectedinherited

Definition at line 198 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 2128 of file specctra.h.

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


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