KiCad PCB EDA Suite
DSN::ELEM_HOLDER Class Reference

A holder for any DSN class. More...

#include <specctra.h>

Inheritance diagram for DSN::ELEM_HOLDER:
DSN::ELEM DSN::CLASS_CLASS DSN::CONTROL DSN::IMAGE DSN::PADSTACK DSN::REGION DSN::STRUCTURE

Public Member Functions

 ELEM_HOLDER (DSN_T aType, ELEM *aParent=0)
 
virtual void FormatContents (OUTPUTFORMATTER *out, int nestLevel) override
 Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format. 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
 
virtual UNIT_RESGetUnits () const
 Return the units for this section. More...
 
virtual void Format (OUTPUTFORMATTER *out, int nestLevel)
 Write 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 ()
 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 Types

typedef boost::ptr_vector< ELEMELEM_ARRAY
 

Private Attributes

ELEM_ARRAY kids
 ELEM pointers. More...
 

Friends

class SPECCTRA_DB
 

Detailed Description

A holder for any DSN class.

It can contain other class instances, including classes derived from this class.

Definition at line 288 of file specctra.h.

Member Typedef Documentation

◆ ELEM_ARRAY

typedef boost::ptr_vector<ELEM> DSN::ELEM_HOLDER::ELEM_ARRAY
private

Definition at line 358 of file specctra.h.

Constructor & Destructor Documentation

◆ ELEM_HOLDER()

DSN::ELEM_HOLDER::ELEM_HOLDER ( DSN_T  aType,
ELEM aParent = 0 
)
inline

Definition at line 292 of file specctra.h.

292  :
293  ELEM( aType, aParent )
294  {
295  }
ELEM(DSN_T aType, ELEM *aParent=0)
Definition: specctra.cpp:3749

Member Function Documentation

◆ Append()

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

◆ At()

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

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 kids.

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

◆ Delete()

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

Definition at line 353 of file specctra.h.

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

References kids.

◆ FindElem()

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

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 kids, and DSN::ELEM::Type().

◆ Format()

void DSN::ELEM::Format ( OUTPUTFORMATTER out,
int  nestLevel 
)
virtualinherited

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

3775 {
3776  out->Print( nestLevel, "(%s\n", Name() );
3777 
3778  FormatContents( out, nestLevel+1 );
3779 
3780  out->Print( nestLevel, ")\n" );
3781 }
const char * Name() const
Definition: specctra.cpp:3760
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
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426

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(), FormatContents(), DSN::CLASS_CLASS::FormatContents(), DSN::STRUCTURE::FormatContents(), and DSN::ROUTE::FormatContents().

◆ FormatContents()

void DSN::ELEM_HOLDER::FormatContents ( OUTPUTFORMATTER out,
int  nestLevel 
)
overridevirtual

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.

Reimplemented in DSN::PADSTACK, DSN::IMAGE, DSN::STRUCTURE, DSN::REGION, and DSN::CLASS_CLASS.

Definition at line 3784 of file specctra.cpp.

3785 {
3786  for( int i = 0; i < Length(); ++i )
3787  At(i)->Format( out, nestLevel );
3788 }
virtual void Format(OUTPUTFORMATTER *out, int nestLevel)
Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
Definition: specctra.cpp:3774
ELEM * At(int aIndex) const
Definition: specctra.h:341
int Length() const
Return the number of ELEMs in this holder.
Definition: specctra.h:317

References At(), DSN::ELEM::Format(), and Length().

Referenced by DSN::CLASS_CLASS::FormatContents(), DSN::REGION::FormatContents(), DSN::IMAGE::FormatContents(), and DSN::PADSTACK::FormatContents().

◆ GetUnits()

UNIT_RES * DSN::ELEM::GetUnits ( ) const
virtualinherited

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 in DSN::ROUTE, DSN::PCB, DSN::WIRING, DSN::LIBRARY, DSN::PADSTACK, DSN::IMAGE, DSN::PLACEMENT, and DSN::STRUCTURE.

Definition at line 3765 of file specctra.cpp.

3766 {
3767  if( parent )
3768  return parent->GetUnits();
3769 
3770  return &UNIT_RES::Default;
3771 }
ELEM * parent
Definition: specctra.h:276
static UNIT_RES Default
A static instance which holds the default units of T_inch and 2540000.
Definition: specctra.h:410
virtual UNIT_RES * GetUnits() const
Return the units for this section.
Definition: specctra.cpp:3765

References DSN::UNIT_RES::Default, DSN::ELEM::GetUnits(), and DSN::ELEM::parent.

Referenced by DSN::SPECCTRA_DB::FromSESSION(), DSN::ELEM::GetUnits(), DSN::STRUCTURE::GetUnits(), DSN::PLACEMENT::GetUnits(), DSN::IMAGE::GetUnits(), DSN::PADSTACK::GetUnits(), DSN::LIBRARY::GetUnits(), DSN::WIRING::GetUnits(), DSN::PCB::GetUnits(), and DSN::ROUTE::GetUnits().

◆ Insert()

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

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 kids.

◆ Length()

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

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 kids.

Referenced by DSN::CONTROL::Format(), 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 DSN::IMAGE::Compare(), and DSN::PADSTACK::Compare().

◆ Name()

◆ operator[]()

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

Definition at line 348 of file specctra.h.

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

References At().

◆ Remove()

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

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 kids.

◆ Replace()

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

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 kids.

◆ SetParent()

◆ Type()

DSN_T DSN::ELEM::Type ( ) const
inlineinherited

Friends And Related Function Documentation

◆ SPECCTRA_DB

friend class SPECCTRA_DB
friend

Definition at line 356 of file specctra.h.

Member Data Documentation

◆ kids

ELEM_ARRAY DSN::ELEM_HOLDER::kids
private

ELEM pointers.

Definition at line 360 of file specctra.h.

Referenced by Append(), At(), Delete(), FindElem(), Insert(), Length(), Remove(), and Replace().

◆ parent

ELEM* DSN::ELEM::parent
protectedinherited

Definition at line 276 of file specctra.h.

Referenced by DSN::ELEM::GetUnits(), and DSN::ELEM::SetParent().

◆ sf

STRING_FORMATTER DSN::ELEM::sf
staticprotectedinherited

Definition at line 273 of file specctra.h.

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

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


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