KiCad PCB EDA Suite
SCH_CONNECTION Class Reference

Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net). More...

#include <sch_connection.h>

Public Member Functions

 SCH_CONNECTION (SCH_ITEM *aParent=nullptr, SCH_SHEET_PATH aPath=SCH_SHEET_PATH())
 
 ~SCH_CONNECTION ()
 
bool operator== (const SCH_CONNECTION &aOther) const
 Note: the equality operator for SCH_CONNECTION only tests the net properties, not the ownership / sheet location! More...
 
bool operator!= (const SCH_CONNECTION &aOther) const
 
void ConfigureFromLabel (wxString aLabel)
 Configures the connection given a label. More...
 
void Reset ()
 Clears connectivity information. More...
 
void Clone (SCH_CONNECTION &aOther)
 Copies connectivity information (but not parent) from another connection. More...
 
SCH_ITEMParent () const
 
SCH_ITEMDriver () const
 
SCH_SHEET_PATH Sheet () const
 
void SetDriver (SCH_ITEM *aItem)
 
void SetSheet (SCH_SHEET_PATH aSheet)
 
bool IsDriver () const
 Checks if the SCH_ITEM this connection is attached to can drive connections Drivers can be labels, sheet pins, or component pins. More...
 
bool IsBus () const
 
bool IsNet () const
 
bool IsDirty () const
 
void SetDirty ()
 
void ClearDirty ()
 
wxString Name (bool aIgnoreSheet=false) const
 
wxString RawName () const
 
void SetName (const wxString &aName)
 
wxString Prefix () const
 
wxString Suffix () const
 
void SetPrefix (const wxString &aPrefix)
 
void SetSuffix (const wxString &aSuffix)
 
CONNECTION_TYPE Type () const
 
void SetType (CONNECTION_TYPE aType)
 
int NetCode () const
 
void SetNetCode (int aCode)
 
int BusCode () const
 
void SetBusCode (int aCode)
 
int SubgraphCode () const
 
void SetSubgraphCode (int aCode)
 
long VectorStart () const
 
long VectorEnd () const
 
long VectorIndex () const
 
wxString VectorPrefix () const
 
std::vector< std::shared_ptr< SCH_CONNECTION > > & Members ()
 
const std::vector< std::shared_ptr< SCH_CONNECTION > > & Members () const
 
bool IsSubsetOf (SCH_CONNECTION *aOther) const
 Returns true if aOther is a subset of this connection or vice versa. More...
 
bool IsMemberOfBus (SCH_CONNECTION *aOther) const
 Returns true if this connection is a member of bus connection aOther. More...
 
