Commit fe13569b authored by dickelbeck's avatar dickelbeck

fix TRACK::Copy() usage

parent 4173f9b9
...@@ -66,14 +66,12 @@ TRACK::TRACK( const TRACK& Source ) : ...@@ -66,14 +66,12 @@ TRACK::TRACK( const TRACK& Source ) :
} }
/* Because of the way SEGVIA is derived from TRACK and because there are /* Because of the way SEGVIA and SEGZONE are derived from TRACK and because there are
virtual functions being used, we can no longer simply copy a TRACK and virtual functions being used, we can no longer simply copy a TRACK and
expect it to be a via. We must construct a true SEGVIA so its constructor expect it to be a via or zone. We must construct a true SEGVIA or SEGZONE so its constructor
can initialize the virtual function table properly. So this constructor can initialize the virtual function table properly. This factory type of
is being retired in favor of a factory type function called Copy() function called Copy() can duplicate either a TRACK, SEGVIA, or SEGZONE.
which can duplicate either a TRACK or a SEGVIA.
*/ */
TRACK* TRACK::Copy() const TRACK* TRACK::Copy() const
{ {
if( Type() == TYPETRACK ) if( Type() == TYPETRACK )
...@@ -81,6 +79,9 @@ TRACK* TRACK::Copy() const ...@@ -81,6 +79,9 @@ TRACK* TRACK::Copy() const
if( Type() == TYPEVIA ) if( Type() == TYPEVIA )
return new SEGVIA( (const SEGVIA&) *this ); return new SEGVIA( (const SEGVIA&) *this );
if( Type() == TYPEZONE )
return new SEGZONE( (const SEGZONE&) *this );
return NULL; // should never happen return NULL; // should never happen
} }
...@@ -458,21 +459,23 @@ TRACK* TRACK::GetEndNetCode( int NetCode ) ...@@ -458,21 +459,23 @@ TRACK* TRACK::GetEndNetCode( int NetCode )
} }
#if 0
/**********************************/ /**********************************/
TRACK* TRACK:: Copy( int NbSegm ) TRACK* TRACK:: CopyList( int NbSegm ) const
/**********************************/ /**********************************/
/* Copie d'un Element ou d'une chaine de n elements /* Copie d'un Element ou d'une chaine de n elements
* Retourne un pointeur sur le nouvel element ou le debut de la * Retourne un pointeur sur le nouvel element ou le debut de la
* nouvelle chaine * nouvelle chaine
*/ */
{ {
TRACK* NewTrack, * FirstTrack, * OldTrack, * Source = this; TRACK* NewTrack;
int ii; TRACK* FirstTrack;
TRACK* OldTrack;
FirstTrack = NewTrack = new TRACK( *Source ); const TRACK* Source = this;
FirstTrack = NewTrack = Source->Copy();
for( ii = 1; ii < NbSegm; ii++ ) for( int ii = 1; ii < NbSegm; ii++ )
{ {
Source = Source->Next(); Source = Source->Next();
if( Source == NULL ) if( Source == NULL )
...@@ -487,6 +490,7 @@ TRACK* TRACK:: Copy( int NbSegm ) ...@@ -487,6 +490,7 @@ TRACK* TRACK:: Copy( int NbSegm )
return FirstTrack; return FirstTrack;
} }
#endif
/********************************************/ /********************************************/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment