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 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...
 
DSN_T Type () const
 
const char * Name () const
 
virtual void Format (OUTPUTFORMATTER *out, int nestLevel) throw ( IO_ERROR )
 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 2228 of file specctra.h.

Constructor & Destructor Documentation

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

Definition at line 2240 of file specctra.h.

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

Definition at line 2246 of file specctra.h.

References unit.

2247  {
2248  delete unit;
2249  }
UNIT_RES * unit
Definition: specctra.h:2232

Member Function Documentation

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

Definition at line 2251 of file specctra.h.

References DSN::ELEM::SetParent().

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

Function AppendIMAGE adds the image to the image list.

Definition at line 2300 of file specctra.h.

References DSN::ELEM::SetParent().

Referenced by LookupIMAGE().

2301  {
2302  aImage->SetParent( this );
2303  images.push_back( aImage );
2304  }
IMAGES images
Definition: specctra.h:2233
void DSN::LIBRARY::AppendPADSTACK ( PADSTACK aPadstack)
inline

Function AppendPADSTACK adds the padstack to the padstack container.

Definition at line 2355 of file specctra.h.

References DSN::ELEM::SetParent().

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

Function AppendVia adds aVia to the internal via container.

Definition at line 2344 of file specctra.h.

References DSN::ELEM::SetParent().

Referenced by LookupVia().

2345  {
2346  aVia->SetParent( this );
2347  vias.push_back( aVia );
2348  }
PADSTACKS vias
Definition: specctra.h:2236
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 2274 of file specctra.h.

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

Referenced by LookupIMAGE().

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

References DSN::PADSTACK::GetPadstackId().

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

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

References DSN::PADSTACK::Compare().

Referenced by LookupVia().

2331  {
2332  for( unsigned i=0; i<vias.size(); ++i )
2333  {
2334  if( 0 == PADSTACK::Compare( aVia, &vias[i] ) )
2335  return int( i );
2336  }
2337  return -1;
2338  }
static int Compare(PADSTACK *lhs, PADSTACK *rhs)
Function Compare compares two objects of this type and returns <0, 0, or >0.
Definition: specctra.cpp:3557
PADSTACKS vias
Definition: specctra.h:2236
void DSN::ELEM::Format ( OUTPUTFORMATTER out,
int  nestLevel 
)
throw (IO_ERROR
)
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 3511 of file specctra.cpp.

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

3512 {
3513  out->Print( nestLevel, "(%s\n", Name() );
3514 
3515  FormatContents( out, nestLevel+1 );
3516 
3517  out->Print( nestLevel, ")\n" );
3518 }
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:3497
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::LIBRARY::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.

Definition at line 2396 of file specctra.h.

References DSN::UNIT_RES::Format().

2397  {
2398  if( unit )
2399  unit->Format( out, nestLevel );
2400 
2401  for( IMAGES::iterator i=images.begin(); i!=images.end(); ++i )
2402  i->Format( out, nestLevel );
2403 
2404  for( PADSTACKS::iterator i=padstacks.begin(); i!=padstacks.end(); ++i )
2405  i->Format( out, nestLevel );
2406 
2407  for( PADSTACKS::iterator i=vias.begin(); i!=vias.end(); ++i )
2408  i->Format( out, nestLevel );
2409  }
PADSTACKS vias
Definition: specctra.h:2236
UNIT_RES * unit
Definition: specctra.h:2232
IMAGES images
Definition: specctra.h:2233
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:2235
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 2411 of file specctra.h.

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

2412  {
2413  if( unit )
2414  return unit;
2415 
2416  return ELEM::GetUnits();
2417  }
virtual UNIT_RES * GetUnits() const
Function GetUnits returns the units for this section.
Definition: specctra.cpp:3502
UNIT_RES * unit
Definition: specctra.h:2232
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 2314 of file specctra.h.

References AppendIMAGE(), and FindIMAGE().

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

References AppendVia(), and FindVia().

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

Friends And Related Function Documentation

friend class SPECCTRA_DB
friend

Definition at line 2230 of file specctra.h.

Member Data Documentation

IMAGES DSN::LIBRARY::images
private

Definition at line 2233 of file specctra.h.

PADSTACKS DSN::LIBRARY::padstacks
private

all except vias, which are in 'vias'

Definition at line 2235 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::ELEM::Name(), and DSN::ELEM::Type().

UNIT_RES* DSN::LIBRARY::unit
private

Definition at line 2232 of file specctra.h.

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

PADSTACKS DSN::LIBRARY::vias
private

Definition at line 2236 of file specctra.h.


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