Eeschema: add delete symbol library code to schematic legacy plugin.
This commit is contained in:
parent
f14dc8f2be
commit
213ceaa280
|
@ -191,6 +191,7 @@ public:
|
||||||
//-----<PUBLIC SCH_PLUGIN API>-------------------------------------------------
|
//-----<PUBLIC SCH_PLUGIN API>-------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* Function GetName
|
* Function GetName
|
||||||
* returns a brief hard coded name for this SCH_PLUGIN.
|
* returns a brief hard coded name for this SCH_PLUGIN.
|
||||||
*/
|
*/
|
||||||
|
@ -204,50 +205,53 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Load
|
* Function Load
|
||||||
|
*
|
||||||
* loads information from some input file format that this SCH_PLUGIN implementation
|
* loads information from some input file format that this SCH_PLUGIN implementation
|
||||||
* knows about, into either a new SCHEMATIC or an existing one. This may be used to load an
|
* knows about, into either a new SCHEMATIC or an existing one. This may be used to load an
|
||||||
* entire new SCHEMATIC, or to augment an existing one if @a aAppendToMe is not NULL.
|
* entire new SCHEMATIC, or to augment an existing one if @a aAppendToMe is not NULL.
|
||||||
*
|
*
|
||||||
* @param aFileName is the name of the file to use as input and may be foreign in
|
* @param aFileName is the name of the file to use as input and may be foreign in
|
||||||
* nature or native in nature.
|
* nature or native in nature.
|
||||||
*
|
*
|
||||||
* @param aAppendToMe is an existing SCHEMATIC to append to, but if NULL then
|
* @param aAppendToMe is an existing SCHEMATIC to append to, but if NULL then this means
|
||||||
* this means "do not append, rather load anew".
|
* "do not append, rather load anew".
|
||||||
*
|
*
|
||||||
* @param aProperties is an associative array that can be used to tell the
|
* @param aProperties is an associative array that can be used to tell the loader how to
|
||||||
* loader how to load the file, because it can take any number of
|
* load the file, because it can take any number of additional named
|
||||||
* additional named arguments that the plugin is known to support. These are
|
* arguments that the plugin is known to support. These are tuning
|
||||||
* tuning parameters for the import or load. The caller continues to own
|
* parameters for the import or load. The caller continues to own
|
||||||
* this object (plugin may not delete it), and plugins should expect it to
|
* this object (plugin may not delete it), and plugins should expect
|
||||||
* be optionally NULL.
|
* it to be optionally NULL.
|
||||||
*
|
*
|
||||||
* @return SCHEMATIC* - the successfully loaded schematic, or the same one as \a aAppendToMe
|
* @return SCHEMATIC* - the successfully loaded schematic, or the same one as \a aAppendToMe
|
||||||
* if \a aAppendToMe was not NULL, and the caller owns it.
|
* if \a aAppendToMe was not NULL, and the caller owns it.
|
||||||
*
|
*
|
||||||
* @throw IO_ERROR if there is a problem loading, and its contents should
|
* @throw IO_ERROR if there is a problem loading, and its contents should say what went
|
||||||
* say what went wrong, using line number and character offsets of the
|
* wrong, using line number and character offsets of the input file if
|
||||||
* input file if possible.
|
* possible.
|
||||||
*/
|
*/
|
||||||
virtual SCH_SHEET* Load( const wxString& aFileName, KIWAY* aKiway,
|
virtual SCH_SHEET* Load( const wxString& aFileName, KIWAY* aKiway,
|
||||||
SCH_SHEET* aAppendToMe = NULL, const PROPERTIES* aProperties = NULL );
|
SCH_SHEET* aAppendToMe = NULL, const PROPERTIES* aProperties = NULL );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Save
|
* Function Save
|
||||||
|
*
|
||||||
* will write @a aSchematic to a storage file in a format that this
|
* will write @a aSchematic to a storage file in a format that this
|
||||||
* SCH_PLUGIN implementation knows about, or it can be used to write a portion of
|
* SCH_PLUGIN implementation knows about, or it can be used to write a portion of
|
||||||
* aSchematic to a special kind of export file.
|
* aSchematic to a special kind of export file.
|
||||||
*
|
*
|
||||||
* @param aFileName is the name of a file to save to on disk.
|
* @param aFileName is the name of a file to save to on disk.
|
||||||
*
|
*
|
||||||
* @param aSchematic is the class SCHEMATIC in memory document tree from which to
|
* @param aSchematic is the class SCHEMATIC in memory document tree from which to extract
|
||||||
* extract information when writing to \a aFileName. The caller continues to
|
* information when writing to \a aFileName. The caller continues to
|
||||||
* own the SCHEMATIC, and the plugin should refrain from modifying the SCHEMATIC if possible.
|
* own the SCHEMATIC, and the plugin should refrain from modifying the
|
||||||
|
* SCHEMATIC if possible.
|
||||||
*
|
*
|
||||||
* @param aProperties is an associative array that can be used to tell the
|
* @param aProperties is an associative array that can be used to tell the saver how to
|
||||||
* saver how to save the file, because it can take any number of
|
* save the file, because it can take any number of additional named
|
||||||
* additional named tuning arguments that the plugin is known to support.
|
* tuning arguments that the plugin is known to support. The caller
|
||||||
* The caller continues to own this object (plugin may not delete it),
|
* continues to own this object (plugin may not delete it), and plugins
|
||||||
* and plugins should expect it to be optionally NULL.
|
* should expect it to be optionally NULL.
|
||||||
*
|
*
|
||||||
* @throw IO_ERROR if there is a problem saving or exporting.
|
* @throw IO_ERROR if there is a problem saving or exporting.
|
||||||
*/
|
*/
|
||||||
|
@ -256,6 +260,7 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function EnumerateSymbolLib
|
* Function EnumerateSymbolLib
|
||||||
|
*
|
||||||
* returns a list of #LIB_PART alias names contained within the library @a aLibraryPath.
|
* returns a list of #LIB_PART alias names contained within the library @a aLibraryPath.
|
||||||
*
|
*
|
||||||
* @param aAliasNameList is an array to populate with the #LIB_ALIAS names associated with
|
* @param aAliasNameList is an array to populate with the #LIB_ALIAS names associated with
|
||||||
|
@ -278,6 +283,7 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function LoadSymbol
|
* Function LoadSymbol
|
||||||
|
*
|
||||||
* loads a #LIB_ALIAS object having @a aAliasName from the @a aLibraryPath containing
|
* loads a #LIB_ALIAS object having @a aAliasName from the @a aLibraryPath containing
|
||||||
* a library format that this SCH_PLUGIN knows about. The #LIB_PART should be accessed
|
* a library format that this SCH_PLUGIN knows about. The #LIB_PART should be accessed
|
||||||
* indirectly using the #LIB_ALIAS it is associated with.
|
* indirectly using the #LIB_ALIAS it is associated with.
|
||||||
|
@ -330,6 +336,7 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function DeleteAlias
|
* Function DeleteAlias
|
||||||
|
*
|
||||||
* deletes @a aAliasName from the library at @a aLibraryPath.
|
* deletes @a aAliasName from the library at @a aLibraryPath.
|
||||||
*
|
*
|
||||||
* If @a aAliasName refers the the root #LIB_PART object, the part is renamed to
|
* If @a aAliasName refers the the root #LIB_PART object, the part is renamed to
|
||||||
|
@ -355,6 +362,7 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function DeleteSymbol
|
* Function DeleteSymbol
|
||||||
|
*
|
||||||
* deletes the entire #LIB_PART associated with @a aAliasName from the library
|
* deletes the entire #LIB_PART associated with @a aAliasName from the library
|
||||||
* @a aLibraryPath.
|
* @a aLibraryPath.
|
||||||
*
|
*
|
||||||
|
@ -377,6 +385,7 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function CreateSymbolLib
|
* Function CreateSymbolLib
|
||||||
|
*
|
||||||
* creates a new empty symbol library at @a aLibraryPath. It is an error to attempt
|
* creates a new empty symbol library at @a aLibraryPath. It is an error to attempt
|
||||||
* to create an existing library or to attempt to create on a "read only" location.
|
* to create an existing library or to attempt to create on a "read only" location.
|
||||||
*
|
*
|
||||||
|
@ -395,25 +404,27 @@ public:
|
||||||
const PROPERTIES* aProperties = NULL );
|
const PROPERTIES* aProperties = NULL );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function SymbolLibDelete
|
* Function DeleteSymbolLib
|
||||||
* deletes an existing footprint library and returns true, or if library does not
|
|
||||||
* exist returns false, or throws an exception if library exists but is read only or
|
|
||||||
* cannot be deleted for some other reason.
|
|
||||||
*
|
*
|
||||||
* @param aLibraryPath is a locator for the "library", usually a directory
|
* deletes an existing symbol library and returns true if successful, or if library
|
||||||
* or file which will contain footprints.
|
* does not exist returns false, or throws an exception if library exists but is read
|
||||||
|
* only or cannot be deleted for some other reason.
|
||||||
*
|
*
|
||||||
* @param aProperties is an associative array that can be used to tell the
|
* @param aLibraryPath is a locator for the "library", usually a directory or file
|
||||||
* library delete implementation function anything special, because it can
|
* which will contain symbols.
|
||||||
* take any number of additional named tuning arguments that the plugin is
|
*
|
||||||
* known to support. The caller continues to own this object (plugin may
|
* @param aProperties is an associative array that can be used to tell the library
|
||||||
* not delete it), and plugins should expect it to be optionally NULL.
|
* delete implementation 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.
|
||||||
*
|
*
|
||||||
* @return bool - true if library deleted, false if library did not exist.
|
* @return bool - true if library deleted, false if library did not exist.
|
||||||
*
|
*
|
||||||
* @throw IO_ERROR if there is a problem deleting an existing library.
|
* @throw IO_ERROR if there is a problem deleting an existing library.
|
||||||
*/
|
*/
|
||||||
virtual bool SymbolLibDelete( const wxString& aLibraryPath,
|
virtual bool DeleteSymbolLib( const wxString& aLibraryPath,
|
||||||
const PROPERTIES* aProperties = NULL );
|
const PROPERTIES* aProperties = NULL );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -422,7 +433,7 @@ public:
|
||||||
* system libraries are read only because of where they are installed.)
|
* system libraries are read only because of where they are installed.)
|
||||||
*
|
*
|
||||||
* @param aLibraryPath is a locator for the "library", usually a directory, file,
|
* @param aLibraryPath is a locator for the "library", usually a directory, file,
|
||||||
* or URL containing several footprints.
|
* or URL containing several symbols.
|
||||||
*
|
*
|
||||||
* @throw IO_ERROR if no library at aLibraryPath exists.
|
* @throw IO_ERROR if no library at aLibraryPath exists.
|
||||||
*/
|
*/
|
||||||
|
@ -430,13 +441,13 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function SymbolLibOptions
|
* Function SymbolLibOptions
|
||||||
* appends supported SCH_PLUGIN options to @a aListToAppenTo along with
|
*
|
||||||
* internationalized descriptions. Options are typically appended so
|
* appends supported SCH_PLUGIN options to @a aListToAppenTo along with internationalized
|
||||||
* that a derived SCH_PLUGIN can call its base class
|
* descriptions. Options are typically appended so that a derived SCH_PLUGIN can call
|
||||||
* function by the same name first, thus inheriting options declared there.
|
* its base class function by the same name first, thus inheriting options declared there.
|
||||||
* (Some base class options could pertain to all Symbol*() functions
|
* (Some base class options could pertain to all Symbol*() functions in all derived
|
||||||
* in all derived SCH_PLUGINs.) Note that since aListToAppendTo is a PROPERTIES
|
* SCH_PLUGINs.) Note that since aListToAppendTo is a PROPERTIES object, all options
|
||||||
* object, all options will be unique and last guy wins.
|
* will be unique and last guy wins.
|
||||||
*
|
*
|
||||||
* @param aListToAppendTo holds a tuple of
|
* @param aListToAppendTo holds a tuple of
|
||||||
* <dl>
|
* <dl>
|
||||||
|
@ -471,6 +482,7 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class SCH_PLUGIN_RELEASER
|
* Class SCH_PLUGIN_RELEASER
|
||||||
|
*
|
||||||
* releases a SCH_PLUGIN in the context of a potential thrown exception, through
|
* releases a SCH_PLUGIN in the context of a potential thrown exception, through
|
||||||
* its destructor.
|
* its destructor.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -3394,3 +3394,29 @@ void SCH_LEGACY_PLUGIN::CreateSymbolLib( const wxString& aLibraryPath,
|
||||||
m_cache->Save();
|
m_cache->Save();
|
||||||
m_cache->Load(); // update m_writable and m_mod_time
|
m_cache->Load(); // update m_writable and m_mod_time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool SCH_LEGACY_PLUGIN::DeleteSymbolLib( const wxString& aLibraryPath,
|
||||||
|
const PROPERTIES* aProperties )
|
||||||
|
{
|
||||||
|
wxFileName fn = aLibraryPath;
|
||||||
|
|
||||||
|
if( !fn.FileExists() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Some of the more elaborate wxRemoveFile() crap puts up its own wxLog dialog
|
||||||
|
// we don't want that. we want bare metal portability with no UI here.
|
||||||
|
if( wxRemove( aLibraryPath ) )
|
||||||
|
{
|
||||||
|
THROW_IO_ERROR( wxString::Format( _( "library '%s' cannot be deleted" ),
|
||||||
|
aLibraryPath.GetData() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( m_cache && m_cache->IsFile( aLibraryPath ) )
|
||||||
|
{
|
||||||
|
delete m_cache;
|
||||||
|
m_cache = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -96,6 +96,8 @@ public:
|
||||||
const PROPERTIES* aProperties = NULL ) override;
|
const PROPERTIES* aProperties = NULL ) override;
|
||||||
void CreateSymbolLib( const wxString& aLibraryPath,
|
void CreateSymbolLib( const wxString& aLibraryPath,
|
||||||
const PROPERTIES* aProperties = NULL ) override;
|
const PROPERTIES* aProperties = NULL ) override;
|
||||||
|
bool DeleteSymbolLib( const wxString& aLibraryPath,
|
||||||
|
const PROPERTIES* aProperties = NULL ) override;
|
||||||
|
|
||||||
// Temporary for testing using PART_LIB instead of SCH_PLUGIN.
|
// Temporary for testing using PART_LIB instead of SCH_PLUGIN.
|
||||||
void TransferCache( PART_LIB& aTarget ) override;
|
void TransferCache( PART_LIB& aTarget ) override;
|
||||||
|
|
|
@ -36,9 +36,8 @@
|
||||||
static void not_implemented( SCH_PLUGIN* aPlugin, const char* aCaller )
|
static void not_implemented( SCH_PLUGIN* aPlugin, const char* aCaller )
|
||||||
{
|
{
|
||||||
THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED,
|
THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED,
|
||||||
aPlugin->GetName().GetData(),
|
aPlugin->GetName().GetData(),
|
||||||
wxString::FromUTF8( aCaller ).GetData() )
|
wxString::FromUTF8( aCaller ).GetData() ) );
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -114,7 +113,7 @@ void SCH_PLUGIN::CreateSymbolLib( const wxString& aLibraryPath, const PROPERTIES
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SCH_PLUGIN::SymbolLibDelete( const wxString& aLibraryPath, const PROPERTIES* aProperties )
|
bool SCH_PLUGIN::DeleteSymbolLib( const wxString& aLibraryPath, const PROPERTIES* aProperties )
|
||||||
{
|
{
|
||||||
// not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
|
// not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
|
||||||
not_implemented( this, __FUNCTION__ );
|
not_implemented( this, __FUNCTION__ );
|
||||||
|
@ -136,16 +135,16 @@ void SCH_PLUGIN::SymbolLibOptions( PROPERTIES* aListToAppendTo ) const
|
||||||
#if 1
|
#if 1
|
||||||
(*aListToAppendTo)["debug_level"] = UTF8( _(
|
(*aListToAppendTo)["debug_level"] = UTF8( _(
|
||||||
"Enable <b>debug</b> logging for Symbol*() functions in this SCH_PLUGIN."
|
"Enable <b>debug</b> logging for Symbol*() functions in this SCH_PLUGIN."
|
||||||
));
|
) );
|
||||||
|
|
||||||
(*aListToAppendTo)["read_filter_regex"] = UTF8( _(
|
(*aListToAppendTo)["read_filter_regex"] = UTF8( _(
|
||||||
"Regular expression <b>symbol name</b> filter."
|
"Regular expression <b>symbol name</b> filter."
|
||||||
));
|
) );
|
||||||
|
|
||||||
(*aListToAppendTo)["enable_transaction_logging"] = UTF8( _(
|
(*aListToAppendTo)["enable_transaction_logging"] = UTF8( _(
|
||||||
"Enable transaction logging. The mere presence of this option turns on the "
|
"Enable transaction logging. The mere presence of this option turns on the "
|
||||||
"logging, no need to set a Value."
|
"logging, no need to set a Value."
|
||||||
));
|
) );
|
||||||
|
|
||||||
(*aListToAppendTo)["username"] = UTF8( _(
|
(*aListToAppendTo)["username"] = UTF8( _(
|
||||||
"User name for <b>login</b> to some special library server."
|
"User name for <b>login</b> to some special library server."
|
||||||
|
@ -153,7 +152,7 @@ void SCH_PLUGIN::SymbolLibOptions( PROPERTIES* aListToAppendTo ) const
|
||||||
|
|
||||||
(*aListToAppendTo)["password"] = UTF8( _(
|
(*aListToAppendTo)["password"] = UTF8( _(
|
||||||
"Password for <b>login</b> to some special library server."
|
"Password for <b>login</b> to some special library server."
|
||||||
));
|
) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
|
@ -161,7 +160,6 @@ void SCH_PLUGIN::SymbolLibOptions( PROPERTIES* aListToAppendTo ) const
|
||||||
// if and when implemented.
|
// if and when implemented.
|
||||||
(*aListToAppendTo)["python_symbol_plugin"] = UTF8( _(
|
(*aListToAppendTo)["python_symbol_plugin"] = UTF8( _(
|
||||||
"Enter the python symbol which implements the SCH_PLUGIN::Symbol*() functions."
|
"Enter the python symbol which implements the SCH_PLUGIN::Symbol*() functions."
|
||||||
));
|
) );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue