KiCad PCB EDA Suite
DSN::PADSTACK Class Reference

Class 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 throw ( IO_ERROR )
 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 throw ( IO_ERROR )
 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

Class PADSTACK holds either a via or a pad definition.

Definition at line 2095 of file specctra.h.

Constructor & Destructor Documentation

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

References DSN::T_off, and DSN::T_on.

2121  :
2122  ELEM_HOLDER( T_padstack, NULL )
2123  {
2124  unit = 0;
2125  rotate = T_on;
2126  absolute = T_off;
2127  rules = 0;
2128  attach = T_off;
2129  }
RULE * rules
Definition: specctra.h:2111
UNIT_RES * unit
Definition: specctra.h:2102
DSN_T rotate
Definition: specctra.h:2106
DSN_T attach
Definition: specctra.h:2108
DSN_T absolute
Definition: specctra.h:2107
ELEM_HOLDER(DSN_T aType, ELEM *aParent=0)
Definition: specctra.h:291
DSN::PADSTACK::~PADSTACK ( )
inline

Definition at line 2130 of file specctra.h.

References rules, and unit.

2131  {
2132  delete unit;
2133  delete rules;
2134  }
RULE * rules
Definition: specctra.h:2111
UNIT_RES * unit
Definition: specctra.h:2102

Member Function Documentation

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

Definition at line 321 of file specctra.h.

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

322  {
323  kids.push_back( aElem );
324  }
ELEM_ARRAY kids
ELEM pointers.
Definition: specctra.h:287
ELEM* DSN::ELEM_HOLDER::At ( int  aIndex) const
inlineinherited

Definition at line 343 of file specctra.h.

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

344  {
345  // we have varying sized objects and are using polymorphism, so we
346  // must return a pointer not a reference.
347  return (ELEM*) &kids[aIndex];
348  }
ELEM(DSN_T aType, ELEM *aParent=0)
Definition: specctra.cpp:3486
ELEM_ARRAY kids
ELEM pointers.
Definition: specctra.h:287
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 3557 of file specctra.cpp.

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

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

3558 {
3559  // printf( "PADSTACK::Compare( %p, %p)\n", lhs, rhs );
3560 
3561  if( !lhs->hash.size() )
3562  lhs->hash = lhs->makeHash();
3563 
3564  if( !rhs->hash.size() )
3565  rhs->hash = rhs->makeHash();
3566 
3567  int result = lhs->hash.compare( rhs->hash );
3568  if( result )
3569  return result;
3570 
3571  // Via names hold the drill diameters, so we have to include those to discern
3572  // between two vias with same copper size but with different drill sizes.
3573  result = lhs->padstack_id.compare( rhs->padstack_id );
3574 
3575  return result;
3576 }
void DSN::ELEM_HOLDER::Delete ( int  aIndex)
inlineinherited

Definition at line 355 of file specctra.h.

356  {
357  kids.erase( kids.begin()+aIndex );
358  }
ELEM_ARRAY kids
ELEM pointers.
Definition: specctra.h:287
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 3530 of file specctra.cpp.

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

3531 {
3532  int repeats=0;
3533  for( unsigned i=0; i<kids.size(); ++i )
3534  {
3535  if( kids[i].Type() == aType )
3536  {
3537  if( repeats == instanceNum )
3538  return i;
3539  ++repeats;
3540  }
3541  }
3542  return -1;
3543 }
ELEM_ARRAY kids
ELEM pointers.
Definition: specctra.h:287
DSN_T Type() const
Definition: specctra.h:231
void DSN::PADSTACK::Format ( OUTPUTFORMATTER out,
int  nestLevel 
)
throw (IO_ERROR
)
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 2153 of file specctra.h.

References FormatContents(), and DSN::ELEM::Name().

2154  {
2155  const char* quote = out->GetQuoteChar( padstack_id.c_str() );
2156 
2157  out->Print( nestLevel, "(%s %s%s%s\n", Name(),
2158  quote, padstack_id.c_str(), quote );
2159 
2160  FormatContents( out, nestLevel+1 );
2161 
2162  out->Print( nestLevel, ")\n" );
2163  }
const char * Name() const
Definition: specctra.cpp:3497
static const char * GetQuoteChar(const char *wrapee, const char *quote_char)
Function GetQuoteChar performs quote character need determination according to the Specctra DSN speci...
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:2167
std::string padstack_id
Definition: specctra.h:2101
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:408
void DSN::PADSTACK::FormatContents ( OUTPUTFORMATTER out,
int  nestLevel 
)
throw (IO_ERROR
)
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 2167 of file specctra.h.

References DSN::UNIT_RES::Format(), DSN::RULE::Format(), DSN::ELEM_HOLDER::FormatContents(), DSN::GetTokenText(), DSN::T_off, and DSN::T_on.

Referenced by Format().

