KiCad PCB EDA Suite
DSN::NET Class Reference

Class NET corresponds to a <net_descriptor> in the DSN spec. More...

#include <specctra.h>

Inheritance diagram for DSN::NET:
DSN::ELEM

Public Member Functions

 NET (ELEM *aParent)
 
 ~NET ()
 
int FindPIN_REF (const std::string &aComponent)
 
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...
 
DSN_T Type () const
 
const char * Name () const
 
virtual UNIT_RESGetUnits () const
 Function GetUnits returns the units for this section. More...
 
virtual void FormatContents (OUTPUTFORMATTER *out, int nestLevel)
 Function FormatContents writes the contents 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

ELEMparent
 

Static Protected Attributes

static STRING_FORMATTER sf
 

Private Attributes

std::string net_id
 
bool unassigned
 
int net_number
 
DSN_T pins_type
 T_pins | T_order, type of field 'pins' below. More...
 
PIN_REFS pins
 
PIN_REFS expose
 
PIN_REFS noexpose
 
PIN_REFS source
 
PIN_REFS load
 
PIN_REFS terminator
 
DSN_T type
 T_fix | T_normal. More...
 
DSN_T supply
 T_power | T_ground. More...
 
RULErules
 
LAYER_RULES layer_rules
 
FROMTOS fromtos
 
COMP_ORDERcomp_order
 

Friends

class SPECCTRA_DB
 

Detailed Description

Class NET corresponds to a <net_descriptor> in the DSN spec.

Definition at line 2568 of file specctra.h.

Constructor & Destructor Documentation

DSN::NET::NET ( ELEM aParent)
inline

Definition at line 2599 of file specctra.h.

References DSN::T_NONE, and DSN::T_pins.

2599  :
2600  ELEM( T_net, aParent )
2601  {
2602  unassigned = false;
2603  net_number = T_NONE;
2604  pins_type = T_pins;
2605 
2606  type = T_NONE;
2607  supply = T_NONE;
2608 
2609  rules = 0;
2610  comp_order = 0;
2611  }
ELEM(DSN_T aType, ELEM *aParent=0)
Definition: specctra.cpp:3490
RULE * rules
Definition: specctra.h:2589
DSN_T type
T_fix | T_normal.
Definition: specctra.h:2585
COMP_ORDER * comp_order
Definition: specctra.h:2595
bool unassigned
Definition: specctra.h:2573
int net_number
Definition: specctra.h:2574
DSN_T supply
T_power | T_ground.
Definition: specctra.h:2587
DSN_T pins_type
T_pins | T_order, type of field 'pins' below.
Definition: specctra.h:2576
DSN::NET::~NET ( )
inline

Definition at line 2613 of file specctra.h.

References comp_order, and rules.

2614  {
2615  delete rules;
2616  delete comp_order;
2617  }
RULE * rules
Definition: specctra.h:2589
COMP_ORDER * comp_order
Definition: specctra.h:2595

Member Function Documentation

int DSN::NET::FindPIN_REF ( const std::string &  aComponent)
inline

Definition at line 2619 of file specctra.h.

2620  {
2621  for( unsigned i=0; i<pins.size(); ++i )
2622  {
2623  if( 0 == aComponent.compare( pins[i].component_id ) )
2624  return int(i);
2625  }
2626  return -1;
2627  }
PIN_REFS pins
Definition: specctra.h:2577
void DSN::NET::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 2629 of file specctra.h.

References DSN::RULE::Format(), DSN::COMP_ORDER::Format(), OUTPUTFORMATTER::GetQuoteChar(), DSN::GetTokenText(), DSN::ELEM::Name(), OUTPUTFORMATTER::Print(), and DSN::T_NONE.

