Eeschema: add delete symbol method to schematic I/O plugin.

This commit is contained in:
Wayne Stambaugh 2016-09-29 18:31:43 -04:00
parent 04e21d5c8f
commit aa5e979b8a
4 changed files with 65 additions and 0 deletions

View File

@ -351,6 +351,28 @@ public:
virtual void DeleteAlias( const wxString& aLibraryPath, const wxString& aAliasName,
const PROPERTIES* aProperties = NULL );
/**
* Function DeleteSymbol
* deletes the entire #LIB_PART associated with @a aAliasName from the library
* @a aLibraryPath.
*
* @param aLibraryPath is a locator for the "library", usually a directory, file,
* or URL containing several symbols.
*
* @param aAliasName is the name of a #LIB_ALIAS associated with it's root #LIB_PART
* object to delete from the specified library.
*
* @param aProperties is an associative array that can be used to tell the library
* delete function anything special, because it can take any number
* of additional named tuning arguments that the plugin is known to
* support. The caller continues to own this object (plugin may not
* delete it), and plugins should expect it to be optionally NULL.
*
* @throw IO_ERROR if there is a problem finding the alias or the library or deleting it.
*/
virtual void DeleteSymbol( const wxString& aLibraryPath, const wxString& aAliasName,
const PROPERTIES* aProperties = NULL );
/**
* Function SymbolLibCreate
* creates a new empty footprint library at @a aLibraryPath empty. It is an

View File

@ -1948,6 +1948,8 @@ public:
void DeleteAlias( const wxString& aAliasName );
void DeleteSymbol( const wxString& aAliasName );
wxDateTime GetLibModificationTime();
bool IsFile( const wxString& aFullPathAndFileName ) const;
@ -3237,6 +3239,25 @@ void SCH_LEGACY_PLUGIN_CACHE::DeleteAlias( const wxString& aAliasName )
}
void SCH_LEGACY_PLUGIN_CACHE::DeleteSymbol( const wxString& aAliasName )
{
LIB_ALIAS_MAP::iterator it = m_aliases.find( aAliasName );
if( it == m_aliases.end() )
THROW_IO_ERROR( wxString::Format( _( "library %s does not contain an alias %s" ),
m_libFileName.GetFullName(), aAliasName ) );
LIB_ALIAS* alias = it->second;
LIB_PART* part = alias->GetPart();
wxArrayString aliasNames = part->GetAliasNames();
// Deleting all of the aliases deletes the symbol from the library.
for( size_t i = 0; i < aliasNames.Count(); i++ )
DeleteAlias( aliasNames[i] );
}
void SCH_LEGACY_PLUGIN::cacheLib( const wxString& aLibraryFileName )
{
if( !m_cache || !m_cache->IsFile( aLibraryFileName ) || m_cache->IsFileChanged() )
@ -3323,3 +3344,14 @@ void SCH_LEGACY_PLUGIN::DeleteAlias( const wxString& aLibraryPath, const wxStrin
m_cache->DeleteAlias( aAliasName );
}
void SCH_LEGACY_PLUGIN::DeleteSymbol( const wxString& aLibraryPath, const wxString& aAliasName,
const PROPERTIES* aProperties )
{
m_props = aProperties;
cacheLib( aLibraryPath );
m_cache->DeleteSymbol( aAliasName );
}

View File

@ -93,6 +93,9 @@ public:
void DeleteAlias( const wxString& aLibraryPath, const wxString& aAliasName,
const PROPERTIES* aProperties = NULL ) override;
void DeleteSymbol( const wxString& aLibraryPath, const wxString& aAliasName,
const PROPERTIES* aProperties = NULL ) override;
// Temporary for testing using PART_LIB instead of SCH_PLUGIN.
void TransferCache( PART_LIB& aTarget ) override;

View File

@ -99,6 +99,14 @@ void SCH_PLUGIN::DeleteAlias( const wxString& aLibraryPath, const wxString& aAli
}
void SCH_PLUGIN::DeleteSymbol( const wxString& aLibraryPath, const wxString& aAliasName,
const PROPERTIES* aProperties )
{
// not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
not_implemented( this, __FUNCTION__ );
}
void SCH_PLUGIN::SymbolLibCreate( const wxString& aLibraryPath, const PROPERTIES* aProperties )
{
// not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.