KiCad PCB EDA Suite
DSN::IMAGE Class Reference

#include <specctra.h>

Inheritance diagram for DSN::IMAGE:
DSN::ELEM_HOLDER DSN::ELEM

Public Member Functions

 IMAGE (ELEM *aParent)
 
 ~IMAGE ()
 
std::string GetImageId ()
 
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 (IMAGE *lhs, IMAGE *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 image_id
 
DSN_T side
 
UNIT_RESunit
 
PINS pins
 
RULErules
 
RULEplace_rules
 
KEEPOUTS keepouts
 
int duplicated
 no. times this image_id is duplicated More...
 

Friends

class SPECCTRA_DB
 
class LIBRARY
 

Detailed Description

Definition at line 1976 of file specctra.h.

Constructor & Destructor Documentation

DSN::IMAGE::IMAGE ( ELEM aParent)
inline

Definition at line 2003 of file specctra.h.

References DSN::T_both.

2003  :
2004  ELEM_HOLDER( T_image, aParent )
2005  {
2006  side = T_both;
2007  unit = 0;
2008  rules = 0;
2009  place_rules = 0;
2010  duplicated = 0;
2011  }
DSN_T side
Definition: specctra.h:1984
int duplicated
no. times this image_id is duplicated
Definition: specctra.h:1999
RULE * place_rules
Definition: specctra.h:1995
UNIT_RES * unit
Definition: specctra.h:1985
RULE * rules
Definition: specctra.h:1994
ELEM_HOLDER(DSN_T aType, ELEM *aParent=0)
Definition: specctra.h:291
DSN::IMAGE::~IMAGE ( )
inline

Definition at line 2012 of file specctra.h.

References place_rules, rules, and unit.

2013  {
2014  delete unit;
2015  delete rules;
2016  delete place_rules;
2017  }
RULE * place_rules
Definition: specctra.h:1995
UNIT_RES * unit
Definition: specctra.h:1985
RULE * rules
Definition: specctra.h:1994

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::IMAGE::Compare ( IMAGE lhs,
IMAGE rhs 
)
static

Function Compare compares two objects of this type and returns <0, 0, or >0.

Definition at line 3585 of file specctra.cpp.

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

Referenced by DSN::LIBRARY::FindIMAGE().

3586 {
3587  if( !lhs->hash.size() )
3588  lhs->hash = lhs->makeHash();
3589 
3590  if( !rhs->hash.size() )
3591  rhs->hash = rhs->makeHash();
3592 
3593  int result = lhs->hash.compare( rhs->hash );
3594 
3595  // printf("\"%s\" \"%s\" ret=%d\n", lhs->hash.c_str(), rhs->hash.c_str(), result );
3596 
3597  return result;
3598 }
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::IMAGE::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 2041 of file specctra.h.

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

2042  {
2043  std::string imageId = GetImageId();
2044 
2045  const char* quote = out->GetQuoteChar( imageId.c_str() );
2046 
2047  out->Print( nestLevel, "(%s %s%s%s", Name(),
2048  quote, imageId.c_str(), quote );
2049 
2050  FormatContents( out, nestLevel+1 );
2051 
2052  out->Print( nestLevel, ")\n" );
2053  }
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:2056
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
std::string GetImageId()
Definition: specctra.h:2025
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::IMAGE::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 2056 of file specctra.h.

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

Referenced by Format().

2057  {
2058  if( side != T_both )
2059  out->Print( 0, " (side %s)", GetTokenText( side ) );
2060 
2061  out->Print( 0, "\n");
2062 
2063  if( unit )
2064  unit->Format( out, nestLevel );
2065 
2066  // format the kids, which in this class are the shapes
2067  ELEM_HOLDER::FormatContents( out, nestLevel );
2068 
2069  for( PINS::iterator i=pins.begin(); i!=pins.end(); ++i )
2070  i->Format( out, nestLevel );
2071 
2072  if( rules )
2073  rules->Format( out, nestLevel );
2074 
2075  if( place_rules )
2076  place_rules->Format( out, nestLevel );
2077 
2078  for( KEEPOUTS::iterator i=keepouts.begin(); i!=keepouts.end(); ++i )
2079  i->Format( out, nestLevel );
2080  }
DSN_T side
Definition: specctra.h:1984
KEEPOUTS keepouts
Definition: specctra.h:1997
PINS pins
Definition: specctra.h:1992
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
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
RULE * place_rules
Definition: specctra.h:1995
UNIT_RES * unit
Definition: specctra.h:1985
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
RULE * rules
Definition: specctra.h:1994
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
std::string DSN::IMAGE::GetImageId ( )
inline

Definition at line 2025 of file specctra.h.

References image_id.

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

2026  {
2027  if( duplicated )
2028  {
2029  char buf[32];
2030 
2031  std::string ret = image_id;
2032  ret += "::";
2033  sprintf( buf, "%d", duplicated );
2034  ret += buf;
2035  return ret;
2036  }
2037 
2038  return image_id;
2039  }
int duplicated
no. times this image_id is duplicated
Definition: specctra.h:1999
std::string image_id
Definition: specctra.h:1983
UNIT_RES* DSN::IMAGE::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 2083 of file specctra.h.

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

2084  {
2085  if( unit )
2086  return unit;
2087 
2088  return ELEM::GetUnits();
2089  }
virtual UNIT_RES * GetUnits() const
Function GetUnits returns the units for this section.
Definition: specctra.cpp:3506
UNIT_RES * unit
Definition: specctra.h:1985
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 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
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

Friends And Related Function Documentation

friend class LIBRARY
friend

Definition at line 1979 of file specctra.h.

friend class SPECCTRA_DB
friend

Definition at line 1978 of file specctra.h.

Member Data Documentation

int DSN::IMAGE::duplicated
private

no. times this image_id is duplicated

Definition at line 1999 of file specctra.h.

Referenced by DSN::LIBRARY::FindIMAGE().

std::string DSN::IMAGE::hash
private

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

Definition at line 1981 of file specctra.h.

Referenced by Compare().

std::string DSN::IMAGE::image_id
private
KEEPOUTS DSN::IMAGE::keepouts
private

Definition at line 1997 of file specctra.h.

Referenced by DSN::SPECCTRA_DB::doIMAGE(), and DSN::SPECCTRA_DB::makeIMAGE().

ELEM* DSN::ELEM::parent
protectedinherited

Definition at line 200 of file specctra.h.

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

PINS DSN::IMAGE::pins
private
RULE* DSN::IMAGE::place_rules
private

Definition at line 1995 of file specctra.h.

Referenced by DSN::SPECCTRA_DB::doIMAGE(), and ~IMAGE().

RULE* DSN::IMAGE::rules
private

Definition at line 1994 of file specctra.h.

Referenced by DSN::SPECCTRA_DB::doIMAGE(), and ~IMAGE().

STRING_FORMATTER DSN::ELEM::sf
staticprotectedinherited

Definition at line 222 of file specctra.h.

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

DSN_T DSN::IMAGE::side
private

Definition at line 1984 of file specctra.h.

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

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

Definition at line 1985 of file specctra.h.

Referenced by DSN::SPECCTRA_DB::doIMAGE(), GetUnits(), and ~IMAGE().


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