KiCad PCB EDA Suite
DSN::LIBRARY Class Reference

A <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)
 Search this LIBRARY for an image which matches the argument. More...
 
void AppendIMAGE (IMAGE *aImage)
 Add the image to the image list. More...
 
IMAGELookupIMAGE (IMAGE *aImage)
 Add the image only if one exactly like it does not already exist in the image container. More...
 
int FindVia (PADSTACK *aVia)
 Search this LIBRARY for a via which matches the argument. More...
 
void AppendVia (PADSTACK *aVia)
 Add aVia to the internal via container. More...
 
void AppendPADSTACK (PADSTACK *aPadstack)
 Add the padstack to the padstack container. More...
 
PADSTACKLookupVia (PADSTACK *aVia)
 Add the via only if one exactly like it does not already exist in the padstack container. More...
 
PADSTACKFindPADSTACK (const std::string &aPadstackId)
 Search the padstack container by name. 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...
 
DSN_T Type () const
 
const char * Name () const
 
virtual void Format (OUTPUTFORMATTER *out, int nestLevel)
 Write 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 ()
 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 Attributes

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

Friends

class SPECCTRA_DB
 

Detailed Description

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

Constructor & Destructor Documentation

◆ LIBRARY()

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

Definition at line 2260 of file specctra.h.

2260  :
2261  ELEM( aType, aParent )
2262  {
2263  unit = 0;
2264 // via_start_index = -1; // 0 or greater means there is at least one via
2265  }
ELEM(DSN_T aType, ELEM *aParent=0)
Definition: specctra.cpp:3749
UNIT_RES * unit
Definition: specctra.h:2444

References unit.

◆ ~LIBRARY()

DSN::LIBRARY::~LIBRARY ( )
inline

Definition at line 2267 of file specctra.h.

2268  {
2269  delete unit;
2270  }
UNIT_RES * unit
Definition: specctra.h:2444

References unit.

Member Function Documentation

◆ AddPadstack()

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

Definition at line 2272 of file specctra.h.

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

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

Add the image to the image list.

Definition at line 2321 of file specctra.h.

2322  {
2323  aImage->SetParent( this );
2324  images.push_back( aImage );
2325  }
IMAGES images
Definition: specctra.h:2445

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

Referenced by LookupIMAGE().

◆ AppendPADSTACK()

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

Add the padstack to the padstack container.

Definition at line 2375 of file specctra.h.

2376  {
2377  aPadstack->SetParent( this );
2378  padstacks.push_back( aPadstack );
2379  }
PADSTACKS padstacks
all except vias, which are in 'vias'
Definition: specctra.h:2447

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

◆ AppendVia()

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

Add aVia to the internal via container.

Definition at line 2365 of file specctra.h.

2366  {
2367  aVia->SetParent( this );
2368  vias.push_back( aVia );
2369  }
PADSTACKS vias
Definition: specctra.h:2448

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

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

◆ FindIMAGE()

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

Search this LIBRARY for an image which matches the argument.

Returns
index of image if found, else -1.

Definition at line 2294 of file specctra.h.

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

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

Search the padstack container by name.

Returns
The PADSTACK with a matching name if it exists, else nullptr.

Definition at line 2405 of file specctra.h.

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

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

◆ FindVia()

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

Search this LIBRARY for a via which matches the argument.

Returns
the index found in the padstack list, else -1.

Definition at line 2351 of file specctra.h.

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

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

Referenced by LookupVia().

◆ Format()

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

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 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 3774 of file specctra.cpp.

3775 {
3776  out->Print( nestLevel, "(%s\n", Name() );
3777 
3778  FormatContents( out, nestLevel+1 );
3779 
3780  out->Print( nestLevel, ")\n" );
3781 }
const char * Name() const
Definition: specctra.cpp:3760
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
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426

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

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.

Definition at line 2418 of file specctra.h.

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

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

◆ GetUnits()

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

2434  {
2435  if( unit )
2436  return unit;
2437 
2438  return ELEM::GetUnits();
2439  }
UNIT_RES * unit
Definition: specctra.h:2444
virtual UNIT_RES * GetUnits() const
Return the units for this section.
Definition: specctra.cpp:3765

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

◆ LookupIMAGE()

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

Add the image only if one exactly like it does not already exist in the image container.

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

2334  {
2335  int ndx = FindIMAGE( aImage );
2336 
2337  if( ndx == -1 )
2338  {
2339  AppendIMAGE( aImage );
2340  return aImage;
2341  }
2342 
2343  return &images[ndx];
2344  }
int FindIMAGE(IMAGE *aImage)
Search this LIBRARY for an image which matches the argument.
Definition: specctra.h:2294
IMAGES images
Definition: specctra.h:2445
void AppendIMAGE(IMAGE *aImage)
Add the image to the image list.
Definition: specctra.h:2321

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

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

◆ LookupVia()

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

Add the via only if one exactly like it does not already exist in the padstack container.

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

2388  {
2389  int ndx = FindVia( aVia );
2390 
2391  if( ndx == -1 )
2392  {
2393  AppendVia( aVia );
2394  return aVia;
2395  }
2396 
2397  return &vias[ndx];
2398  }
int FindVia(PADSTACK *aVia)
Search this LIBRARY for a via which matches the argument.
Definition: specctra.h:2351
PADSTACKS vias
Definition: specctra.h:2448
void AppendVia(PADSTACK *aVia)
Add aVia to the internal via container.
Definition: specctra.h:2365

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

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

◆ 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 );
267  sf.StripUseless();
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
const std::string & GetString()
Definition: richio.h:438
void StripUseless()
Removes whitespace, '(', and ')' from the string.
Definition: richio.cpp:512
static STRING_FORMATTER sf
Definition: specctra.h:273
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 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 2442 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 2447 of file specctra.h.

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

◆ parent

ELEM* DSN::ELEM::parent
protectedinherited

Definition at line 276 of file specctra.h.

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

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

Definition at line 2444 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: