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 throw ( IO_ERROR )
 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 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...
 
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 1973 of file specctra.h.

Constructor & Destructor Documentation

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

Definition at line 2000 of file specctra.h.

References DSN::T_both.

2000  :
2001  ELEM_HOLDER( T_image, aParent )
2002  {
2003  side = T_both;
2004  unit = 0;
2005  rules = 0;
2006  place_rules = 0;
2007  duplicated = 0;
2008  }
DSN_T side
Definition: specctra.h:1981
int duplicated
no. times this image_id is duplicated
Definition: specctra.h:1996
RULE * place_rules
Definition: specctra.h:1992
UNIT_RES * unit
Definition: specctra.h:1982
RULE * rules
Definition: specctra.h:1991
ELEM_HOLDER(DSN_T aType, ELEM *aParent=0)
Definition: specctra.h:291
DSN::IMAGE::~IMAGE ( )
inline

Definition at line 2009 of file specctra.h.

References place_rules, rules, and unit.

2010  {
2011  delete unit;
2012  delete rules;
2013  delete place_rules;
2014  }
RULE * place_rules
Definition: specctra.h:1992
UNIT_RES * unit
Definition: specctra.h:1982
RULE * rules
Definition: specctra.h:1991

Member Function Documentation

void DSN::ELEM_HOLDER::Append ( ELEM aElem)
inlineinherited

Definition at line 321 of file specctra.h.

Referenced by DSN::SPECCTRA_DB::makeIMAGE(), DSN::SPECCTRA_DB::makePADSTACK(), and DSN::SPECCTRA_DB::makeVia().

322  {
323  kids.push_back( aElem );
324  }
ELEM_ARRAY kids
ELEM pointers.
Definition: specctra.h:287
ELEM* DSN::ELEM_HOLDER::At ( int  aIndex) const
inlineinherited

Definition at line 343 of file specctra.h.

Referenced by DSN::CONTROL::Format(), 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:3486
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 3581 of file specctra.cpp.

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

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

3582 {
3583  if( !lhs->hash.size() )
3584  lhs->hash = lhs->makeHash();
3585 
3586  if( !rhs->hash.size() )
3587  rhs->hash = rhs->makeHash();
3588 
3589  int result = lhs->hash.compare( rhs->hash );
3590 
3591  // printf("\"%s\" \"%s\" ret=%d\n", lhs->hash.c_str(), rhs->hash.c_str(), result );
3592 
3593  return result;
3594 }
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 3530 of file specctra.cpp.

References DSN::ELEM_HOLDER::kids, and DSN::ELEM::Type().

3531 {
3532  int repeats=0;
3533  for( unsigned i=0; i<kids.size(); ++i )
3534  {
3535  if( kids[i].Type() == aType )
3536  {
3537  if( repeats == instanceNum )
3538  return i;
3539  ++repeats;
3540  }
3541  }
3542  return -1;
3543 }
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 
)
throw (IO_ERROR
)
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 2038 of file specctra.h.

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

2039  {
2040  std::string imageId = GetImageId();
2041 
2042  const char* quote = out->GetQuoteChar( imageId.c_str() );
2043 
2044  out->Print( nestLevel, "(%s %s%s%s", Name(),
2045  quote, imageId.c_str(), quote );
2046 
2047  FormatContents( out, nestLevel+1 );
2048 
2049  out->Print( nestLevel, ")\n" );
2050  }
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:2053
const char * Name() const
Definition: specctra.cpp:3497
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:331
std::string GetImageId()
Definition: specctra.h:2022
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::IMAGE::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_HOLDER.

Definition at line 2053 of file specctra.h.

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

Referenced by Format().

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

Definition at line 2022 of file specctra.h.

References image_id.

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

2023  {
2024  if( duplicated )
2025  {
2026  char buf[32];
2027 
2028  std::string ret = image_id;
2029  ret += "::";
2030  sprintf( buf, "%d", duplicated );
2031  ret += buf;
2032  return ret;
2033  }
2034 
2035  return image_id;
2036  }
int duplicated
no. times this image_id is duplicated
Definition: specctra.h:1996
std::string image_id
Definition: specctra.h:1980
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 2080 of file specctra.h.

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

2081  {
2082  if( unit )
2083  return unit;
2084 
2085  return ELEM::GetUnits();
2086  }
virtual UNIT_RES * GetUnits() const
Function GetUnits returns the units for this section.
Definition: specctra.cpp:3502
UNIT_RES * unit
Definition: specctra.h:1982
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(), and DSN::STRUCTURE::FormatContents().

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: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
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 1976 of file specctra.h.

friend class SPECCTRA_DB
friend

Definition at line 1975 of file specctra.h.

Member Data Documentation

int DSN::IMAGE::duplicated
private

no. times this image_id is duplicated

Definition at line 1996 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 1978 of file specctra.h.

Referenced by Compare().

std::string DSN::IMAGE::image_id
private

Definition at line 1980 of file specctra.h.

Referenced by DSN::LIBRARY::FindIMAGE(), GetImageId(), and DSN::SPECCTRA_DB::makeIMAGE().

KEEPOUTS DSN::IMAGE::keepouts
private

Definition at line 1994 of file specctra.h.

Referenced by 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

Definition at line 1989 of file specctra.h.

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

RULE* DSN::IMAGE::place_rules
private

Definition at line 1992 of file specctra.h.

Referenced by ~IMAGE().

RULE* DSN::IMAGE::rules
private

Definition at line 1991 of file specctra.h.

Referenced by ~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 1981 of file specctra.h.

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

Definition at line 1982 of file specctra.h.

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


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