KiCad PCB EDA Suite
DSN::LIBRARY Class Reference

LIBRARY corresponds to the <library_descriptor> in the specctra dsn specification. More...

#include <specctra.h>

Inheritance diagram for DSN::LIBRARY:
DSN::ELEM

Public Member Functions

 LIBRARY (ELEM *aParent, DSN_T aType=T_library)
 
 ~LIBRARY ()
 
void AddPadstack (PADSTACK *aPadstack)
 
int FindIMAGE (IMAGE *aImage)
 Function FindIMAGE searches this LIBRARY for an image which matches the argument. More...
 
void AppendIMAGE (IMAGE *aImage)
 Function AppendIMAGE adds the image to the image list. More...
 
IMAGELookupIMAGE (IMAGE *aImage)
 Function LookupIMAGE will add the image only if one exactly like it does not already exist in the image container. More...
 
int FindVia (PADSTACK *aVia)
 Function FindVia searches this LIBRARY for a via which matches the argument. More...
 
void AppendVia (PADSTACK *aVia)
 Function AppendVia adds aVia to the internal via container. More...
 
void AppendPADSTACK (PADSTACK *aPadstack)
 Function AppendPADSTACK adds the padstack to the padstack container. More...
 
PADSTACKLookupVia (PADSTACK *aVia)
 Function LookupVia will add the via only if one exactly like it does not already exist in the padstack container. More...
 
PADSTACKFindPADSTACK (const std::string &aPadstackId)
 Function FindPADSTACK searches the padstack container by name. 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...
 
DSN_T Type () const
 
const char * Name () const
 
virtual void Format (OUTPUTFORMATTER *out, int nestLevel)
 Function Format writes this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format. More...
 
void SetParent (ELEM *aParent)
 

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

UNIT_RESunit
 
IMAGES images
 
PADSTACKS padstacks
 all except vias, which are in 'vias' More...
 
PADSTACKS vias
 

Friends

class SPECCTRA_DB
 

Detailed Description

LIBRARY corresponds to the <library_descriptor> in the specctra dsn specification.

Only unit_descriptor, image_descriptors, and padstack_descriptors are included as children at this time.

Definition at line 2251 of file specctra.h.

Constructor & Destructor Documentation

◆ LIBRARY()

DSN::LIBRARY::LIBRARY ( ELEM aParent,
DSN_T  aType = T_library 
)
inline

Definition at line 2263 of file specctra.h.

2263  :
2264  ELEM( aType, aParent )
2265  {
2266  unit = 0;
2267 // via_start_index = -1; // 0 or greater means there is at least one via
2268  }
ELEM(DSN_T aType, ELEM *aParent=0)
Definition: specctra.cpp:3494
UNIT_RES * unit
Definition: specctra.h:2255

References unit.

◆ ~LIBRARY()

DSN::LIBRARY::~LIBRARY ( )
inline

Definition at line 2269 of file specctra.h.

2270  {
2271  delete unit;
2272  }
UNIT_RES * unit
Definition: specctra.h:2255

References unit.

Member Function Documentation

◆ AddPadstack()

void DSN::LIBRARY::AddPadstack ( PADSTACK aPadstack)
inline

Definition at line 2274 of file specctra.h.

2275  {
2276  aPadstack->SetParent( this );
2277  padstacks.push_back( aPadstack );
2278  }
PADSTACKS padstacks
all except vias, which are in 'vias'
Definition: specctra.h:2258

References padstacks, and DSN::ELEM::SetParent().

Referenced by DSN::SPECCTRA_DB::doLIBRARY(), and DSN::SPECCTRA_DB::FromBOARD().

◆ AppendIMAGE()

void DSN::LIBRARY::AppendIMAGE ( IMAGE aImage)
inline

Function AppendIMAGE adds the image to the image list.

Definition at line 2323 of file specctra.h.

2324  {
2325  aImage->SetParent( this );
2326  images.push_back( aImage );
2327  }
IMAGES images
Definition: specctra.h:2256

References images, and DSN::ELEM::SetParent().

Referenced by LookupIMAGE().

◆ AppendPADSTACK()

void DSN::LIBRARY::AppendPADSTACK ( PADSTACK aPadstack)
inline

Function AppendPADSTACK adds the padstack to the padstack container.

Definition at line 2378 of file specctra.h.

2379  {
2380  aPadstack->SetParent( this );
2381  padstacks.push_back( aPadstack );
2382  }
PADSTACKS padstacks
all except vias, which are in 'vias'
Definition: specctra.h:2258

References padstacks, and DSN::ELEM::SetParent().

◆ AppendVia()

void DSN::LIBRARY::AppendVia ( PADSTACK aVia)
inline

Function AppendVia adds aVia to the internal via container.

Definition at line 2367 of file specctra.h.

2368  {
2369  aVia->SetParent( this );
2370  vias.push_back( aVia );
2371  }
PADSTACKS vias
Definition: specctra.h:2259

