Switched to default copy ctor and/or operator= for BOARD, BOARD_CONNECTED_ITEM, DRAWSEGMENT & EDGE_MODULE.

This commit is contained in:
Maciej Suminski 2016-05-30 10:44:48 +02:00
parent ec4531948f
commit 2c08ff1d59
7 changed files with 19 additions and 73 deletions

View File

@ -212,6 +212,19 @@ private:
*/
void chainMarkedSegments( wxPoint aPosition, const LSET& aLayerSet, TRACKS* aList );
// The default copy constructor & operator= are inadequate,
// either write one or do not use it at all
BOARD( const BOARD& aOther ) :
BOARD_ITEM( aOther ), m_NetInfo( this )
{
assert( false );
}
BOARD& operator=( const BOARD& aOther )
{
assert( false );
}
public:
static inline bool ClassOf( const EDA_ITEM* aItem )
{

View File

@ -41,13 +41,6 @@ BOARD_CONNECTED_ITEM::BOARD_CONNECTED_ITEM( BOARD_ITEM* aParent, KICAD_T idtype
}
BOARD_CONNECTED_ITEM::BOARD_CONNECTED_ITEM( const BOARD_CONNECTED_ITEM& aItem ) :
BOARD_ITEM( aItem ), m_netinfo( aItem.m_netinfo ), m_Subnet( aItem.m_Subnet ),
m_ZoneSubnet( aItem.m_ZoneSubnet )
{
}
bool BOARD_CONNECTED_ITEM::SetNetCode( int aNetCode, bool aNoAssert )
{
// if aNetCode < 0 ( typically NETINFO_LIST::FORCE_ORPHANED )

View File

@ -56,7 +56,8 @@ public:
BOARD_CONNECTED_ITEM( BOARD_ITEM* aParent, KICAD_T idtype );
BOARD_CONNECTED_ITEM( const BOARD_CONNECTED_ITEM& aItem );
// Do not create a copy constructor & operator=.
// The ones generated by the compiler are adequate.
static inline bool ClassOf( const EDA_ITEM* aItem )
{

View File

@ -64,34 +64,6 @@ DRAWSEGMENT::~DRAWSEGMENT()
}
const DRAWSEGMENT& DRAWSEGMENT::operator = ( const DRAWSEGMENT& rhs )
{
// skip the linked list stuff, and parent
m_Type = rhs.m_Type;
m_Layer = rhs.m_Layer;
m_Width = rhs.m_Width;
m_Start = rhs.m_Start;
m_End = rhs.m_End;
m_Shape = rhs.m_Shape;
m_Angle = rhs.m_Angle;
m_TimeStamp = rhs.m_TimeStamp;
m_BezierC1 = rhs.m_BezierC1;
m_BezierC2 = rhs.m_BezierC1;
m_BezierPoints = rhs.m_BezierPoints;
return *this;
}
void DRAWSEGMENT::Copy( DRAWSEGMENT* source )
{
if( source == NULL ) // who would do this?
return;
*this = *source; // operator = ()
}
void DRAWSEGMENT::Rotate( const wxPoint& aRotCentre, double aAngle )
{
switch( m_Shape )

View File

@ -65,13 +65,11 @@ protected:
public:
DRAWSEGMENT( BOARD_ITEM* aParent = NULL, KICAD_T idtype = PCB_LINE_T );
// Do not create a copy constructor. The one generated by the compiler is adequate.
// Do not create a copy constructor & operator=.
// The ones generated by the compiler are adequate.
~DRAWSEGMENT();
/// skip the linked list stuff, and parent
const DRAWSEGMENT& operator = ( const DRAWSEGMENT& rhs );
static inline bool ClassOf( const EDA_ITEM* aItem )
{
return aItem && PCB_LINE_T == aItem->Type();
@ -181,8 +179,6 @@ public:
m_PolyPoints = aPoints;
}
void Copy( DRAWSEGMENT* source );
void Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
GR_DRAWMODE aDrawMode, const wxPoint& aOffset = ZeroOffset );

View File

@ -65,30 +65,6 @@ EDGE_MODULE::~EDGE_MODULE()
}
const EDGE_MODULE& EDGE_MODULE::operator = ( const EDGE_MODULE& rhs )
{
if( &rhs == this )
return *this;
DRAWSEGMENT::operator=( rhs );
m_Start0 = rhs.m_Start0;
m_End0 = rhs.m_End0;
m_PolyPoints = rhs.m_PolyPoints; // std::vector copy
return *this;
}
void EDGE_MODULE::Copy( EDGE_MODULE* source )
{
if( source == NULL )
return;
*this = *source;
}
void EDGE_MODULE::SetLocalCoord()
{
MODULE* module = (MODULE*) m_Parent;

View File

@ -46,21 +46,16 @@ class EDGE_MODULE : public DRAWSEGMENT
public:
EDGE_MODULE( MODULE* parent, STROKE_T aShape = S_SEGMENT );
// Do not create a copy constructor. The one generated by the compiler is adequate.
// EDGE_MODULE( const EDGE_MODULE& );
// Do not create a copy constructor & operator=.
// The ones generated by the compiler are adequate.
~EDGE_MODULE();
/// skip the linked list stuff, and parent
const EDGE_MODULE& operator = ( const EDGE_MODULE& rhs );
static inline bool ClassOf( const EDA_ITEM* aItem )
{
return aItem && PCB_MODULE_EDGE_T == aItem->Type();
}
void Copy( EDGE_MODULE* source ); // copy structure
/**
* Move an edge of the footprint.
* This is a footprint shape modification.