Naming conventions.

This commit is contained in:
Jeff Young 2020-12-08 12:28:26 +00:00
parent 9407e6dc83
commit 20ad2bee2f
3 changed files with 52 additions and 55 deletions

View File

@ -67,20 +67,17 @@ class NETINFO_ITEM : public BOARD_ITEM
friend class NETINFO_LIST; friend class NETINFO_LIST;
private: private:
int m_NetCode; ///< A number equivalent to the net name. int m_netCode; ///< A number equivalent to the net name.
///< Used for fast comparisons in ratsnest and DRC computations. wxString m_netname; ///< Full net name like /sheet/subsheet/vout used by Eeschema.
wxString m_shortNetname; ///< short net name, like vout from /sheet/subsheet/vout.
bool m_isCurrent; ///< Indicates the net is currently in use. We still store those NETCLASSPTR m_netClass;
///< that are not during a session for undo/redo and to keep
///< netclass membership information.
wxString m_Netname; ///< Full net name like /mysheet/mysubsheet/vout used by Eeschema bool m_isCurrent; ///< Indicates the net is currently in use. We still store
///< those that are not during a session for undo/redo and to
///< keep netclass membership information.
wxString m_ShortNetname; ///< short net name, like vout from /mysheet/mysubsheet/vout BOARD* m_parent; ///< The parent board the net belongs to.
NETCLASSPTR m_NetClass;
BOARD* m_parent; ///< The parent board the net belongs to.
public: public:
@ -127,7 +124,7 @@ public:
*/ */
NETCLASS* GetNetClass() NETCLASS* GetNetClass()
{ {
return m_NetClass.get(); return m_netClass.get();
} }
/** /**
@ -136,7 +133,7 @@ public:
*/ */
wxString GetClassName() const wxString GetClassName() const
{ {
return m_NetClass ? m_NetClass->GetName() : NETCLASS::Default; return m_netClass ? m_netClass->GetName() : NETCLASS::Default;
} }
#if 1 #if 1
@ -147,8 +144,8 @@ public:
*/ */
int GetTrackWidth() int GetTrackWidth()
{ {
wxASSERT( m_NetClass ); wxASSERT( m_netClass );
return m_NetClass->GetTrackWidth(); return m_netClass->GetTrackWidth();
} }
/** /**
@ -157,8 +154,8 @@ public:
*/ */
int GetViaSize() int GetViaSize()
{ {
wxASSERT( m_NetClass ); wxASSERT( m_netClass );
return m_NetClass->GetViaDiameter(); return m_netClass->GetViaDiameter();
} }
/** /**
@ -167,8 +164,8 @@ public:
*/ */
int GetMicroViaSize() int GetMicroViaSize()
{ {
wxASSERT( m_NetClass ); wxASSERT( m_netClass );
return m_NetClass->GetuViaDiameter(); return m_netClass->GetuViaDiameter();
} }
/** /**
@ -177,8 +174,8 @@ public:
*/ */
int GetViaDrillSize() int GetViaDrillSize()
{ {
wxASSERT( m_NetClass ); wxASSERT( m_netClass );
return m_NetClass->GetViaDrill(); return m_netClass->GetViaDrill();
} }
/** /**
@ -187,8 +184,8 @@ public:
*/ */
int GetMicroViaDrillSize() int GetMicroViaDrillSize()
{ {
wxASSERT( m_NetClass ); wxASSERT( m_netClass );
return m_NetClass->GetuViaDrill(); return m_netClass->GetuViaDrill();
} }
@ -211,7 +208,7 @@ public:
*/ */
int GetClearance() int GetClearance()
{ {
return m_NetClass ? m_NetClass->GetClearance() : 0; return m_netClass ? m_netClass->GetClearance() : 0;
} }
#endif #endif
@ -220,21 +217,21 @@ public:
* Function GetNet * Function GetNet
* @return int - the netcode * @return int - the netcode
*/ */
int GetNet() const { return m_NetCode; } int GetNet() const { return m_netCode; }
void SetNetCode( int aNetCode ) { m_NetCode = aNetCode; } void SetNetCode( int aNetCode ) { m_netCode = aNetCode; }
/** /**
* Function GetNetname * Function GetNetname
* @return const wxString&, a reference to the full netname * @return const wxString&, a reference to the full netname
*/ */
const wxString& GetNetname() const { return m_Netname; } const wxString& GetNetname() const { return m_netname; }
/** /**
* Function GetShortNetname * Function GetShortNetname
* @return const wxString &, a reference to the short netname * @return const wxString &, a reference to the short netname
*/ */
const wxString& GetShortNetname() const { return m_ShortNetname; } const wxString& GetShortNetname() const { return m_shortNetname; }
/** /**
* Function SetNetname * Function SetNetname
@ -243,12 +240,12 @@ public:
*/ */
void SetNetname( const wxString& aNewName ) void SetNetname( const wxString& aNewName )
{ {
m_Netname = aNewName; m_netname = aNewName;
if( aNewName.Contains( "/" ) ) if( aNewName.Contains( "/" ) )
m_ShortNetname = aNewName.AfterLast( '/' ); m_shortNetname = aNewName.AfterLast( '/' );
else else
m_ShortNetname = aNewName; m_shortNetname = aNewName;
} }
bool IsCurrent() const { return m_isCurrent; } bool IsCurrent() const { return m_isCurrent; }
@ -358,7 +355,7 @@ public:
private: private:
std::map<int, int>::const_iterator m_iterator; std::map<int, int>::const_iterator m_iterator;
const NETINFO_MAPPING* m_mapping; const NETINFO_MAPPING* m_mapping;
}; };
/** /**
@ -393,11 +390,9 @@ public:
} }
private: private:
///> Board for which mapping is prepared const BOARD* m_board; ///> Board for which mapping is prepared
const BOARD* m_board; std::map<int, int> m_netMapping; ///> Map that allows saving net codes with consecutive
///> numbers (for compatibility reasons)
///> Map that allows saving net codes with consecutive numbers (for compatibility reasons)
std::map<int, int> m_netMapping;
}; };
@ -559,7 +554,7 @@ public:
BOARD* GetParent() const BOARD* GetParent() const
{ {
return m_Parent; return m_parent;
} }
private: private:
@ -582,12 +577,13 @@ private:
*/ */
int getFreeNetCode(); int getFreeNetCode();
BOARD* m_Parent; private:
BOARD* m_parent;
NETNAMES_MAP m_netNames; ///< map of <wxString, NETINFO_ITEM*>, is NETINFO_ITEM owner NETNAMES_MAP m_netNames; ///< map of <wxString, NETINFO_ITEM*>, is NETINFO_ITEM owner
NETCODES_MAP m_netCodes; ///< map of <int, NETINFO_ITEM*> is NOT owner NETCODES_MAP m_netCodes; ///< map of <int, NETINFO_ITEM*> is NOT owner
int m_newNetCode; ///< possible value for new net code assignment int m_newNetCode; ///< possible value for new net code assignment
}; };
#endif // CLASS_NETINFO_ #endif // CLASS_NETINFO_

