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
 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

Class PADSTACK holds either a via or a pad definition.

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

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

2124  :
2125  ELEM_HOLDER( T_padstack, NULL )
2126  {
2127  unit = 0;
2128  rotate = T_on;
2129  absolute = T_off;
2130  rules = 0;
2131  attach = T_off;
2132  }
RULE * rules
Definition: specctra.h:2114
UNIT_RES * unit
Definition: specctra.h:2105
DSN_T rotate
Definition: specctra.h:2109
DSN_T attach
Definition: specctra.h:2111
DSN_T absolute
Definition: specctra.h:2110
ELEM_HOLDER(DSN_T aType, ELEM *aParent=0)
Definition: specctra.h:291
DSN::PADSTACK::~PADSTACK ( )
inline

Definition at line 2133 of file specctra.h.

References rules, and unit.

2134  {
2135  delete unit;
2136  delete rules;
2137  }
RULE * rules
Definition: specctra.h:2114
UNIT_RES * unit
Definition: specctra.h:2105

Member Function Documentation

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

Definition at line 343 of file specctra.h.

Referenced by DSN::CONTROL::Format(), DSN::ELEM_HOLDER::FormatContents(), 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:3490
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 3561 of file specctra.cpp.

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

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

3562 {
3563  // printf( "PADSTACK::Compare( %p, %p)\n", lhs, rhs );
3564 
3565  if( !lhs->hash.size() )
3566  lhs->hash = lhs->makeHash();
3567 
3568  if( !rhs->hash.size() )
3569  rhs->hash = rhs->makeHash();
3570 
3571  int result = lhs->hash.compare( rhs->hash );
3572  if( result )
3573  return result;
3574 
3575  // Via names hold the drill diameters, so we have to include those to discern
3576  // between two vias with same copper size but with different drill sizes.
3577  result = lhs->padstack_id.compare( rhs->padstack_id );
3578 
3579  return result;
3580 }
YYCODETYPE lhs
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 3534 of file specctra.cpp.

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

3535 {
3536  int repeats=0;
3537  for( unsigned i=0; i<kids.size(); ++i )
3538  {
3539  if( kids[i].Type() == aType )
3540  {
3541  if( repeats == instanceNum )
3542  return i;
3543  ++repeats;
3544  }
3545  }
3546  return -1;
3547 }
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 
)
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 2156 of file specctra.h.

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

2157  {
2158  const char* quote = out->GetQuoteChar( padstack_id.c_str() );
2159 
2160  out->Print( nestLevel, "(%s %s%s%s\n", Name(),
2161  quote, padstack_id.c_str(), quote );
2162 
2163  FormatContents( out, nestLevel+1 );
2164 
2165  out->Print( nestLevel, ")\n" );
2166  }
const char * Name() const
Definition: specctra.cpp:3501
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:327
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:2170
std::string padstack_id
Definition: specctra.h:2104
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404
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 2170 of file specctra.h.

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

Referenced by Format().

2171  {
2172  if( unit )
2173  unit->Format( out, nestLevel );
2174 
2175  // format the kids, which in this class are the shapes
2176  ELEM_HOLDER::FormatContents( out, nestLevel );
2177 
2178  out->Print( nestLevel, "%s", "" );
2179 
2180  // spec for <attach_descriptor> says default is on, so
2181  // print the off condition to override this.
2182  if( attach == T_off )
2183  out->Print( 0, "(attach off)" );
2184  else if( attach == T_on )
2185  {
2186  const char* quote = out->GetQuoteChar( via_id.c_str() );
2187  out->Print( 0, "(attach on (use_via %s%s%s))",
2188  quote, via_id.c_str(), quote );
2189  }
2190 
2191  if( rotate == T_off ) // print the non-default
2192  out->Print( 0, "(rotate %s)", GetTokenText( rotate ) );
2193 
2194  if( absolute == T_on ) // print the non-default
2195  out->Print( 0, "(absolute %s)", GetTokenText( absolute ) );
2196 
2197  out->Print( 0, "\n" );
2198 
2199  if( rules )
2200  rules->Format( out, nestLevel );
2201  }
RULE * rules
Definition: specctra.h:2114
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:2105
std::string via_id
Definition: specctra.h:2112
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:2109
DSN_T attach
Definition: specctra.h:2111
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:327
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:3525
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:404
DSN_T absolute
Definition: specctra.h:2110
const std::string& DSN::PADSTACK::GetPadstackId ( )
inline

Definition at line 2139 of file specctra.h.

References padstack_id.

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

2140  {
2141  return padstack_id;
2142  }
std::string padstack_id
Definition: specctra.h:2104
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 2204 of file specctra.h.

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

2205  {
2206  if( unit )
2207  return unit;
2208 
2209  return ELEM::GetUnits();
2210  }
virtual UNIT_RES * GetUnits() const
Function GetUnits returns the units for this section.
Definition: specctra.cpp:3506
UNIT_RES * unit
Definition: specctra.h:2105
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(), DSN::ELEM_HOLDER::FormatContents(), DSN::STRUCTURE::FormatContents(), and DSN::SPECCTRA_DB::makeVIA().

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:500
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 2151 of file specctra.h.

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

2152  {
2153  padstack_id = aPadstackId;
2154  }
std::string padstack_id
Definition: specctra.h:2104

Friends And Related Function Documentation

friend class SPECCTRA_DB
friend

Definition at line 2100 of file specctra.h.

Member Data Documentation

DSN_T DSN::PADSTACK::absolute
private

Definition at line 2110 of file specctra.h.

Referenced by DSN::SPECCTRA_DB::doPADSTACK().

DSN_T DSN::PADSTACK::attach
private

Definition at line 2111 of file specctra.h.

Referenced by DSN::SPECCTRA_DB::doPADSTACK().

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

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

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

Referenced by DSN::SPECCTRA_DB::doPADSTACK().

RULE* DSN::PADSTACK::rules
private

Definition at line 2114 of file specctra.h.

Referenced by DSN::SPECCTRA_DB::doPADSTACK(), and ~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::UNIT_RES::Format(), DSN::ELEM::Name(), and DSN::ELEM::Type().

UNIT_RES* DSN::PADSTACK::unit
private

Definition at line 2105 of file specctra.h.

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

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

Definition at line 2112 of file specctra.h.

Referenced by DSN::SPECCTRA_DB::doPADSTACK().


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