void ParseBusVector (wxString vector, wxString *name, long *begin, long *end) const
 Parses a bus vector (e.g. More...
 
bool ParseBusGroup (wxString aGroup, wxString *name, std::vector< wxString > &aMemberList) const
 Parses a bus group label into the name and a list of components. More...
 
void AppendInfoToMsgPanel (MSG_PANEL_ITEMS &aList) const
 Adds information about the connection object to aList. More...
 
void AppendDebugInfoToMsgPanel (MSG_PANEL_ITEMS &aList) const
 Adds extended debug information about the connection object to aList. More...
 

Static Public Member Functions

static bool IsBusLabel (const wxString &aLabel)
 Test if aLabel has a bus notation. More...
 
static bool IsBusVectorLabel (const wxString &aLabel)
 Test if aLabel has a bus vector notation (simple bus, e.g. More...
 
static bool IsBusGroupLabel (const wxString &aLabel)
 Test if aLabel has a bus group notation. More...
 

Private Attributes

bool m_dirty
 
SCH_SHEET_PATH m_sheet
 The hierarchical sheet this connection is on. More...
 
SCH_ITEMm_parent
 The SCH_ITEM this connection is owned by. More...
 
SCH_ITEMm_driver
 The SCH_ITEM that drives this connection's net. More...
 
CONNECTION_TYPE m_type
 
wxString m_name
 Name of the bus. More...
 
wxString m_prefix
 
wxString m_suffix
 Name suffix (used only for disambiguation) More...
 
int m_net_code
 
int m_bus_code
 
int m_subgraph_code
 Groups directly-connected items. More...
 
long m_vector_index
 Index of bus vector member nets. More...
 
long m_vector_start
 Highest member of a vector bus. More...
 
long m_vector_end
 Lowest member of a vector bus. More...
 
wxString m_vector_prefix
 
std::vector< std::shared_ptr< SCH_CONNECTION > > m_members
 For bus connections, store a list of member connections. More...
 

Detailed Description

Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).

These are generated when netlisting, or when editing operations that can change the netlist are performed.

In hierarchical schematics, a single SCH_ITEM object can refer to multiple distinct parts of a design (in the case of a sub-sheet that is instanced more than once in a higher level sheet). Because of this, a single item may contain more than one SCH_CONNECTION – each is specific to a sheet.

Components contain connections for each of their pins (and for each sheet they exist on) but don't use their own connection object.

Definition at line 60 of file sch_connection.h.

Constructor & Destructor Documentation

◆ SCH_CONNECTION()

SCH_CONNECTION::SCH_CONNECTION ( SCH_ITEM aParent = nullptr,
SCH_SHEET_PATH  aPath = SCH_SHEET_PATH() 
)

Definition at line 63 of file sch_connection.cpp.

63  :
64  m_sheet( aPath ),
65  m_parent( aParent )
66 {
67  Reset();
68 }
void Reset()
Clears connectivity information.
SCH_SHEET_PATH m_sheet
The hierarchical sheet this connection is on.
SCH_ITEM * m_parent
The SCH_ITEM this connection is owned by.

References Reset().

◆ ~SCH_CONNECTION()

SCH_CONNECTION::~SCH_CONNECTION ( )
inline

Definition at line 65 of file sch_connection.h.

66  {}

Member Function Documentation

◆ AppendDebugInfoToMsgPanel()

void SCH_CONNECTION::AppendDebugInfoToMsgPanel ( MSG_PANEL_ITEMS aList) const

Adds extended debug information about the connection object to aList.

Definition at line 355 of file sch_connection.cpp.

356 {
357  if( !ADVANCED_CFG::GetCfg().m_realTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime )
358  return;
359 
360  // These messages are not flagged as translatable, because they are only debug messges
361  wxString msg;
362 
363  AppendInfoToMsgPanel( aList );
364 
365  if( IsBus() )
366  {
367  msg.Printf( "%d", m_bus_code );
368  aList.push_back( MSG_PANEL_ITEM( "Bus Code", msg, BROWN ) );
369  }
370 
371  msg.Printf( "%d", m_subgraph_code );
372  aList.push_back( MSG_PANEL_ITEM( "Subgraph Code", msg, BROWN ) );
373 
374  if( auto driver = Driver() )
375  {
376  msg.Printf( "%s at %p", driver->GetSelectMenuText( MILLIMETRES ), driver );
377  aList.push_back( MSG_PANEL_ITEM( "Connection Source", msg, RED ) );
378  }
379 }
int m_subgraph_code
Groups directly-connected items.
SCH_ITEM * Driver() const
Definition: colors.h:60
static bool m_allowRealTime
void AppendInfoToMsgPanel(MSG_PANEL_ITEMS &aList) const
Adds information about the connection object to aList.
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers of advanced config.
Class EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:53
bool IsBus() const
Definition: colors.h:62

References AppendInfoToMsgPanel(), BROWN, Driver(), ADVANCED_CFG::GetCfg(), IsBus(), CONNECTION_GRAPH::m_allowRealTime, m_bus_code, m_subgraph_code, MILLIMETRES, and RED.

Referenced by LIB_PIN::GetMsgPanelInfo().

◆ AppendInfoToMsgPanel()

void SCH_CONNECTION::AppendInfoToMsgPanel ( MSG_PANEL_ITEMS aList) const

Adds information about the connection object to aList.

Definition at line 308 of file sch_connection.cpp.

309 {
310  if( !ADVANCED_CFG::GetCfg().m_realTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime )
311  return;
312 
313  wxString msg, group_name;
314  std::vector<wxString> group_members;
315 
316  aList.push_back( MSG_PANEL_ITEM( _( "Connection Name" ), Name(), BROWN ) );
317 
318  if( !IsBus() )
319  {
320  msg.Printf( "%d", m_net_code );
321  aList.push_back( MSG_PANEL_ITEM( _( "Net Code" ), msg, BROWN ) );
322  }
323 
324  if( auto alias = g_ConnectionGraph->GetBusAlias( m_name ) )
325  {
326  msg.Printf( _( "Bus Alias %s Members" ), m_name );
327 
328  wxString members;
329 
330  for( auto member : alias->Members() )
331  members << member << " ";
332 
333  aList.push_back( MSG_PANEL_ITEM( msg, members, RED ) );
334  }
335  else if( ParseBusGroup( m_name, &group_name, group_members ) )
336  {
337  for( auto group_member : group_members )
338  {
339  if( auto group_alias = g_ConnectionGraph->GetBusAlias( group_member ) )
340  {
341  msg.Printf( _( "Bus Alias %s Members" ), group_alias->GetName() );
342 
343  wxString members;
344 
345  for( auto member : group_alias->Members() )
346  members << member << " ";
347 
348  aList.push_back( MSG_PANEL_ITEM( msg, members, RED ) );
349  }
350  }
351  }
352 }
std::shared_ptr< BUS_ALIAS > GetBusAlias(const wxString &aName)
Returns a bus alias pointer for the given name if it exists (from cache)
wxString m_name
Name of the bus.
CONNECTION_GRAPH * g_ConnectionGraph
This also wants to live in the eventual SCHEMATIC object.
wxString Name(bool aIgnoreSheet=false) const
Definition: colors.h:60
bool ParseBusGroup(wxString aGroup, wxString *name, std::vector< wxString > &aMemberList) const
Parses a bus group label into the name and a list of components.
static bool m_allowRealTime
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers of advanced config.
Class EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:53
bool IsBus() const
Definition: colors.h:62

References BROWN, g_ConnectionGraph, CONNECTION_GRAPH::GetBusAlias(), ADVANCED_CFG::GetCfg(), IsBus(), CONNECTION_GRAPH::m_allowRealTime, m_name, m_net_code, Name(), ParseBusGroup(), and RED.

Referenced by AppendDebugInfoToMsgPanel().

◆ BusCode()

int SCH_CONNECTION::BusCode ( ) const
inline

Definition at line 194 of file sch_connection.h.

195  {
196  return m_bus_code;
197  }

References m_bus_code.

Referenced by Clone().

◆ ClearDirty()

void SCH_CONNECTION::ClearDirty ( )
inline

Definition at line 143 of file sch_connection.h.

144  {
145  m_dirty = false;
146  }

References m_dirty.

Referenced by CONNECTION_GRAPH::buildConnectionGraph().

◆ Clone()

void SCH_CONNECTION::Clone ( SCH_CONNECTION aOther)

Copies connectivity information (but not parent) from another connection.

Parameters
aOtheris the connection to clone

Definition at line 208 of file sch_connection.cpp.

209 {
210  m_type = aOther.Type();
211  m_driver = aOther.Driver();
212  m_sheet = aOther.Sheet();
213  m_name = aOther.m_name;
214  m_prefix = aOther.Prefix();
215  m_suffix = aOther.Suffix();
216  m_members = aOther.Members();
217  m_net_code = aOther.NetCode();
218  m_bus_code = aOther.BusCode();
219  m_vector_start = aOther.VectorStart();
220  m_vector_end = aOther.VectorEnd();
221  m_vector_index = aOther.VectorIndex();
222  m_vector_prefix = aOther.VectorPrefix();
223 
224  // Note: subgraph code isn't cloned, it should remain with the original object
225 }
wxString Prefix() const
std::vector< std::shared_ptr< SCH_CONNECTION > > m_members
For bus connections, store a list of member connections.
wxString m_name
Name of the bus.
SCH_ITEM * m_driver
The SCH_ITEM that drives this connection's net.
int BusCode() const
CONNECTION_TYPE m_type
int NetCode() const
wxString Suffix() const
long VectorEnd() const
SCH_ITEM * Driver() const
long VectorIndex() const
SCH_SHEET_PATH m_sheet
The hierarchical sheet this connection is on.
wxString m_suffix
Name suffix (used only for disambiguation)
SCH_SHEET_PATH Sheet() const
long m_vector_start
Highest member of a vector bus.
wxString VectorPrefix() const
long VectorStart() const
std::vector< std::shared_ptr< SCH_CONNECTION > > & Members()
long m_vector_index
Index of bus vector member nets.
long m_vector_end
Lowest member of a vector bus.
wxString m_vector_prefix
CONNECTION_TYPE Type() const

References BusCode(), Driver(), m_bus_code, m_driver, m_members, m_name, m_net_code, m_prefix, m_sheet, m_suffix, m_type, m_vector_end, m_vector_index, m_vector_prefix, m_vector_start, Members(), NetCode(), Prefix(), Sheet(), Suffix(), Type(), VectorEnd(), VectorIndex(), VectorPrefix(), and VectorStart().

Referenced by CONNECTION_GRAPH::buildConnectionGraph().

◆ ConfigureFromLabel()

void SCH_CONNECTION::ConfigureFromLabel ( wxString  aLabel)

Configures the connection given a label.

For CONNECTION_NET, this just sets the name. For CONNECTION_BUS, this will deduce the correct BUS_TYPE and also generate a correct list of members.

Definition at line 110 of file sch_connection.cpp.

111 {
112  m_members.clear();
113 
114  if( IsBusVectorLabel( aLabel ) )
115  {
116  m_name = aLabel;
118 
120 
121  for( long i = m_vector_start; i <= m_vector_end; ++i )
122  {
123  auto member = std::make_shared< SCH_CONNECTION >( m_parent, m_sheet );
124  wxString name = m_vector_prefix;
125  name << i;
126  member->m_type = CONNECTION_NET;
127  member->m_prefix = m_prefix;
128  member->m_name = name;
129  member->m_vector_index = i;
130  m_members.push_back( member );
131  }
132  }
133  else if( IsBusGroupLabel( aLabel ) )
134  {
136  m_name = aLabel;
137 
138  std::vector<wxString> members;
139  wxString group_name;
140 
141  if( ParseBusGroup( aLabel, &group_name, members ) )
142  {
143  // Named bus groups generate a net prefix, unnamed ones don't
144  wxString prefix = group_name != wxT( "" ) ? ( group_name + wxT( "." ) ) : wxT( "" );
145 
146  for( const auto& group_member : members )
147  {
148  // Handle alias inside bus group member list
149  if( auto alias = g_ConnectionGraph->GetBusAlias( group_member ) )
150  {
151  for( const auto& alias_member : alias->Members() )
152  {
153  auto member = std::make_shared< SCH_CONNECTION >( m_parent, m_sheet );
154  member->SetPrefix( prefix );
155  member->ConfigureFromLabel( alias_member );
156  m_members.push_back( member );
157  }
158  }
159  else
160  {
161  auto member = std::make_shared< SCH_CONNECTION >( m_parent, m_sheet );
162  member->SetPrefix( prefix );
163  member->ConfigureFromLabel( group_member );
164  m_members.push_back( member );
165  }
166  }
167  }
168  }
169  else if( auto alias = g_ConnectionGraph->GetBusAlias( aLabel ) )
170  {
172  m_name = aLabel;
173 
174  for( auto alias_member : alias->Members() )
175  {
176  auto member = std::make_shared< SCH_CONNECTION >( m_parent );
177  member->ConfigureFromLabel( alias_member );
178  m_members.push_back( member );
179  }
180  }
181  else
182  {
183  m_name = aLabel;
185  }
186 }
std::vector< std::shared_ptr< SCH_CONNECTION > > m_members
For bus connections, store a list of member connections.
std::shared_ptr< BUS_ALIAS > GetBusAlias(const wxString &aName)
Returns a bus alias pointer for the given name if it exists (from cache)
wxString m_name
Name of the bus.
CONNECTION_GRAPH * g_ConnectionGraph
This also wants to live in the eventual SCHEMATIC object.
CONNECTION_TYPE m_type
This item represents a net.
static bool IsBusVectorLabel(const wxString &aLabel)
Test if aLabel has a bus vector notation (simple bus, e.g.
bool ParseBusGroup(wxString aGroup, wxString *name, std::vector< wxString > &aMemberList) const
Parses a bus group label into the name and a list of components.
SCH_SHEET_PATH m_sheet
The hierarchical sheet this connection is on.
long m_vector_start
Highest member of a vector bus.
const char * name
Definition: DXF_plotter.cpp:61
size_t i
Definition: json11.cpp:597
long m_vector_end
Lowest member of a vector bus.
static bool IsBusGroupLabel(const wxString &aLabel)
Test if aLabel has a bus group notation.
This item represents a bus group.
wxString m_vector_prefix
void ParseBusVector(wxString vector, wxString *name, long *begin, long *end) const
Parses a bus vector (e.g.
SCH_ITEM * m_parent
The SCH_ITEM this connection is owned by.
This item represents a bus vector.

References CONNECTION_BUS, CONNECTION_BUS_GROUP, CONNECTION_NET, g_ConnectionGraph, CONNECTION_GRAPH::GetBusAlias(), i, IsBusGroupLabel(), IsBusVectorLabel(), m_members, m_name, m_parent, m_prefix, m_sheet, m_type, m_vector_end, m_vector_prefix, m_vector_start, name, ParseBusGroup(), and ParseBusVector().

Referenced by CONNECTION_GRAPH::buildConnectionGraph(), CONNECTION_GRAPH::ercCheckBusToNetConflicts(), and DIALOG_MIGRATE_BUSES::getProposedLabels().

◆ Driver()

SCH_ITEM* SCH_CONNECTION::Driver ( ) const
inline

Definition at line 101 of file sch_connection.h.

102  {
103  return m_driver;
104  }
SCH_ITEM * m_driver
The SCH_ITEM that drives this connection's net.

References m_driver.

Referenced by AppendDebugInfoToMsgPanel(), and Clone().

◆ IsBus()

◆ IsBusGroupLabel()

bool SCH_CONNECTION::IsBusGroupLabel ( const wxString &  aLabel)
static

Test if aLabel has a bus group notation.

Parameters
aLabelA wxString object containing the label to test.
Returns
true if text is a bus group notation format

Definition at line 401 of file sch_connection.cpp.

402 {
403  try
404  {
405  return std::regex_match( std::string( aLabel.mb_str() ), bus_group_label_re );
406  }
407  catch( ... )
408  {
409  return false;
410  }
411 }
static std::regex bus_group_label_re("^([^[:space:]]+)?\\{((?:[^[:space:]]+(?:\\[[\\d]+\\.+[\\d]+\\])? ?)+)\\}~*$")

References bus_group_label_re().

Referenced by ConfigureFromLabel(), NETLIST_OBJECT::ConvertBusToNetListItems(), and IsBusLabel().

◆ IsBusLabel()

bool SCH_CONNECTION::IsBusLabel ( const wxString &  aLabel)
static

Test if aLabel has a bus notation.

Parameters
aLabelA wxString object containing the label to test.
Returns
true if text is a bus notation format otherwise false is returned.

Definition at line 382 of file sch_connection.cpp.

383 {
384  return IsBusVectorLabel( aLabel ) || IsBusGroupLabel( aLabel );
385 }
static bool IsBusVectorLabel(const wxString &aLabel)
Test if aLabel has a bus vector notation (simple bus, e.g.
static bool IsBusGroupLabel(const wxString &aLabel)
Test if aLabel has a bus group notation.

References IsBusGroupLabel(), and IsBusVectorLabel().

Referenced by SCH_BUS_WIRE_ENTRY::ConnectionPropagatesTo(), NETLIST_OBJECT::ConvertBusToNetListItems(), SCH_TEXT::GetNetListItem(), SCH_SHEET::GetNetListItem(), and SCH_SCREEN::IsTerminalPoint().

◆ IsBusVectorLabel()

bool SCH_CONNECTION::IsBusVectorLabel ( const wxString &  aLabel)
static

Test if aLabel has a bus vector notation (simple bus, e.g.

A[7..0])

Parameters
aLabelA wxString object containing the label to test.
Returns
true if text is a bus notation format otherwise false is returned.

Definition at line 388 of file sch_connection.cpp.

389 {
390  try
391  {
392  return std::regex_match( std::string( aLabel.mb_str() ), bus_label_re );
393  }
394  catch( ... )
395  {
396  return false;
397  }
398 }
static std::regex bus_label_re("^([^[:space:]]+)(\\[[\\d]+\\.+[\\d]+\\])~*$")
Buses can be defined in multiple ways.

References bus_label_re().

Referenced by ConfigureFromLabel(), NETLIST_OBJECT::ConvertBusToNetListItems(), and IsBusLabel().

◆ IsDirty()

bool SCH_CONNECTION::IsDirty ( ) const
inline

Definition at line 133 of file sch_connection.h.

134  {
135  return m_dirty;
136  }

References m_dirty.

◆ IsDriver()

bool SCH_CONNECTION::IsDriver ( ) const

Checks if the SCH_ITEM this connection is attached to can drive connections Drivers can be labels, sheet pins, or component pins.

Returns
true if the attached items is a driver

Definition at line 228 of file sch_connection.cpp.

229 {
230  wxASSERT( Parent() );
231 
232  switch( Parent()->Type() )
233  {
234  case SCH_LABEL_T:
235  case SCH_GLOBAL_LABEL_T:
236  case SCH_HIER_LABEL_T:
237  case SCH_PIN_T:
238  case SCH_SHEET_PIN_T:
239  case SCH_SHEET_T:
240  case LIB_PIN_T:
241  return true;
242 
243  default:
244  return false;
245  }
246 }
SCH_ITEM * Parent() const
CONNECTION_TYPE Type() const

References LIB_PIN_T, Parent(), SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_LABEL_T, SCH_PIN_T, SCH_SHEET_PIN_T, SCH_SHEET_T, and Type().

Referenced by CONNECTION_SUBGRAPH::AddItem().

◆ IsMemberOfBus()

bool SCH_CONNECTION::IsMemberOfBus ( SCH_CONNECTION aOther) const

Returns true if this connection is a member of bus connection aOther.

Will always return false if aOther is not a bus connection

Definition at line 528 of file sch_connection.cpp.

529 {
530  if( !aOther->IsBus() )
531  return false;
532 
533  auto me = Name( true );
534 
535  for( auto m : aOther->Members() )
536  if( m->Name( true ) == me )
537  return true;
538 
539  return false;
540 }
wxString Name(bool aIgnoreSheet=false) const
std::vector< std::shared_ptr< SCH_CONNECTION > > & Members()
bool IsBus() const

References IsBus(), Members(), and Name().

◆ IsNet()

bool SCH_CONNECTION::IsNet ( ) const
inline

Definition at line 128 of file sch_connection.h.

129  {
130  return ( m_type == CONNECTION_NET );
131  }
CONNECTION_TYPE m_type
This item represents a net.

References CONNECTION_NET, and m_type.

Referenced by CONNECTION_GRAPH::buildConnectionGraph(), IsSubsetOf(), and CONNECTION_SUBGRAPH::UpdateItemConnections().

◆ IsSubsetOf()

bool SCH_CONNECTION::IsSubsetOf ( SCH_CONNECTION aOther) const

Returns true if aOther is a subset of this connection or vice versa.

For plain nets, this just tests whether or not the connectio names are the same. For buses, this tests whether the two have any shared members.

Will always return false if one connection is a bus and the other a net.

Definition at line 502 of file sch_connection.cpp.

503 {
504  if( aOther->IsNet() )
505  return IsNet() ? ( aOther->Name( true ) == Name( true ) ) : false;
506 
507  if( !IsBus() )
508  return false;
509 
510  std::vector<wxString> mine, theirs;
511 
512  for( auto m : Members() )
513  mine.push_back( m->Name( true ) );
514 
515  for( auto m : aOther->Members() )
516  theirs.push_back( m->Name( true ) );
517 
518  std::set<wxString> subset;
519 
520  std::set_intersection( mine.begin(), mine.end(),
521  theirs.begin(), theirs.end(),
522  std::inserter(subset, subset.begin() ) );
523 
524  return ( !subset.empty() );
525 }
wxString Name(bool aIgnoreSheet=false) const
bool IsNet() const
std::vector< std::shared_ptr< SCH_CONNECTION > > & Members()
bool IsBus() const

References IsBus(), IsNet(), Members(), and Name().

◆ Members() [1/2]

std::vector< std::shared_ptr< SCH_CONNECTION > >& SCH_CONNECTION::Members ( )
inline

◆ Members() [2/2]

const std::vector< std::shared_ptr< SCH_CONNECTION > >& SCH_CONNECTION::Members ( ) const
inline

Definition at line 239 of file sch_connection.h.

240  {
241  return m_members;
242  }
std::vector< std::shared_ptr< SCH_CONNECTION > > m_members
For bus connections, store a list of member connections.

References m_members.

◆ Name()

wxString SCH_CONNECTION::Name ( bool  aIgnoreSheet = false) const

Definition at line 249 of file sch_connection.cpp.

250 {
251  wxString ret = m_prefix + m_name + m_suffix;
252 
253  if( m_name.IsEmpty() )
254  ret = "<NO NET>";
255 
256  if( !Parent() || m_type == CONNECTION_NONE )
257  return ret;
258 
259  if( !aIgnoreSheet )
260  {
261  bool prepend_path = true;
262 
263  if( m_driver )
264  {
265  switch( m_driver->Type() )
266  {
267  case SCH_PIN_T:
268  // Pins are either power connections or belong to a uniquely-annotated
269  // component, so they don't need a path if they are driving the subgraph
270  prepend_path = false;
271  break;
272 
273  case SCH_GLOBAL_LABEL_T:
274  prepend_path = false;
275  break;
276 
277  default:
278  break;
279  }
280  }
281 
282  if( prepend_path )
283  ret = m_sheet.PathHumanReadable() + ret;
284  }
285 
286  return ret;
287 }
No connection to this item.
wxString m_name
Name of the bus.
SCH_ITEM * m_driver
The SCH_ITEM that drives this connection's net.
CONNECTION_TYPE m_type
SCH_SHEET_PATH m_sheet
The hierarchical sheet this connection is on.
wxString m_suffix
Name suffix (used only for disambiguation)
SCH_ITEM * Parent() const
wxString PathHumanReadable() const
Function PathHumanReadable returns the sheet path in a human readable form, i.e.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204

References CONNECTION_NONE, m_driver, m_name, m_prefix, m_sheet, m_suffix, m_type, Parent(), SCH_SHEET_PATH::PathHumanReadable(), SCH_GLOBAL_LABEL_T, SCH_PIN_T, and EDA_ITEM::Type().

Referenced by AppendInfoToMsgPanel(), CONNECTION_GRAPH::assignNewNetCode(), CONNECTION_GRAPH::buildConnectionGraph(), CONNECTION_GRAPH::ercCheckBusToBusEntryConflicts(), CONNECTION_GRAPH::ercCheckNoConnects(), CONNECTION_SUBGRAPH::GetNetName(), highlightNet(), IsMemberOfBus(), IsSubsetOf(), CONNECTION_GRAPH::propagateToNeighbors(), CONNECTION_GRAPH::recacheSubgraphName(), and SCH_EDITOR_CONTROL::UpdateNetHighlighting().

◆ NetCode()

int SCH_CONNECTION::NetCode ( ) const
inline

Definition at line 184 of file sch_connection.h.

185  {
186  return m_net_code;
187  }

References m_net_code.

Referenced by Clone().

◆ operator!=()

bool SCH_CONNECTION::operator!= ( const SCH_CONNECTION aOther) const

Definition at line 104 of file sch_connection.cpp.

105 {
106  return !( aOther == *this );
107 }

◆ operator==()

bool SCH_CONNECTION::operator== ( const SCH_CONNECTION aOther) const

Note: the equality operator for SCH_CONNECTION only tests the net properties, not the ownership / sheet location!

Definition at line 71 of file sch_connection.cpp.

72 {
73  // NOTE: Not comparing m_dirty or net/bus/subgraph codes
74  if( ( aOther.m_driver == m_driver ) &&
75  ( aOther.m_type == m_type ) &&
76  ( aOther.m_name == m_name ) &&
77  ( aOther.m_sheet == m_sheet ) )
78  {
79  return true;
80  }
81 
82  return false;
83 }
wxString m_name
Name of the bus.
SCH_ITEM * m_driver
The SCH_ITEM that drives this connection's net.
CONNECTION_TYPE m_type
SCH_SHEET_PATH m_sheet
The hierarchical sheet this connection is on.

References m_driver, m_name, m_sheet, and m_type.

◆ Parent()

SCH_ITEM* SCH_CONNECTION::Parent ( ) const
inline

Definition at line 96 of file sch_connection.h.

97  {
98  return m_parent;
99  }
SCH_ITEM * m_parent
The SCH_ITEM this connection is owned by.

References m_parent.

Referenced by IsDriver(), and Name().

◆ ParseBusGroup()

bool SCH_CONNECTION::ParseBusGroup ( wxString  aGroup,
wxString *  name,
std::vector< wxString > &  aMemberList 
) const

Parses a bus group label into the name and a list of components.

Parameters
aGroupis the input label, e.g. "USB{DP DM}"
nameis the output group name, e.g. "USB"
aMemberListis a list of member strings, e.g. "DP", "DM"
Returns
true if aGroup was successfully parsed

Definition at line 472 of file sch_connection.cpp.

474 {
475  auto ss_group = std::string( aGroup.mb_str() );
476  std::smatch matches;
477 
478  try
479  {
480  if( !std::regex_match( ss_group, matches, bus_group_label_re ) )
481  {
482  return false;
483  }
484  }
485  catch( ... )
486  {
487  return false;
488  }
489 
490  *aName = wxString( matches[1] );
491 
492  wxStringTokenizer tokenizer( wxString( matches[2] ), " " );
493  while( tokenizer.HasMoreTokens() )
494  {
495  aMemberList.push_back( tokenizer.GetNextToken() );
496  }
497 
498  return true;
499 }
static std::regex bus_group_label_re("^([^[:space:]]+)?\\{((?:[^[:space:]]+(?:\\[[\\d]+\\.+[\\d]+\\])? ?)+)\\}~*$")

References bus_group_label_re().

Referenced by AppendInfoToMsgPanel(), ConfigureFromLabel(), and NETLIST_OBJECT::ConvertBusToNetListItems().

◆ ParseBusVector()

void SCH_CONNECTION::ParseBusVector ( wxString  vector,
wxString *  name,
long *  begin,
long *  end 
) const

Parses a bus vector (e.g.

A[7..0]) into name, begin, and end. Ensures that begin and end are positive and that end > begin.

Parameters
vectoris a bus vector label string
nameoutput of the name portion of the label
beginis the first entry in the vector
endis the last entry in the vector

Definition at line 414 of file sch_connection.cpp.

416 {
417  auto ss_vector = std::string( aVector.mb_str() );
418  std::smatch matches;
419 
420  try
421  {
422  if( !std::regex_match( ss_vector, matches, bus_label_re ) )
423  {
424  wxFAIL_MSG( wxT( "<" ) + aVector + wxT( "> is not a valid bus vector." ) );
425  return;
426  }
427  }
428  catch( ... )
429  {
430  return;
431  }
432 
433  *aName = wxString( matches[1] );
434  wxString numberString( matches[2] );
435 
436  // numberString will include the brackets, e.g. [5..0] so skip the first one
437  size_t i = 1, len = numberString.Len();
438  wxString tmp;
439 
440  while( i < len && numberString[i] != '.' )
441  {
442  tmp.Append( numberString[i] );
443  i++;
444  }
445 
446  tmp.ToLong( begin );
447 
448  while( i < len && numberString[i] == '.' )
449  i++;
450 
451  tmp.Empty();
452 
453  while( i < len && numberString[i] != ']' )
454  {
455  tmp.Append( numberString[i] );
456  i++;
457  }
458 
459  tmp.ToLong( end );
460 
461  if( *begin < 0 )
462  *begin = 0;
463 
464  if( *end < 0 )
465  *end = 0;
466 
467  if( *begin > *end )
468  std::swap( *begin, *end );
469 }
static std::regex bus_label_re("^([^[:space:]]+)(\\[[\\d]+\\.+[\\d]+\\])~*$")
Buses can be defined in multiple ways.
size_t i
Definition: json11.cpp:597

References bus_label_re(), and i.

Referenced by ConfigureFromLabel(), and NETLIST_OBJECT::ConvertBusToNetListItems().

◆ Prefix()

wxString SCH_CONNECTION::Prefix ( ) const
inline

Definition at line 160 of file sch_connection.h.

161  {
162  return m_prefix;
163  }

References m_prefix.

Referenced by Clone().

◆ RawName()

wxString SCH_CONNECTION::RawName ( ) const
inline

Definition at line 150 of file sch_connection.h.

151  {
152  return m_name;
153  }
wxString m_name
Name of the bus.

References m_name.

Referenced by CONNECTION_GRAPH::matchBusMember().

◆ Reset()

void SCH_CONNECTION::Reset ( )

Clears connectivity information.

Definition at line 189 of file sch_connection.cpp.

190 {
192  m_name.Empty();
193  m_prefix.Empty();
194  m_suffix .Empty();
195  m_driver = nullptr;
196  m_members.clear();
197  m_dirty = true;
198  m_net_code = 0;
199  m_bus_code = 0;
200  m_subgraph_code = 0;
201  m_vector_start = 0;
202  m_vector_end = 0;
203  m_vector_index = 0;
204  m_vector_prefix.Empty();
205 }
int m_subgraph_code
Groups directly-connected items.
No connection to this item.
std::vector< std::shared_ptr< SCH_CONNECTION > > m_members
For bus connections, store a list of member connections.
wxString m_name
Name of the bus.
SCH_ITEM * m_driver
The SCH_ITEM that drives this connection's net.
CONNECTION_TYPE m_type
wxString m_suffix
Name suffix (used only for disambiguation)
long m_vector_start
Highest member of a vector bus.
long m_vector_index
Index of bus vector member nets.
long m_vector_end
Lowest member of a vector bus.
wxString m_vector_prefix

References CONNECTION_NONE, m_bus_code, m_dirty, m_driver, m_members, m_name, m_net_code, m_prefix, m_subgraph_code, m_suffix, m_type, m_vector_end, m_vector_index, m_vector_prefix, and m_vector_start.

Referenced by SCH_ITEM::InitializeConnection(), and SCH_CONNECTION().

◆ SetBusCode()

void SCH_CONNECTION::SetBusCode ( int  aCode)
inline

Definition at line 199 of file sch_connection.h.

200  {
201  m_bus_code = aCode;
202  }

References m_bus_code.

Referenced by CONNECTION_GRAPH::buildConnectionGraph().

◆ SetDirty()

void SCH_CONNECTION::SetDirty ( )
inline

Definition at line 138 of file sch_connection.h.

139  {
140  m_dirty = true;
141  }

References m_dirty.

◆ SetDriver()

void SCH_CONNECTION::SetDriver ( SCH_ITEM aItem)

Definition at line 86 of file sch_connection.cpp.

87 {
88  m_driver = aItem;
89 
90  for( auto member : m_members )
91  member->SetDriver( aItem );
92 }
std::vector< std::shared_ptr< SCH_CONNECTION > > m_members
For bus connections, store a list of member connections.
SCH_ITEM * m_driver
The SCH_ITEM that drives this connection's net.

References m_driver, and m_members.

Referenced by CONNECTION_GRAPH::buildConnectionGraph().

◆ SetName()

void SCH_CONNECTION::SetName ( const wxString &  aName)
inline

Definition at line 155 of file sch_connection.h.

156  {
157  m_name = aName;
158  }
wxString m_name
Name of the bus.

References m_name.

Referenced by CONNECTION_GRAPH::buildConnectionGraph().

◆ SetNetCode()

void SCH_CONNECTION::SetNetCode ( int  aCode)
inline

Definition at line 189 of file sch_connection.h.

190  {
191  m_net_code = aCode;
192  }

References m_net_code.

Referenced by CONNECTION_GRAPH::assignNewNetCode(), and CONNECTION_GRAPH::buildConnectionGraph().

◆ SetPrefix()

void SCH_CONNECTION::SetPrefix ( const wxString &  aPrefix)

Definition at line 290 of file sch_connection.cpp.

291 {
292  m_prefix = aPrefix;
293 
294  for( auto m : Members() )
295  m->SetPrefix( aPrefix );
296 }
std::vector< std::shared_ptr< SCH_CONNECTION > > & Members()

References m_prefix, and Members().

◆ SetSheet()

void SCH_CONNECTION::SetSheet ( SCH_SHEET_PATH  aSheet)

Definition at line 95 of file sch_connection.cpp.

96 {
97  m_sheet = aSheet;
98 
99  for( auto member : m_members )
100  member->SetSheet( aSheet );
101 }
std::vector< std::shared_ptr< SCH_CONNECTION > > m_members
For bus connections, store a list of member connections.
SCH_SHEET_PATH m_sheet
The hierarchical sheet this connection is on.

References m_members, and m_sheet.

Referenced by SCH_ITEM::InitializeConnection().

◆ SetSubgraphCode()

void SCH_CONNECTION::SetSubgraphCode ( int  aCode)
inline

Definition at line 209 of file sch_connection.h.

210  {
211  m_subgraph_code = aCode;
212  }
int m_subgraph_code
Groups directly-connected items.

References m_subgraph_code.

Referenced by CONNECTION_SUBGRAPH::Absorb(), and CONNECTION_GRAPH::buildConnectionGraph().

◆ SetSuffix()

void SCH_CONNECTION::SetSuffix ( const wxString &  aSuffix)

Definition at line 299 of file sch_connection.cpp.

300 {
301  m_suffix = aSuffix;
302 
303  for( auto m : Members() )
304  m->SetSuffix( aSuffix );
305 }
wxString m_suffix
Name suffix (used only for disambiguation)
std::vector< std::shared_ptr< SCH_CONNECTION > > & Members()

References m_suffix, and Members().

Referenced by CONNECTION_GRAPH::buildConnectionGraph().

◆ SetType()

void SCH_CONNECTION::SetType ( CONNECTION_TYPE  aType)
inline

Definition at line 179 of file sch_connection.h.

180  {
181  m_type = aType;
182  }
CONNECTION_TYPE m_type

References m_type.

◆ Sheet()

SCH_SHEET_PATH SCH_CONNECTION::Sheet ( ) const
inline

Definition at line 106 of file sch_connection.h.

107  {
108  return m_sheet;
109  }
SCH_SHEET_PATH m_sheet
The hierarchical sheet this connection is on.

References m_sheet.

Referenced by Clone().

◆ SubgraphCode()

int SCH_CONNECTION::SubgraphCode ( ) const
inline

Definition at line 204 of file sch_connection.h.

205  {
206  return m_subgraph_code;
207  }
int m_subgraph_code
Groups directly-connected items.

References m_subgraph_code.

Referenced by CONNECTION_GRAPH::buildConnectionGraph().

◆ Suffix()

wxString SCH_CONNECTION::Suffix ( ) const
inline

Definition at line 165 of file sch_connection.h.

166  {
167  return m_suffix;
168  }
wxString m_suffix
Name suffix (used only for disambiguation)

References m_suffix.

Referenced by Clone().

◆ Type()

CONNECTION_TYPE SCH_CONNECTION::Type ( ) const
inline

Definition at line 174 of file sch_connection.h.

175  {
176  return m_type;
177  }
CONNECTION_TYPE m_type

References m_type.

Referenced by Clone(), IsDriver(), and CONNECTION_GRAPH::matchBusMember().

◆ VectorEnd()

long SCH_CONNECTION::VectorEnd ( ) const
inline

Definition at line 219 of file sch_connection.h.

220  {
221  return m_vector_end;
222  }
long m_vector_end
Lowest member of a vector bus.

References m_vector_end.

Referenced by Clone(), and DIALOG_MIGRATE_BUSES::getProposedLabels().

◆ VectorIndex()

long SCH_CONNECTION::VectorIndex ( ) const
inline

Definition at line 224 of file sch_connection.h.

225  {
226  return m_vector_index;
227  }
long m_vector_index
Index of bus vector member nets.

References m_vector_index.

Referenced by Clone(), and CONNECTION_GRAPH::matchBusMember().

◆ VectorPrefix()

wxString SCH_CONNECTION::VectorPrefix ( ) const
inline

Definition at line 229 of file sch_connection.h.

230  {
231  return m_vector_prefix;
232  }
wxString m_vector_prefix

References m_vector_prefix.

Referenced by Clone(), and DIALOG_MIGRATE_BUSES::getProposedLabels().

◆ VectorStart()

long SCH_CONNECTION::VectorStart ( ) const
inline

Definition at line 214 of file sch_connection.h.

215  {
216  return m_vector_start;
217  }
long m_vector_start
Highest member of a vector bus.

References m_vector_start.

Referenced by Clone(), and DIALOG_MIGRATE_BUSES::getProposedLabels().

Member Data Documentation

◆ m_bus_code

int SCH_CONNECTION::m_bus_code
private

Definition at line 339 of file sch_connection.h.

Referenced by AppendDebugInfoToMsgPanel(), BusCode(), Clone(), Reset(), and SetBusCode().

◆ m_dirty

bool SCH_CONNECTION::m_dirty
private

Definition at line 320 of file sch_connection.h.

Referenced by ClearDirty(), IsDirty(), Reset(), and SetDirty().

◆ m_driver

SCH_ITEM* SCH_CONNECTION::m_driver
private

The SCH_ITEM that drives this connection's net.

Definition at line 326 of file sch_connection.h.

Referenced by Clone(), Driver(), Name(), operator==(), Reset(), and SetDriver().

◆ m_members

std::vector< std::shared_ptr< SCH_CONNECTION > > SCH_CONNECTION::m_members
private

For bus connections, store a list of member connections.

NOTE: All connections that Clone() others share the list of member pointers. This seems fine at the moment.

Definition at line 358 of file sch_connection.h.

Referenced by Clone(), ConfigureFromLabel(), Members(), Reset(), SetDriver(), and SetSheet().

◆ m_name

wxString SCH_CONNECTION::m_name
private

Name of the bus.

Prefix if connection is member of a labeled bus group (or "" if not)

Definition at line 330 of file sch_connection.h.

Referenced by AppendInfoToMsgPanel(), Clone(), ConfigureFromLabel(), Name(), operator==(), RawName(), Reset(), and SetName().

◆ m_net_code

int SCH_CONNECTION::m_net_code
private

Definition at line 337 of file sch_connection.h.

Referenced by AppendInfoToMsgPanel(), Clone(), NetCode(), Reset(), and SetNetCode().

◆ m_parent

SCH_ITEM* SCH_CONNECTION::m_parent
private

The SCH_ITEM this connection is owned by.

Definition at line 324 of file sch_connection.h.

Referenced by ConfigureFromLabel(), and Parent().

◆ m_prefix

wxString SCH_CONNECTION::m_prefix
private

Definition at line 333 of file sch_connection.h.

Referenced by Clone(), ConfigureFromLabel(), Name(), Prefix(), Reset(), and SetPrefix().

◆ m_sheet

SCH_SHEET_PATH SCH_CONNECTION::m_sheet
private

The hierarchical sheet this connection is on.

Definition at line 322 of file sch_connection.h.

Referenced by Clone(), ConfigureFromLabel(), Name(), operator==(), SetSheet(), and Sheet().

◆ m_subgraph_code

int SCH_CONNECTION::m_subgraph_code
private

Groups directly-connected items.

Definition at line 341 of file sch_connection.h.

Referenced by AppendDebugInfoToMsgPanel(), Reset(), SetSubgraphCode(), and SubgraphCode().

◆ m_suffix

wxString SCH_CONNECTION::m_suffix
private

Name suffix (used only for disambiguation)

Definition at line 335 of file sch_connection.h.

Referenced by Clone(), Name(), Reset(), SetSuffix(), and Suffix().

◆ m_type

CONNECTION_TYPE SCH_CONNECTION::m_type
private
See also
enum CONNECTION_TYPE

Definition at line 328 of file sch_connection.h.

Referenced by Clone(), ConfigureFromLabel(), IsBus(), IsNet(), Name(), operator==(), Reset(), SetType(), and Type().

◆ m_vector_end

long SCH_CONNECTION::m_vector_end
private

Lowest member of a vector bus.

Prefix name of the vector, if m_type == CONNECTION_BUS (or "" if not)

Definition at line 347 of file sch_connection.h.

Referenced by Clone(), ConfigureFromLabel(), Reset(), and VectorEnd().

◆ m_vector_index

long SCH_CONNECTION::m_vector_index
private

Index of bus vector member nets.

Definition at line 343 of file sch_connection.h.

Referenced by Clone(), Reset(), and VectorIndex().

◆ m_vector_prefix

wxString SCH_CONNECTION::m_vector_prefix
private

Definition at line 350 of file sch_connection.h.

Referenced by Clone(), ConfigureFromLabel(), Reset(), and VectorPrefix().

◆ m_vector_start

long SCH_CONNECTION::m_vector_start
private

Highest member of a vector bus.

Definition at line 345 of file sch_connection.h.

Referenced by Clone(), ConfigureFromLabel(), Reset(), and VectorStart().


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