View File

@ -40,18 +40,18 @@
/*********************************************************/ /*********************************************************/
NETINFO_ITEM::NETINFO_ITEM( BOARD* aParent, const wxString& aNetName, int aNetCode ) : NETINFO_ITEM::NETINFO_ITEM( BOARD* aParent, const wxString& aNetName, int aNetCode ) :
BOARD_ITEM( aParent, PCB_NETINFO_T ), BOARD_ITEM( aParent, PCB_NETINFO_T ),
m_NetCode( aNetCode ), m_netCode( aNetCode ),
m_isCurrent( true ), m_isCurrent( true ),
m_Netname( aNetName ), m_netname( aNetName ),
m_ShortNetname( m_Netname.AfterLast( '/' ) ) m_shortNetname( m_netname.AfterLast( '/' ) )
{ {
m_parent = aParent; m_parent = aParent;
if( aParent ) if( aParent )
m_NetClass = aParent->GetDesignSettings().GetNetClasses().GetDefault(); m_netClass = aParent->GetDesignSettings().GetNetClasses().GetDefault();
else else
m_NetClass = std::make_shared<NETCLASS>( "<invalid>" ); m_netClass = std::make_shared<NETCLASS>( "<invalid>" );
} }
@ -64,7 +64,7 @@ NETINFO_ITEM::~NETINFO_ITEM()
void NETINFO_ITEM::SetClass( const NETCLASSPTR& aNetClass ) void NETINFO_ITEM::SetClass( const NETCLASSPTR& aNetClass )
{ {
wxCHECK( m_parent, /* void */ ); wxCHECK( m_parent, /* void */ );
m_NetClass = aNetClass ? aNetClass : m_parent->GetDesignSettings().GetNetClasses().GetDefault(); m_netClass = aNetClass ? aNetClass : m_parent->GetDesignSettings().GetNetClasses().GetDefault();
} }

View File

@ -30,7 +30,8 @@
// Constructor and destructor // Constructor and destructor
NETINFO_LIST::NETINFO_LIST( BOARD* aParent ) : m_Parent( aParent ) NETINFO_LIST::NETINFO_LIST( BOARD* aParent ) :
m_parent( aParent )
{ {
// Make sure that the unconnected net has number 0 // Make sure that the unconnected net has number 0
AppendNet( new NETINFO_ITEM( aParent, wxEmptyString, 0 ) ); AppendNet( new NETINFO_ITEM( aParent, wxEmptyString, 0 ) );
@ -99,7 +100,7 @@ void NETINFO_LIST::RemoveNet( NETINFO_ITEM* aNet )
} }
} }
m_newNetCode = std::min( m_newNetCode, aNet->m_NetCode - 1 ); m_newNetCode = std::min( m_newNetCode, aNet->m_netCode - 1 );
} }
@ -128,15 +129,15 @@ void NETINFO_LIST::AppendNet( NETINFO_ITEM* aNewElement )
if( sameName != NULL ) if( sameName != NULL )
{ {
aNewElement->m_NetCode = sameName->GetNet(); aNewElement->m_netCode = sameName->GetNet();
return; return;
} }
// be sure that net codes are consecutive // be sure that net codes are consecutive
// negative net code means that it has to be auto assigned // negative net code means that it has to be auto assigned
else if( ( aNewElement->m_NetCode != (int) m_netCodes.size() ) || ( aNewElement->m_NetCode < 0 ) ) else if( aNewElement->m_netCode != (int) m_netCodes.size() || aNewElement->m_netCode < 0 )
{ {
aNewElement->m_NetCode = getFreeNetCode(); aNewElement->m_netCode = getFreeNetCode();
} }
// net names & codes are supposed to be unique // net names & codes are supposed to be unique
@ -155,8 +156,8 @@ void NETINFO_LIST::buildListOfNets()
for( NETINFO_ITEM* net : *this ) for( NETINFO_ITEM* net : *this )
net->Clear(); net->Clear();
m_Parent->SynchronizeNetsAndNetClasses( ); m_parent->SynchronizeNetsAndNetClasses( );
m_Parent->SetAreasNetCodesFromNetNames(); m_parent->SetAreasNetCodesFromNetNames();
} }