References DSN::ELEM::SetParent(), and vias.

Referenced by DSN::SPECCTRA_DB::FromBOARD(), and LookupVia().

◆ FindIMAGE()

int DSN::LIBRARY::FindIMAGE ( IMAGE aImage)
inline

Function FindIMAGE searches this LIBRARY for an image which matches the argument.

Returns
int - if found the index into the images list, else -1.

Definition at line 2297 of file specctra.h.

2298  {
2299  unsigned i;
2300  for( i=0; i<images.size(); ++i )
2301  {
2302  if( 0 == IMAGE::Compare( aImage, &images[i] ) )
2303  return (int) i;
2304  }
2305 
2306  // There is no match to the IMAGE contents, but now generate a unique
2307  // name for it.
2308  int dups = 1;
2309  for( i=0; i<images.size(); ++i )
2310  {
2311  if( 0 == aImage->image_id.compare( images[i].image_id ) )
2312  aImage->duplicated = dups++;
2313  }
2314 
2315  return -1;
2316  }
static int Compare(IMAGE *lhs, IMAGE *rhs)
Function Compare compares two objects of this type and returns <0, 0, or >0.
Definition: specctra.cpp:3588
IMAGES images
Definition: specctra.h:2256

References DSN::IMAGE::Compare(), DSN::IMAGE::duplicated, DSN::IMAGE::image_id, and images.

Referenced by LookupIMAGE().

◆ FindPADSTACK()

PADSTACK* DSN::LIBRARY::FindPADSTACK ( const std::string &  aPadstackId)
inline

Function FindPADSTACK searches the padstack container by name.

Returns
PADSTACK* - The PADSTACK with a matching name if it exists, else NULL.

Definition at line 2408 of file specctra.h.

2409  {
2410  for( unsigned i=0; i<padstacks.size(); ++i )
2411  {
2412  PADSTACK* ps = &padstacks[i];
2413 
2414  if( ps->GetPadstackId().compare( aPadstackId ) == 0 )
2415  return ps;
2416  }
2417  return NULL;
2418  }
#define NULL
PADSTACKS padstacks
all except vias, which are in 'vias'
Definition: specctra.h:2258

References DSN::PADSTACK::GetPadstackId(), NULL, and padstacks.

◆ FindVia()

int DSN::LIBRARY::FindVia ( PADSTACK aVia)
inline

Function FindVia searches this LIBRARY for a via which matches the argument.

Returns
int - if found the index into the padstack list, else -1.

Definition at line 2353 of file specctra.h.

2354  {
2355  for( unsigned i = 0; i < vias.size(); ++i )
2356  {
2357  if( 0 == PADSTACK::Compare( aVia, &vias[i] ) )
2358  return int( i );
2359  }
2360  return -1;
2361  }
static int Compare(PADSTACK *lhs, PADSTACK *rhs)
Function Compare compares two objects of this type and returns <0, 0, or >0.
Definition: specctra.cpp:3566
PADSTACKS vias
Definition: specctra.h:2259

References DSN::PADSTACK::Compare(), and vias.

Referenced by LookupVia().

◆ Format()

void DSN::ELEM::Format ( OUTPUTFORMATTER out,
int  nestLevel 
)
virtualinherited

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 in DSN::SESSION, DSN::NET_OUT, DSN::SUPPLY_PIN, DSN::ANCESTOR, DSN::PCB, DSN::WIRE_VIA, DSN::WIRE, DSN::CLASS, DSN::NET, DSN::COMP_ORDER, DSN::FROMTO, DSN::PADSTACK, DSN::IMAGE, DSN::PIN, DSN::SHAPE, DSN::COMPONENT, DSN::PLACE, DSN::GRID, DSN::STRINGPROP, DSN::TOKPROP, DSN::LAYER_NOISE_WEIGHT, DSN::SPECCTRA_LAYER_PAIR, DSN::LAYER, DSN::CONTROL, DSN::VIA, DSN::KEEPOUT, DSN::WINDOW, DSN::QARC, DSN::CIRCLE, DSN::BOUNDARY, DSN::PATH, DSN::LAYER_RULE, DSN::RULE, DSN::RECTANGLE, and DSN::UNIT_RES.

Definition at line 3519 of file specctra.cpp.

3520 {
3521  out->Print( nestLevel, "(%s\n", Name() );
3522 
3523  FormatContents( out, nestLevel+1 );
3524 
3525  out->Print( nestLevel, ")\n" );
3526 }
const char * Name() const
Definition: specctra.cpp:3505
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
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:408

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

Referenced by DSN::WINDOW::Format(), DSN::KEEPOUT::Format(), DSN::CONTROL::Format(), DSN::PLACE::Format(), DSN::SHAPE::Format(), DSN::CLASS::Format(), DSN::WIRE::Format(), DSN::PCB::Format(), DSN::SESSION::Format(), DSN::ELEM_HOLDER::FormatContents(), DSN::CLASS_CLASS::FormatContents(), DSN::STRUCTURE::FormatContents(), and DSN::ROUTE::FormatContents().

