From a377fa4201a781fe0cf8eeb6b69c29bdeca508b3 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Thu, 25 Jan 2024 09:08:10 -0500 Subject: [PATCH] Add some missing deep comparisions for BOARD_STACKUP --- .../board_stackup_manager/board_stackup.cpp | 44 ++++++++++++++++++- pcbnew/board_stackup_manager/board_stackup.h | 6 +++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/pcbnew/board_stackup_manager/board_stackup.cpp b/pcbnew/board_stackup_manager/board_stackup.cpp index 92c7d65f3e..567da8b3d4 100644 --- a/pcbnew/board_stackup_manager/board_stackup.cpp +++ b/pcbnew/board_stackup_manager/board_stackup.cpp @@ -29,6 +29,19 @@ #include "stackup_predefined_prms.h" +bool DIELECTRIC_PRMS::operator==( const DIELECTRIC_PRMS& aOther ) const +{ + if( m_Material != aOther.m_Material ) return false; + if( m_Thickness != aOther.m_Thickness ) return false; + if( m_ThicknessLocked != aOther.m_ThicknessLocked ) return false; + if( m_EpsilonR != aOther.m_EpsilonR ) return false; + if( m_LossTangent != aOther.m_LossTangent ) return false; + if( m_Color != aOther.m_Color ) return false; + + return true; +} + + BOARD_STACKUP_ITEM::BOARD_STACKUP_ITEM( BOARD_STACKUP_ITEM_TYPE aType ) { DIELECTRIC_PRMS item_prms; @@ -91,6 +104,29 @@ BOARD_STACKUP_ITEM::BOARD_STACKUP_ITEM( const BOARD_STACKUP_ITEM& aOther ) } +bool BOARD_STACKUP_ITEM::operator==( const BOARD_STACKUP_ITEM& aOther ) const +{ + if( m_Type != aOther.m_Type ) return false; + if( m_LayerName != aOther.m_LayerName ) return false; + if( m_TypeName != aOther.m_TypeName ) return false; + if( m_LayerId != aOther.m_LayerId ) return false; + if( m_DielectricLayerId != aOther.m_DielectricLayerId ) return false; + if( m_enabled != aOther.m_enabled ) return false; + + if( !std::equal( std::begin( m_DielectricPrmsList ), std::end( m_DielectricPrmsList ), + std::begin( aOther.m_DielectricPrmsList ), + []( const DIELECTRIC_PRMS& aA, const DIELECTRIC_PRMS& aB ) + { + return aA == aB; + } ) ) + { + return false; + } + + return true; +} + + void BOARD_STACKUP_ITEM::AddDielectricPrms( int aDielectricPrmsIdx ) { // add a DIELECTRIC_PRMS item to m_DielectricPrmsList @@ -369,8 +405,14 @@ bool BOARD_STACKUP::operator==( const BOARD_STACKUP& aOther ) const if( m_EdgePlating != aOther.m_EdgePlating ) return false; if( m_FinishType != aOther.m_FinishType ) return false; - if( !std::equal( std::begin( m_list ), std::end( m_list ), std::begin( aOther.m_list ) ) ) + if( !std::equal( std::begin( m_list ), std::end( m_list ), std::begin( aOther.m_list ), + []( const BOARD_STACKUP_ITEM* aA, const BOARD_STACKUP_ITEM* aB ) + { + return *aA == *aB; + } ) ) + { return false; + } return true; } diff --git a/pcbnew/board_stackup_manager/board_stackup.h b/pcbnew/board_stackup_manager/board_stackup.h index 316dd549fa..d3ab92892f 100644 --- a/pcbnew/board_stackup_manager/board_stackup.h +++ b/pcbnew/board_stackup_manager/board_stackup.h @@ -69,6 +69,9 @@ public: m_EpsilonR( 1.0 ), m_LossTangent( 0.0 ) {} + bool operator==( const DIELECTRIC_PRMS& aOther ) const; + bool operator!=( const DIELECTRIC_PRMS& aOther ) const { return !operator==( aOther ); } + private: friend class BOARD_STACKUP_ITEM; @@ -93,6 +96,9 @@ public: BOARD_STACKUP_ITEM( BOARD_STACKUP_ITEM_TYPE aType ); BOARD_STACKUP_ITEM( const BOARD_STACKUP_ITEM& aOther ); + bool operator==( const BOARD_STACKUP_ITEM& aOther ) const; + bool operator!=( const BOARD_STACKUP_ITEM& aOther ) const { return !operator==( aOther ); } + /** * Add (insert) a DIELECTRIC_PRMS item to m_DielectricPrmsList * all values are set to default