KiCad PCB EDA Suite
DSN::LIBRARY Class Reference

Class 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

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

Constructor & Destructor Documentation

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

Definition at line 2243 of file specctra.h.

2243  :
2244  ELEM( aType, aParent )
2245  {
2246  unit = 0;
2247 // via_start_index = -1; // 0 or greater means there is at least one via
2248  }
ELEM(DSN_T aType, ELEM *aParent=0)
Definition: specctra.cpp:3490
UNIT_RES * unit
Definition: specctra.h:2235
DSN::LIBRARY::~LIBRARY ( )
inline

Definition at line 2249 of file specctra.h.

References unit.

2250  {
2251  delete unit;
2252  }
UNIT_RES * unit
Definition: specctra.h:2235

Member Function Documentation

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

Definition at line 2254 of file specctra.h.

References DSN::ELEM::SetParent().

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

2255  {
2256  aPadstack->SetParent( this );
2257  padstacks.push_back( aPadstack );
2258  }
PADSTACKS padstacks
all except vias, which are in 'vias'
Definition: specctra.h:2238
void DSN::LIBRARY::AppendIMAGE ( IMAGE aImage)
inline

Function AppendIMAGE adds the image to the image list.

Definition at line 2303 of file specctra.h.

References DSN::ELEM::SetParent().

Referenced by LookupIMAGE().

2304  {
2305  aImage->SetParent( this );
2306  images.push_back( aImage );
2307  }
IMAGES images
Definition: specctra.h:2236
void DSN::LIBRARY::AppendPADSTACK ( PADSTACK aPadstack)
inline

Function AppendPADSTACK adds the padstack to the padstack container.

Definition at line 2358 of file specctra.h.

References DSN::ELEM::SetParent().

2359  {
2360  aPadstack->SetParent( this );
2361  padstacks.push_back( aPadstack );
2362  }
PADSTACKS padstacks
all except vias, which are in 'vias'
Definition: specctra.h:2238
void DSN::LIBRARY::AppendVia ( PADSTACK aVia)
inline

Function AppendVia adds aVia to the internal via container.

Definition at line 2347 of file specctra.h.

References DSN::ELEM::SetParent().

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

2348  {
2349  aVia->SetParent( this );
2350  vias.push_back( aVia );
2351  }
PADSTACKS vias
Definition: specctra.h:2239
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 2277 of file specctra.h.

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

Referenced by LookupIMAGE().

2278  {
2279  unsigned i;
2280  for( i=0; i<images.size(); ++i )
2281  {
2282  if( 0 == IMAGE::Compare( aImage, &images[i] ) )
2283  return (int) i;
2284  }
2285 
2286  // There is no match to the IMAGE contents, but now generate a unique
2287  // name for it.
2288  int dups = 1;
2289  for( i=0; i<images.size(); ++i )
2290  {
2291  if( 0 == aImage->image_id.compare( images[i].image_id ) )
2292  aImage->duplicated = dups++;
2293  }
2294 
2295  return -1;
2296  }
IMAGES images
Definition: specctra.h:2236
static int Compare(IMAGE *lhs, IMAGE *rhs)
Function Compare compares two objects of this type and returns <0, 0, or >0.
Definition: specctra.cpp:3585
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 2388 of file specctra.h.

References DSN::PADSTACK::GetPadstackId().

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

2389  {
2390  for( unsigned i=0; i<padstacks.size(); ++i )
2391  {
2392  PADSTACK* ps = &padstacks[i];
2393  if( 0 == ps->GetPadstackId().compare( aPadstackId ) )
2394  return ps;
2395  }
2396  return NULL;
2397  }
PADSTACKS padstacks
all except vias, which are in 'vias'
Definition: specctra.h:2238
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 2333 of file specctra.h.

References DSN::PADSTACK::Compare().

Referenced by LookupVia().

