2010-12-27 16:49:39 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KICAD, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Kicad Developers, see change_log.txt for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2011-01-01 22:56:43 +00:00
|
|
|
#include <wx/wx.h> // _()
|
2010-12-27 16:49:39 +00:00
|
|
|
|
2010-12-30 01:47:14 +00:00
|
|
|
#include <sch_part.h>
|
2011-02-14 06:39:51 +00:00
|
|
|
#include <sch_sweet_parser.h>
|
2011-01-01 22:56:43 +00:00
|
|
|
#include <sch_lpid.h>
|
|
|
|
#include <sch_lib_table.h>
|
2010-12-27 16:49:39 +00:00
|
|
|
|
2011-01-01 22:56:43 +00:00
|
|
|
|
2011-02-14 06:39:51 +00:00
|
|
|
using namespace SCH;
|
2011-01-01 22:56:43 +00:00
|
|
|
|
|
|
|
|
2011-01-03 17:47:08 +00:00
|
|
|
PART::PART( LIB* aOwner, const STRING& aPartNameAndRev ) :
|
2011-01-01 22:56:43 +00:00
|
|
|
owner( aOwner ),
|
|
|
|
contains( 0 ),
|
2011-01-03 17:47:08 +00:00
|
|
|
partNameAndRev( aPartNameAndRev ),
|
|
|
|
extends( 0 ),
|
|
|
|
base( 0 )
|
|
|
|
{
|
|
|
|
// Our goal is to have class LIB only instantiate what is needed, so print here
|
|
|
|
// what it is doing. It is the only class where PART can be instantiated.
|
|
|
|
D(printf("PART::PART(%s)\n", aPartNameAndRev.c_str() );)
|
|
|
|
}
|
2011-01-01 22:56:43 +00:00
|
|
|
|
|
|
|
|
2011-02-14 06:39:51 +00:00
|
|
|
void PART::clear()
|
|
|
|
{
|
|
|
|
if( extends )
|
|
|
|
{
|
|
|
|
delete extends;
|
|
|
|
extends = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for( GRAPHICS::iterator it = graphics.begin(); it != graphics.end(); ++it )
|
|
|
|
delete *it;
|
|
|
|
graphics.clear();
|
|
|
|
|
|
|
|
|
|
|
|
// @todo delete all properties, pins, and graphics
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-01 22:56:43 +00:00
|
|
|
PART::~PART()
|
|
|
|
{
|
2011-02-14 06:39:51 +00:00
|
|
|
clear();
|
2011-01-01 22:56:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PART::setExtends( LPID* aLPID )
|
|
|
|
{
|
|
|
|
delete extends;
|
|
|
|
extends = aLPID;
|
2010-12-27 16:49:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-01 22:56:43 +00:00
|
|
|
void PART::inherit( const PART& other )
|
|
|
|
{
|
|
|
|
contains = other.contains;
|
|
|
|
|
2011-01-03 17:47:08 +00:00
|
|
|
// @todo copy the inherited drawables, properties, and pins here
|
2011-01-01 22:56:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PART& PART::operator=( const PART& other )
|
|
|
|
{
|
2011-01-03 17:47:08 +00:00
|
|
|
owner = other.owner;
|
|
|
|
partNameAndRev = other.partNameAndRev;
|
|
|
|
body = other.body;
|
|
|
|
base = other.base;
|
|
|
|
|
|
|
|
setExtends( other.extends ? new LPID( *other.extends ) : 0 );
|
2011-01-01 22:56:43 +00:00
|
|
|
|
2011-01-03 17:47:08 +00:00
|
|
|
// maintain in concert with inherit(), which is a partial assignment operator.
|
2011-01-01 22:56:43 +00:00
|
|
|
inherit( other );
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-14 06:39:51 +00:00
|
|
|
void PART::Parse( SWEET_PARSER* aParser, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_ERROR )
|
2011-01-01 22:56:43 +00:00
|
|
|
{
|
2011-02-14 06:39:51 +00:00
|
|
|
aParser->Parse( this, aTable );
|
2011-01-01 22:56:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-29 20:25:30 +00:00
|
|
|
#if 0 && defined(DEBUG)
|
2010-12-27 16:49:39 +00:00
|
|
|
|
|
|
|
int main( int argc, char** argv )
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|