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
 Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format. 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...
 
int FindElem (DSN_T aType, int instanceNum=0)
 Find a particular instance number of a given type of ELEM. More...
 
int Length () const
 Return the number of ELEMs in this holder. 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)
 Compare two objects of this type and returns <0, 0, or >0. More...
 

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

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

Constructor & Destructor Documentation

◆ IMAGE()

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

Definition at line 2009 of file specctra.h.

2009  :
2010  ELEM_HOLDER( T_image, aParent )
2011  {
2012  side = T_both;
2013  unit = 0;
2014  rules = 0;
2015  place_rules = 0;
2016  duplicated = 0;
2017  }
DSN_T side
Definition: specctra.h:2102
int duplicated
no. times this image_id is duplicated
Definition: specctra.h:2117
RULE * place_rules
Definition: specctra.h:2113
UNIT_RES * unit
Definition: specctra.h:2103
RULE * rules
Definition: specctra.h:2112
ELEM_HOLDER(DSN_T aType, ELEM *aParent=0)
Definition: specctra.h:292

References duplicated, place_rules, rules, side, and unit.

◆ ~IMAGE()

DSN::IMAGE::~IMAGE ( )
inline

Definition at line 2019 of file specctra.h.

2020  {
2021  delete unit;
2022  delete rules;
2023  delete place_rules;
2024  }
RULE * place_rules
Definition: specctra.h:2113
UNIT_RES * unit
Definition: specctra.h:2103
RULE * rules
Definition: specctra.h:2112

References place_rules, rules, and unit.

Member Function Documentation

◆ Append()

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

◆ At()

ELEM* DSN::ELEM_HOLDER::At ( int  aIndex) const
inlineinherited

Definition at line 341 of file specctra.h.

342  {
343  // we have varying sized objects and are using polymorphism, so we
344  // must return a pointer not a reference.
345  return (ELEM*) &kids[aIndex];
346  }
ELEM(DSN_T aType, ELEM *aParent=0)
Definition: specctra.cpp:3749
ELEM_ARRAY kids
ELEM pointers.
Definition: specctra.h:360

References DSN::ELEM_HOLDER::kids.

Referenced by DSN::CONTROL::Format(), DSN::ELEM_HOLDER::FormatContents(), DSN::STRUCTURE::FormatContents(), and DSN::ELEM_HOLDER::operator[]().

◆ Compare()

int IMAGE::Compare ( IMAGE lhs,
IMAGE rhs 
)
static

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

Definition at line 3838 of file specctra.cpp.

3839 {
3840  if( !lhs->hash.size() )
3841  lhs->hash = lhs->makeHash();
3842 
3843  if( !rhs->hash.size() )
3844  rhs->hash = rhs->makeHash();
3845 
3846  int result = lhs->hash.compare( rhs->hash );
3847 
3848  return result;
3849 }

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

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

◆ Delete()

void DSN::ELEM_HOLDER::Delete ( int  aIndex)
inlineinherited

Definition at line 353 of file specctra.h.

353 { kids.erase( kids.begin() + aIndex ); }
ELEM_ARRAY kids
ELEM pointers.
Definition: specctra.h:360

References DSN::ELEM_HOLDER::kids.

◆ FindElem()

int DSN::ELEM_HOLDER::FindElem ( DSN_T  aType,
int  instanceNum = 0 
)
inherited

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

3792 {
3793  int repeats=0;
3794 
3795  for( unsigned i = 0; i < kids.size(); ++i )
3796  {
3797  if( kids[i].Type() == aType )
3798  {
3799  if( repeats == instanceNum )
3800  return i;
3801 
3802  ++repeats;
3803  }
3804  }
3805 
3806  return -1;
3807 }
ELEM_ARRAY kids
ELEM pointers.
Definition: specctra.h:360
DSN_T Type() const
Definition: specctra.h:210

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

◆ Format()

void DSN::IMAGE::Format ( OUTPUTFORMATTER out,
int  nestLevel 
)
inlineoverridevirtual

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 from DSN::ELEM.

Definition at line 2047 of file specctra.h.

2048  {
2049  std::string imageId = GetImageId();
2050 
2051  const char* quote = out->GetQuoteChar( imageId.c_str() );
2052 
2053  out->Print( nestLevel, "(%s %s%s%s", Name(), quote, imageId.c_str(), quote );
2054 
2055  FormatContents( out, nestLevel+1 );
2056 
2057  out->Print( nestLevel, ")\n" );
2058  }
void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.h:2061
const char * Name() const
Definition: specctra.cpp:3760
static const char * GetQuoteChar(const char *wrapee, const char *quote_char)
Perform quote character need determination according to the Specctra DSN specification.
Definition: richio.cpp:348
std::string GetImageId()
Definition: specctra.h:2031
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426

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

◆ FormatContents()

void DSN::IMAGE::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_HOLDER.

Definition at line 2061 of file specctra.h.

2062  {
2063  if( side != T_both )
2064  out->Print( 0, " (side %s)", GetTokenText( side ) );
2065 
2066  out->Print( 0, "\n");
2067 
2068  if( unit )
2069  unit->Format( out, nestLevel );
2070 
2071  // format the kids, which in this class are the shapes
2072  ELEM_HOLDER::FormatContents( out, nestLevel );
2073 
2074  for( PINS::iterator i=pins.begin(); i!=pins.end(); ++i )
2075  i->Format( out, nestLevel );
2076 
2077  if( rules )
2078  rules->Format( out, nestLevel );
2079 
2080  if( place_rules )
2081  place_rules->Format( out, nestLevel );
2082 
2083  for( KEEPOUTS::iterator i=keepouts.begin(); i!=keepouts.end(); ++i )
2084  i->Format( out, nestLevel );
2085  }
DSN_T side
Definition: specctra.h:2102
KEEPOUTS keepouts
Definition: specctra.h:2115
PINS pins
Definition: specctra.h:2110
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:500
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
RULE * place_rules
Definition: specctra.h:2113
UNIT_RES * unit
Definition: specctra.h:2103
virtual void FormatContents(OUTPUTFORMATTER *out, int nestLevel) override
Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.cpp:3784
RULE * rules
Definition: specctra.h:2112
const char * GetTokenText(T aTok)
The DSN namespace and returns the C string representing a SPECCTRA_DB::keyword.
Definition: specctra.cpp:70
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426