◆ FormatContents()

void DSN::LIBRARY::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.

Definition at line 2420 of file specctra.h.

2421  {
2422  if( unit )
2423  unit->Format( out, nestLevel );
2424 
2425  for( IMAGES::iterator i = images.begin(); i != images.end(); ++i )
2426  i->Format( out, nestLevel );
2427 
2428  for( PADSTACKS::iterator i = padstacks.begin(); i != padstacks.end(); ++i )
2429  i->Format( out, nestLevel );
2430 
2431  for( PADSTACKS::iterator i = vias.begin(); i != vias.end(); ++i )
2432  i->Format( out, nestLevel );
2433  }
PADSTACKS vias
Definition: specctra.h:2259
UNIT_RES * unit
Definition: specctra.h:2255
IMAGES images
Definition: specctra.h:2256
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
PADSTACKS padstacks
all except vias, which are in 'vias'
Definition: specctra.h:2258

References DSN::UNIT_RES::Format(), images, padstacks, unit, and vias.

◆ GetUnits()

UNIT_RES* DSN::LIBRARY::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 2435 of file specctra.h.

2436  {
2437  if( unit )
2438  return unit;
2439 
2440  return ELEM::GetUnits();
2441  }
UNIT_RES * unit
Definition: specctra.h:2255
virtual UNIT_RES * GetUnits() const
Function GetUnits returns the units for this section.
Definition: specctra.cpp:3510

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

◆ LookupIMAGE()

IMAGE* DSN::LIBRARY::LookupIMAGE ( IMAGE aImage)
inline

Function LookupIMAGE will add the image only if one exactly like it does not already exist in the image container.

Returns
IMAGE* - the IMAGE which is registered in the LIBRARY that matches the argument, and it will be either the argument or a previous image which is a duplicate.

Definition at line 2337 of file specctra.h.

2338  {
2339  int ndx = FindIMAGE( aImage );
2340  if( ndx == -1 )
2341  {
2342  AppendIMAGE( aImage );
2343  return aImage;
2344  }
2345  return &images[ndx];
2346  }
int FindIMAGE(IMAGE *aImage)
Function FindIMAGE searches this LIBRARY for an image which matches the argument.
Definition: specctra.h:2297
IMAGES images
Definition: specctra.h:2256
void AppendIMAGE(IMAGE *aImage)
Function AppendIMAGE adds the image to the image list.
Definition: specctra.h:2323

References AppendIMAGE(), FindIMAGE(), and images.

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

◆ LookupVia()

PADSTACK* DSN::LIBRARY::LookupVia ( PADSTACK aVia)
inline

Function LookupVia will add the via only if one exactly like it does not already exist in the padstack container.

Returns
PADSTACK* - the PADSTACK which is registered in the LIBRARY that matches the argument, and it will be either the argument or a previous padstack which is a duplicate.

Definition at line 2392 of file specctra.h.

2393  {
2394  int ndx = FindVia( aVia );
2395  if( ndx == -1 )
2396  {
2397  AppendVia( aVia );
2398  return aVia;
2399  }
2400  return &vias[ndx];
2401  }
int FindVia(PADSTACK *aVia)
Function FindVia searches this LIBRARY for a via which matches the argument.
Definition: specctra.h:2353
PADSTACKS vias
Definition: specctra.h:2259
void AppendVia(PADSTACK *aVia)
Function AppendVia adds aVia to the internal via container.
Definition: specctra.h:2367

References AppendVia(), FindVia(), and vias.

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

◆ 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 DSN::PADSTACK::Compare().

◆ Name()

◆ SetParent()

void DSN::ELEM::SetParent ( ELEM aParent)
inlineinherited

◆ Type()

Friends And Related Function Documentation

◆ SPECCTRA_DB

friend class SPECCTRA_DB
friend

Definition at line 2253 of file specctra.h.

Member Data Documentation

◆ images

IMAGES DSN::LIBRARY::images
private

◆ padstacks

PADSTACKS DSN::LIBRARY::padstacks
private

all except vias, which are in 'vias'

Definition at line 2258 of file specctra.h.

Referenced by AddPadstack(), AppendPADSTACK(), FindPADSTACK(), and FormatContents().

◆ parent

ELEM* DSN::ELEM::parent
protectedinherited

Definition at line 199 of file specctra.h.

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

◆ 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::LIBRARY::unit
private

Definition at line 2255 of file specctra.h.

Referenced by DSN::SPECCTRA_DB::doLIBRARY(), FormatContents(), GetUnits(), LIBRARY(), and ~LIBRARY().

◆ vias

PADSTACKS DSN::LIBRARY::vias
private

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