2630  {
2631  const char* quote = out->GetQuoteChar( net_id.c_str() );
2632  const char* space = " ";
2633 
2634  out->Print( nestLevel, "(%s %s%s%s", Name(),
2635  quote, net_id.c_str(), quote );
2636 
2637  if( unassigned )
2638  {
2639  out->Print( 0, "%s(unassigned)", space );
2640  space = ""; // only needed one space
2641  }
2642 
2643  if( net_number != T_NONE )
2644  {
2645  out->Print( 0, "%s(net_number %d)", space, net_number );
2646  // space = "";
2647  }
2648 
2649  out->Print( 0, "\n" );
2650 
2651  if( pins.size() )
2652  {
2653  const int RIGHTMARGIN = 80;
2654  int perLine = out->Print( nestLevel+1, "(%s", GetTokenText( pins_type ) );
2655 
2656  for( PIN_REFS::iterator i=pins.begin(); i!=pins.end(); ++i )
2657  {
2658  if( perLine > RIGHTMARGIN )
2659  {
2660  out->Print( 0, "\n");
2661  perLine = out->Print( nestLevel+2, "%s", "" );
2662  }
2663  else
2664  perLine += out->Print( 0, " " );
2665 
2666  perLine += i->FormatIt( out, 0 );
2667  }
2668  out->Print( 0, ")\n" );
2669  }
2670 
2671  if( comp_order )
2672  comp_order->Format( out, nestLevel+1 );
2673 
2674  if( type != T_NONE )
2675  out->Print( nestLevel+1, "(type %s)\n", GetTokenText( type ) );
2676 
2677  if( rules )
2678  rules->Format( out, nestLevel+1 );
2679 
2680  for( LAYER_RULES::iterator i=layer_rules.begin(); i!=layer_rules.end(); ++i )
2681  i->Format( out, nestLevel+1 );
2682 
2683  for( FROMTOS::iterator i=fromtos.begin(); i!=fromtos.end(); ++i )
2684  i->Format( out, nestLevel+1 );
2685 
2686  out->Print( nestLevel, ")\n" );
2687  }
std::string net_id
Definition: specctra.h:2572
FROMTOS fromtos
Definition: specctra.h:2593
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
RULE * rules
Definition: specctra.h:2589
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:2546
DSN_T type
T_fix | T_normal.
Definition: specctra.h:2585
COMP_ORDER * comp_order
Definition: specctra.h:2595
bool unassigned
Definition: specctra.h:2573
const char * Name() const
Definition: specctra.cpp:3501
int net_number
Definition: specctra.h:2574
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
LAYER_RULES layer_rules
Definition: specctra.h:2591
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
PIN_REFS pins
Definition: specctra.h:2577
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404
DSN_T pins_type
T_pins | T_order, type of field 'pins' below.
Definition: specctra.h:2576
virtual void DSN::ELEM::FormatContents ( OUTPUTFORMATTER out,
int  nestLevel 
)
inlinevirtualinherited

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 in DSN::WAS_IS, DSN::ROUTE, DSN::HISTORY, DSN::WIRING, DSN::NETWORK, DSN::TOPOLOGY, DSN::LIBRARY, DSN::PADSTACK, DSN::IMAGE, DSN::PLACEMENT, DSN::COMPONENT, DSN::STRUCTURE, DSN::STRUCTURE_OUT, DSN::REGION, DSN::CLASS_CLASS, DSN::CLASSES, DSN::PARSER, and DSN::ELEM_HOLDER.

Definition at line 264 of file specctra.h.

Referenced by DSN::ELEM::Format(), and DSN::ELEM::makeHash().

265  {
266  // overridden in ELEM_HOLDER
267  }
UNIT_RES * DSN::ELEM::GetUnits ( ) const
virtualinherited

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

Definition at line 3506 of file specctra.cpp.

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

3507 {
3508  if( parent )
3509  return parent->GetUnits();
3510 
3511  return &UNIT_RES::Default;
3512 }
virtual UNIT_RES * GetUnits() const
Function GetUnits returns the units for this section.
Definition: specctra.cpp:3506
ELEM * parent
Definition: specctra.h:200
static UNIT_RES Default
A static instance which holds the default units of T_inch and 2540000.
Definition: specctra.h:414
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: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

Friends And Related Function Documentation

friend class SPECCTRA_DB
friend

Definition at line 2570 of file specctra.h.

Member Data Documentation

COMP_ORDER* DSN::NET::comp_order
private

Definition at line 2595 of file specctra.h.

Referenced by DSN::SPECCTRA_DB::doNET(), and ~NET().

PIN_REFS DSN::NET::expose
private

Definition at line 2579 of file specctra.h.

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

FROMTOS DSN::NET::fromtos
private

Definition at line 2593 of file specctra.h.

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

LAYER_RULES DSN::NET::layer_rules
private

Definition at line 2591 of file specctra.h.

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

PIN_REFS DSN::NET::load
private

Definition at line 2582 of file specctra.h.

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

std::string DSN::NET::net_id
private

Definition at line 2572 of file specctra.h.

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

int DSN::NET::net_number
private

Definition at line 2574 of file specctra.h.

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

PIN_REFS DSN::NET::noexpose
private

Definition at line 2580 of file specctra.h.

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

ELEM* DSN::ELEM::parent
protectedinherited

Definition at line 200 of file specctra.h.

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

PIN_REFS DSN::NET::pins
private

Definition at line 2577 of file specctra.h.

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

DSN_T DSN::NET::pins_type
private

T_pins | T_order, type of field 'pins' below.

Definition at line 2576 of file specctra.h.

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

RULE* DSN::NET::rules
private

Definition at line 2589 of file specctra.h.

Referenced by DSN::SPECCTRA_DB::doNET(), and ~NET().

STRING_FORMATTER DSN::ELEM::sf
staticprotectedinherited

Definition at line 222 of file specctra.h.

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

PIN_REFS DSN::NET::source
private

Definition at line 2581 of file specctra.h.

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

DSN_T DSN::NET::supply
private

T_power | T_ground.

Definition at line 2587 of file specctra.h.

PIN_REFS DSN::NET::terminator
private

Definition at line 2583 of file specctra.h.

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

DSN_T DSN::NET::type
private

T_fix | T_normal.

Definition at line 2585 of file specctra.h.

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

bool DSN::NET::unassigned
private

Definition at line 2573 of file specctra.h.

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


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