References DSN::UNIT_RES::Format(), DSN::RULE::Format(), DSN::ELEM_HOLDER::FormatContents(), DSN::GetTokenText(), keepouts, pins, place_rules, OUTPUTFORMATTER::Print(), rules, side, and unit.

Referenced by Format().

◆ GetImageId()

std::string DSN::IMAGE::GetImageId ( )
inline

Definition at line 2031 of file specctra.h.

2032  {
2033  if( duplicated )
2034  {
2035  char buf[32];
2036 
2037  std::string ret = image_id;
2038  ret += "::";
2039  sprintf( buf, "%d", duplicated );
2040  ret += buf;
2041  return ret;
2042  }
2043 
2044  return image_id;
2045  }
int duplicated
no. times this image_id is duplicated
Definition: specctra.h:2117
std::string image_id
Definition: specctra.h:2101

References duplicated, and image_id.

Referenced by Format().

◆ GetUnits()

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

2088  {
2089  if( unit )
2090  return unit;
2091 
2092  return ELEM::GetUnits();
2093  }
UNIT_RES * unit
Definition: specctra.h:2103
virtual UNIT_RES * GetUnits() const
Return the units for this section.
Definition: specctra.cpp:3765

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

◆ Insert()

void DSN::ELEM_HOLDER::Insert ( int  aIndex,
ELEM aElem 
)
inlineinherited

Definition at line 339 of file specctra.h.

339 { kids.insert( kids.begin() + aIndex, aElem ); }
ELEM_ARRAY kids
ELEM pointers.
Definition: specctra.h:360

References DSN::ELEM_HOLDER::kids.

◆ Length()

int DSN::ELEM_HOLDER::Length ( ) const
inlineinherited

Return the number of ELEMs in this holder.

Returns
the count of children elements.

Definition at line 317 of file specctra.h.

318  {
319  return kids.size();
320  }
ELEM_ARRAY kids
ELEM pointers.
Definition: specctra.h:360

References DSN::ELEM_HOLDER::kids.

Referenced by DSN::CONTROL::Format(), DSN::ELEM_HOLDER::FormatContents(), DSN::STRUCTURE::FormatContents(), and DSN::SPECCTRA_DB::makeVIA().

◆ 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 Compare(), and DSN::PADSTACK::Compare().

◆ Name()

◆ operator[]()

ELEM* DSN::ELEM_HOLDER::operator[] ( int  aIndex) const
inlineinherited

Definition at line 348 of file specctra.h.

349  {
350  return At( aIndex );
351  }
ELEM * At(int aIndex) const
Definition: specctra.h:341

References DSN::ELEM_HOLDER::At().

◆ Remove()

ELEM* DSN::ELEM_HOLDER::Remove ( int  aIndex)
inlineinherited

Definition at line 333 of file specctra.h.

334  {
335  ELEM_ARRAY::auto_type ret = kids.release( kids.begin() + aIndex );
336  return ret.release();
337  }
ELEM_ARRAY kids
ELEM pointers.
Definition: specctra.h:360

References DSN::ELEM_HOLDER::kids.

◆ Replace()

ELEM* DSN::ELEM_HOLDER::Replace ( int  aIndex,
ELEM aElem 
)
inlineinherited

Definition at line 327 of file specctra.h.

328  {
329  ELEM_ARRAY::auto_type ret = kids.replace( aIndex, aElem );
330  return ret.release();
331  }
ELEM_ARRAY kids
ELEM pointers.
Definition: specctra.h:360

References DSN::ELEM_HOLDER::kids.

◆ SetParent()

◆ Type()

Friends And Related Function Documentation

◆ LIBRARY

friend class LIBRARY
friend

Definition at line 2097 of file specctra.h.

◆ SPECCTRA_DB

friend class SPECCTRA_DB
friend

Definition at line 2096 of file specctra.h.

Member Data Documentation

◆ duplicated

int DSN::IMAGE::duplicated
private

no. times this image_id is duplicated

Definition at line 2117 of file specctra.h.

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

◆ hash

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

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

Definition at line 2099 of file specctra.h.

Referenced by Compare().

◆ image_id

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

Definition at line 2101 of file specctra.h.

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

◆ keepouts

KEEPOUTS DSN::IMAGE::keepouts
private

Definition at line 2115 of file specctra.h.

Referenced by DSN::SPECCTRA_DB::doIMAGE(), 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().

◆ pins

PINS DSN::IMAGE::pins
private

Definition at line 2110 of file specctra.h.

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

◆ place_rules

RULE* DSN::IMAGE::place_rules
private

Definition at line 2113 of file specctra.h.

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

◆ rules

RULE* DSN::IMAGE::rules
private

Definition at line 2112 of file specctra.h.

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

◆ sf

STRING_FORMATTER DSN::ELEM::sf
staticprotectedinherited

Definition at line 273 of file specctra.h.

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

◆ side

DSN_T DSN::IMAGE::side
private

Definition at line 2102 of file specctra.h.

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

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

Definition at line 2103 of file specctra.h.

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


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