2334  {
2335  for( unsigned i=0; i<vias.size(); ++i )
2336  {
2337  if( 0 == PADSTACK::Compare( aVia, &vias[i] ) )
2338  return int( i );
2339  }
2340  return -1;
2341  }
static int Compare(PADSTACK *lhs, PADSTACK *rhs)
Function Compare compares two objects of this type and returns <0, 0, or >0.
Definition: specctra.cpp:3561
PADSTACKS vias
Definition: specctra.h:2239
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 3515 of file specctra.cpp.

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().

3516 {
3517  out->Print( nestLevel, "(%s\n", Name() );
3518 
3519  FormatContents( out, nestLevel+1 );
3520 
3521  out->Print( nestLevel, ")\n" );
3522 }
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 char * Name() const
Definition: specctra.cpp:3501
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::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 2399 of file specctra.h.

References DSN::UNIT_RES::Format().

2400  {
2401  if( unit )
2402  unit->Format( out, nestLevel );
2403 
2404  for( IMAGES::iterator i=images.begin(); i!=images.end(); ++i )
2405  i->Format( out, nestLevel );
2406 
2407  for( PADSTACKS::iterator i=padstacks.begin(); i!=padstacks.end(); ++i )
2408  i->Format( out, nestLevel );
2409 
2410  for( PADSTACKS::iterator i=vias.begin(); i!=vias.end(); ++i )
2411  i->Format( out, nestLevel );
2412  }
PADSTACKS vias
Definition: specctra.h:2239
UNIT_RES * unit
Definition: specctra.h:2235
IMAGES images
Definition: specctra.h:2236
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
PADSTACKS padstacks
all except vias, which are in 'vias'
Definition: specctra.h:2238
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 2414 of file specctra.h.

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

2415  {
2416  if( unit )
2417  return unit;
2418 
2419  return ELEM::GetUnits();
2420  }
virtual UNIT_RES * GetUnits() const
Function GetUnits returns the units for this section.
Definition: specctra.cpp:3506
UNIT_RES * unit
Definition: specctra.h:2235
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 2317 of file specctra.h.

References AppendIMAGE(), and FindIMAGE().

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

2318  {
2319  int ndx = FindIMAGE( aImage );
2320  if( ndx == -1 )
2321  {
2322  AppendIMAGE( aImage );
2323  return aImage;
2324  }
2325  return &images[ndx];
2326  }
int FindIMAGE(IMAGE *aImage)
Function FindIMAGE searches this LIBRARY for an image which matches the argument. ...
Definition: specctra.h:2277
IMAGES images
Definition: specctra.h:2236
void AppendIMAGE(IMAGE *aImage)
Function AppendIMAGE adds the image to the image list.
Definition: specctra.h:2303
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 2372 of file specctra.h.

References AppendVia(), and FindVia().

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

2373  {
2374  int ndx = FindVia( aVia );
2375  if( ndx == -1 )
2376  {
2377  AppendVia( aVia );
2378  return aVia;
2379  }
2380  return &vias[ndx];
2381  }
int FindVia(PADSTACK *aVia)
Function FindVia searches this LIBRARY for a via which matches the argument.
Definition: specctra.h:2333
PADSTACKS vias
Definition: specctra.h:2239
void AppendVia(PADSTACK *aVia)
Function AppendVia adds aVia to the internal via container.
Definition: specctra.h:2347
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 DSN::PADSTACK::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
void DSN::ELEM::SetParent ( ELEM aParent)
inlineinherited

Friends And Related Function Documentation

friend class SPECCTRA_DB
friend

Definition at line 2233 of file specctra.h.

Member Data Documentation

IMAGES DSN::LIBRARY::images
private

Definition at line 2236 of file specctra.h.

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

PADSTACKS DSN::LIBRARY::padstacks
private

all except vias, which are in 'vias'

Definition at line 2238 of file specctra.h.

ELEM* DSN::ELEM::parent
protectedinherited

Definition at line 200 of file specctra.h.

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

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

Definition at line 2235 of file specctra.h.

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

PADSTACKS DSN::LIBRARY::vias
private

Definition at line 2239 of file specctra.h.

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


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