2168  {
2169  if( unit )
2170  unit->Format( out, nestLevel );
2171 
2172  // format the kids, which in this class are the shapes
2173  ELEM_HOLDER::FormatContents( out, nestLevel );
2174 
2175  out->Print( nestLevel, "%s", "" );
2176 
2177  // spec for <attach_descriptor> says default is on, so
2178  // print the off condition to override this.
2179  if( attach == T_off )
2180  out->Print( 0, "(attach off)" );
2181  else if( attach == T_on )
2182  {
2183  const char* quote = out->GetQuoteChar( via_id.c_str() );
2184  out->Print( 0, "(attach on (use_via %s%s%s))",
2185  quote, via_id.c_str(), quote );
2186  }
2187 
2188  if( rotate == T_off ) // print the non-default
2189  out->Print( 0, "(rotate %s)", GetTokenText( rotate ) );
2190 
2191  if( absolute == T_on ) // print the non-default
2192  out->Print( 0, "(absolute %s)", GetTokenText( absolute ) );
2193 
2194  out->Print( 0, "\n" );
2195 
2196  if( rules )
2197  rules->Format( out, nestLevel );
2198  }
RULE * rules
Definition: specctra.h:2111
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:505
UNIT_RES * unit
Definition: specctra.h:2102
std::string via_id
Definition: specctra.h:2109
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:426
DSN_T rotate
Definition: specctra.h:2106
DSN_T attach
Definition: specctra.h:2108
static const char * GetQuoteChar(const char *wrapee, const char *quote_char)
Function GetQuoteChar performs quote character need determination according to the Specctra DSN speci...
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:3521
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,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:408
DSN_T absolute
Definition: specctra.h:2107
const std::string& DSN::PADSTACK::GetPadstackId ( )
inline

Definition at line 2136 of file specctra.h.

References padstack_id.

Referenced by DSN::SPECCTRA_DB::exportNETCLASS(), and DSN::LIBRARY::FindPADSTACK().

2137  {
2138  return padstack_id;
2139  }
std::string padstack_id
Definition: specctra.h:2101
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 2201 of file specctra.h.

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

2202  {
2203  if( unit )
2204  return unit;
2205 
2206  return ELEM::GetUnits();
2207  }
virtual UNIT_RES * GetUnits() const
Function GetUnits returns the units for this section.
Definition: specctra.cpp:3502
UNIT_RES * unit
Definition: specctra.h:2102
void DSN::ELEM_HOLDER::Insert ( int  aIndex,
ELEM aElem 
)
inlineinherited

Definition at line 338 of file specctra.h.

339  {
340  kids.insert( kids.begin()+aIndex, aElem );
341  }
ELEM_ARRAY kids
ELEM pointers.
Definition: specctra.h:287
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 316 of file specctra.h.

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

317  {
318  return kids.size();
319  }
ELEM_ARRAY kids
ELEM pointers.
Definition: specctra.h:287
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 212 of file specctra.h.

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

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

213  {
214  sf.Clear();
215  FormatContents( &sf, 0 );
216  sf.StripUseless();
217 
218  return sf.GetString();
219  }
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:264
const std::string & GetString()
Definition: richio.h:475
void StripUseless()
Function StripUseless removes whitespace, '(', and ')' from the mystring.
Definition: richio.cpp:504
static STRING_FORMATTER sf
Definition: specctra.h:222
void Clear()
Function Clear clears the buffer and empties the internal string.
Definition: richio.h:464
ELEM* DSN::ELEM_HOLDER::operator[] ( int  aIndex) const
inlineinherited

Definition at line 350 of file specctra.h.

References DSN::ELEM_HOLDER::At().

351  {
352  return At( aIndex );
353  }
ELEM * At(int aIndex) const
Definition: specctra.h:343
ELEM* DSN::ELEM_HOLDER::Remove ( int  aIndex)
inlineinherited

Definition at line 332 of file specctra.h.

333  {
334  ELEM_ARRAY::auto_type ret = kids.release( kids.begin()+aIndex );
335  return ret.release();
336  }
ELEM_ARRAY kids
ELEM pointers.
Definition: specctra.h:287
ELEM* DSN::ELEM_HOLDER::Replace ( int  aIndex,
ELEM aElem 
)
inlineinherited

Definition at line 326 of file specctra.h.

327  {
328  ELEM_ARRAY::auto_type ret = kids.replace( aIndex, aElem );
329  return ret.release();
330  }
ELEM_ARRAY kids
ELEM pointers.
Definition: specctra.h:287
void DSN::PADSTACK::SetPadstackId ( const char *  aPadstackId)
inline

Definition at line 2148 of file specctra.h.

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

2149  {
2150  padstack_id = aPadstackId;
2151  }
std::string padstack_id
Definition: specctra.h:2101

Friends And Related Function Documentation

friend class SPECCTRA_DB
friend

Definition at line 2097 of file specctra.h.

Member Data Documentation

DSN_T DSN::PADSTACK::absolute
private

Definition at line 2107 of file specctra.h.

DSN_T DSN::PADSTACK::attach
private

Definition at line 2108 of file specctra.h.

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

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

Definition at line 2099 of file specctra.h.

Referenced by Compare().

std::string DSN::PADSTACK::padstack_id
private
ELEM* DSN::ELEM::parent
protectedinherited

Definition at line 200 of file specctra.h.

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

DSN_T DSN::PADSTACK::rotate
private

Definition at line 2106 of file specctra.h.

RULE* DSN::PADSTACK::rules
private

Definition at line 2111 of file specctra.h.

Referenced by ~PADSTACK().

STRING_FORMATTER DSN::ELEM::sf
staticprotectedinherited

Definition at line 222 of file specctra.h.

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

DSN_T DSN::ELEM::type
protectedinherited

Definition at line 199 of file specctra.h.

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

UNIT_RES* DSN::PADSTACK::unit
private

Definition at line 2102 of file specctra.h.

Referenced by GetUnits(), and ~PADSTACK().

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

Definition at line 2109 of file specctra.h.


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