mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-03-09 14:26:28 +00:00
Push library management into IO_BASE
This commit is contained in:
parent
cad91312aa
commit
743e9d669a
common
eeschema
dialogs
sch_io
symbol_editor
symbol_lib_table.cppsymbol_library.cppinclude/io
pcbnew
dialogs
footprint_edit_frame.hfootprint_libraries_utils.cpppcb_io
altium
cadstar
eagle
easyeda
easyedapro
geda
ipc2581
kicad_legacy
kicad_sexpr
pcb_io.cpppcb_io.hpcb_io_mgr.cpppython
tools
@ -379,6 +379,7 @@ set( PLOTTERS_CONTROL_SRCS
|
||||
|
||||
set( COMMON_IO_SRCS
|
||||
io/plugin_file_desc.cpp
|
||||
io/io_base.cpp
|
||||
io/io_utils.cpp
|
||||
|
||||
# Altium
|
||||
|
@ -448,7 +448,7 @@ bool FP_LIB_TABLE::IsFootprintLibWritable( const wxString& aNickname )
|
||||
{
|
||||
const FP_LIB_TABLE_ROW* row = FindRow( aNickname, true );
|
||||
wxASSERT( (PCB_IO*) row->plugin );
|
||||
return row->plugin->IsFootprintLibWritable( row->GetFullURI( true ) );
|
||||
return row->plugin->IsLibraryWritable( row->GetFullURI( true ) );
|
||||
}
|
||||
|
||||
|
||||
@ -456,7 +456,7 @@ void FP_LIB_TABLE::FootprintLibDelete( const wxString& aNickname )
|
||||
{
|
||||
const FP_LIB_TABLE_ROW* row = FindRow( aNickname, true );
|
||||
wxASSERT( (PCB_IO*) row->plugin );
|
||||
row->plugin->FootprintLibDelete( row->GetFullURI( true ), row->GetProperties() );
|
||||
row->plugin->DeleteLibrary( row->GetFullURI( true ), row->GetProperties() );
|
||||
}
|
||||
|
||||
|
||||
@ -464,7 +464,7 @@ void FP_LIB_TABLE::FootprintLibCreate( const wxString& aNickname )
|
||||
{
|
||||
const FP_LIB_TABLE_ROW* row = FindRow( aNickname, true );
|
||||
wxASSERT( (PCB_IO*) row->plugin );
|
||||
row->plugin->FootprintLibCreate( row->GetFullURI( true ), row->GetProperties() );
|
||||
row->plugin->CreateLibrary( row->GetFullURI( true ), row->GetProperties() );
|
||||
}
|
||||
|
||||
|
||||
|
58
common/io/io_base.cpp
Normal file
58
common/io/io_base.cpp
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2023 KiCad Developers, see AUTHORS.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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include <io/io_base.h>
|
||||
#include <ki_exception.h>
|
||||
|
||||
#define FMT_UNIMPLEMENTED wxT( "IO interface \"%s\" does not implement the \"%s\" function." )
|
||||
#define NOT_IMPLEMENTED( aCaller ) \
|
||||
THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, \
|
||||
GetName(), \
|
||||
wxString::FromUTF8( aCaller ) ) );
|
||||
|
||||
|
||||
void IO_BASE::CreateLibrary( const wxString& aLibraryPath, const STRING_UTF8_MAP* aProperties )
|
||||
{
|
||||
NOT_IMPLEMENTED( __FUNCTION__ );
|
||||
}
|
||||
|
||||
|
||||
bool IO_BASE::DeleteLibrary( const wxString& aLibraryPath, const STRING_UTF8_MAP* aProperties )
|
||||
{
|
||||
NOT_IMPLEMENTED( __FUNCTION__ );
|
||||
}
|
||||
|
||||
|
||||
bool IO_BASE::IsLibraryWritable( const wxString& aLibraryPath )
|
||||
{
|
||||
NOT_IMPLEMENTED( __FUNCTION__ );
|
||||
}
|
||||
|
||||
void IO_BASE::GetLibraryOptions( STRING_UTF8_MAP* aListToAppendTo ) const
|
||||
{
|
||||
// No global options to append
|
||||
}
|
||||
|
||||
|
||||
bool IO_BASE::CanReadLibrary( const wxString& aFileName ) const
|
||||
{
|
||||
// TODO: Push file extension based checks from PCB_IO and SCH_IO into this function
|
||||
return false;
|
||||
}
|
@ -173,7 +173,7 @@ protected:
|
||||
|
||||
SCH_IO_MGR::SCH_FILE_T pi_type = SCH_IO_MGR::EnumFromStr( row->GetType() );
|
||||
SCH_IO::SCH_IO_RELEASER pi( SCH_IO_MGR::FindPlugin( pi_type ) );
|
||||
pi->SymbolLibOptions( &choices );
|
||||
pi->GetLibraryOptions( &choices );
|
||||
|
||||
DIALOG_PLUGIN_OPTIONS dlg( m_dialog, row->GetNickName(), choices, options, &result );
|
||||
dlg.ShowModal();
|
||||
|
@ -361,7 +361,7 @@ SCH_SHEET* SCH_IO_ALTIUM::LoadSchematicFile( const wxString& aFileName, SCHEMATI
|
||||
if( !libTable->HasLibrary( getLibName() ) )
|
||||
{
|
||||
// Create a new empty symbol library.
|
||||
m_pi->CreateSymbolLib( getLibFileName().GetFullPath() );
|
||||
m_pi->CreateLibrary( getLibFileName().GetFullPath() );
|
||||
wxString libTableUri = "${KIPRJMOD}/" + getLibFileName().GetFullName();
|
||||
|
||||
// Add the new library to the project symbol library table.
|
||||
|
@ -106,18 +106,7 @@ public:
|
||||
//void DeleteSymbol( const wxString& aLibraryPath, const wxString& aAliasName,
|
||||
// const PROPERTIES* aProperties = NULL ) override;
|
||||
|
||||
//void CreateSymbolLib( const wxString& aLibraryPath,
|
||||
// const PROPERTIES* aProperties = NULL ) override;
|
||||
|
||||
// bool DeleteSymbolLib( const wxString& aLibraryPath,
|
||||
// const PROPERTIES* aProperties = NULL ) override;
|
||||
|
||||
bool IsSymbolLibWritable( const wxString& aLibraryPath ) override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//void SymbolLibOptions( PROPERTIES* aListToAppendTo ) const override;
|
||||
bool IsLibraryWritable( const wxString& aLibraryPath ) override { return false; }
|
||||
|
||||
wxString getLibName();
|
||||
wxFileName getLibFileName();
|
||||
|
@ -121,7 +121,7 @@ SCH_SHEET* SCH_IO_CADSTAR_ARCHIVE::LoadSchematicFile( const wxString& aFi
|
||||
if( !libTable->HasLibrary( libName ) )
|
||||
{
|
||||
// Create a new empty symbol library.
|
||||
sch_plugin->CreateSymbolLib( libFileName.GetFullPath() );
|
||||
sch_plugin->CreateLibrary( libFileName.GetFullPath() );
|
||||
wxString libTableUri = "${KIPRJMOD}/" + libFileName.GetFullName();
|
||||
|
||||
// Add the new library to the project symbol library table.
|
||||
@ -232,7 +232,7 @@ void SCH_IO_CADSTAR_ARCHIVE::GetAvailableSymbolFields( std::vector<wxString>& aN
|
||||
}
|
||||
|
||||
|
||||
void SCH_IO_CADSTAR_ARCHIVE::SymbolLibOptions( STRING_UTF8_MAP* aListToAppendTo ) const
|
||||
void SCH_IO_CADSTAR_ARCHIVE::GetLibraryOptions( STRING_UTF8_MAP* aListToAppendTo ) const
|
||||
{
|
||||
( *aListToAppendTo )["csa"] =
|
||||
UTF8( _( "Path to the CADSTAR schematic archive (*.csa) file related to this CADSTAR "
|
||||
|
@ -85,12 +85,9 @@ public:
|
||||
|
||||
|
||||
// Writing to CADSTAR libraries is not supported
|
||||
bool IsSymbolLibWritable( const wxString& aLibraryPath ) override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool IsLibraryWritable( const wxString& aLibraryPath ) override { return false; }
|
||||
|
||||
void SymbolLibOptions( STRING_UTF8_MAP* aListToAppendTo ) const override;
|
||||
void GetLibraryOptions( STRING_UTF8_MAP* aListToAppendTo ) const override;
|
||||
|
||||
private:
|
||||
// Symbol caching
|
||||
|
@ -73,10 +73,7 @@ public:
|
||||
void GetDefaultSymbolFields( std::vector<wxString>& aNames ) override;
|
||||
|
||||
// Database libraries can never be written using the symbol editing API
|
||||
bool IsSymbolLibWritable( const wxString& aLibraryPath ) override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool IsLibraryWritable( const wxString& aLibraryPath ) override { return false; }
|
||||
|
||||
void SetLibTable( SYMBOL_LIB_TABLE* aTable ) override
|
||||
{
|
||||
|
@ -463,7 +463,7 @@ SCH_SHEET* SCH_IO_EAGLE::LoadSchematicFile( const wxString& aFileName, SCHEMATIC
|
||||
if( !libTable->HasLibrary( getLibName() ) )
|
||||
{
|
||||
// Create a new empty symbol library.
|
||||
m_pi->CreateSymbolLib( getLibFileName().GetFullPath() );
|
||||
m_pi->CreateLibrary( getLibFileName().GetFullPath() );
|
||||
wxString libTableUri = wxT( "${KIPRJMOD}/" ) + getLibFileName().GetFullName();
|
||||
|
||||
// Add the new library to the project symbol library table.
|
||||
|
@ -114,7 +114,7 @@ public:
|
||||
LIB_SYMBOL* LoadSymbol( const wxString& aLibraryPath, const wxString& aAliasName,
|
||||
const STRING_UTF8_MAP* aProperties ) override;
|
||||
|
||||
bool IsSymbolLibWritable( const wxString& aLibraryPath ) override { return false; }
|
||||
bool IsLibraryWritable( const wxString& aLibraryPath ) override { return false; }
|
||||
|
||||
private:
|
||||
void checkpoint();
|
||||
|
@ -71,7 +71,7 @@ public:
|
||||
LIB_SYMBOL* LoadSymbol( const wxString& aLibraryPath, const wxString& aAliasName,
|
||||
const STRING_UTF8_MAP* aProperties = nullptr ) override;
|
||||
|
||||
bool IsSymbolLibWritable( const wxString& aLibraryPath ) override { return false; }
|
||||
bool IsLibraryWritable( const wxString& aLibraryPath ) override { return false; }
|
||||
};
|
||||
|
||||
|
||||
|
@ -546,7 +546,7 @@ SCH_SHEET* SCH_IO_EASYEDAPRO::LoadSchematicFile( const wxString& aFileName,
|
||||
if( !libTable->HasLibrary( libName ) )
|
||||
{
|
||||
// Create a new empty symbol library.
|
||||
sch_plugin->CreateSymbolLib( libFileName.GetFullPath() );
|
||||
sch_plugin->CreateLibrary( libFileName.GetFullPath() );
|
||||
wxString libTableUri = wxS( "${KIPRJMOD}/" ) + libFileName.GetFullName();
|
||||
|
||||
// Add the new library to the project symbol library table.
|
||||
|
@ -70,7 +70,7 @@ public:
|
||||
LIB_SYMBOL* LoadSymbol( const wxString& aLibraryPath, const wxString& aAliasName,
|
||||
const STRING_UTF8_MAP* aProperties = nullptr ) override;
|
||||
|
||||
bool IsSymbolLibWritable( const wxString& aLibraryPath ) override { return false; }
|
||||
bool IsLibraryWritable( const wxString& aLibraryPath ) override { return false; }
|
||||
|
||||
private:
|
||||
struct PRJ_DATA; // Opaque data structure
|
||||
|
@ -69,7 +69,7 @@ public:
|
||||
|
||||
void GetDefaultSymbolFields( std::vector<wxString>& aNames ) override;
|
||||
|
||||
bool IsSymbolLibWritable( const wxString& aLibraryPath ) override
|
||||
bool IsLibraryWritable( const wxString& aLibraryPath ) override
|
||||
{
|
||||
// TODO: HTTP libraries are well capabale of supporting this.
|
||||
return false;
|
||||
|
@ -2176,7 +2176,7 @@ void SCH_IO_KICAD_LEGACY::DeleteSymbol( const wxString& aLibraryPath, const wxSt
|
||||
}
|
||||
|
||||
|
||||
void SCH_IO_KICAD_LEGACY::CreateSymbolLib( const wxString& aLibraryPath,
|
||||
void SCH_IO_KICAD_LEGACY::CreateLibrary( const wxString& aLibraryPath,
|
||||
const STRING_UTF8_MAP* aProperties )
|
||||
{
|
||||
if( wxFileExists( aLibraryPath ) )
|
||||
@ -2195,7 +2195,7 @@ void SCH_IO_KICAD_LEGACY::CreateSymbolLib( const wxString& aLibraryPath,
|
||||
}
|
||||
|
||||
|
||||
bool SCH_IO_KICAD_LEGACY::DeleteSymbolLib( const wxString& aLibraryPath,
|
||||
bool SCH_IO_KICAD_LEGACY::DeleteLibrary( const wxString& aLibraryPath,
|
||||
const STRING_UTF8_MAP* aProperties )
|
||||
{
|
||||
wxFileName fn = aLibraryPath;
|
||||
@ -2258,7 +2258,7 @@ bool SCH_IO_KICAD_LEGACY::CanReadLibrary( const wxString& aFileName ) const
|
||||
}
|
||||
|
||||
|
||||
bool SCH_IO_KICAD_LEGACY::IsSymbolLibWritable( const wxString& aLibraryPath )
|
||||
bool SCH_IO_KICAD_LEGACY::IsLibraryWritable( const wxString& aLibraryPath )
|
||||
{
|
||||
// Writing legacy symbol libraries is deprecated.
|
||||
return false;
|
||||
|
@ -127,14 +127,14 @@ public:
|
||||
const STRING_UTF8_MAP* aProperties = nullptr ) override;
|
||||
void DeleteSymbol( const wxString& aLibraryPath, const wxString& aSymbolName,
|
||||
const STRING_UTF8_MAP* aProperties = nullptr ) override;
|
||||
void CreateSymbolLib( const wxString& aLibraryPath,
|
||||
const STRING_UTF8_MAP* aProperties = nullptr ) override;
|
||||
bool DeleteSymbolLib( const wxString& aLibraryPath,
|
||||
const STRING_UTF8_MAP* aProperties = nullptr ) override;
|
||||
void CreateLibrary( const wxString& aLibraryPath,
|
||||
const STRING_UTF8_MAP* aProperties = nullptr ) override;
|
||||
bool DeleteLibrary( const wxString& aLibraryPath,
|
||||
const STRING_UTF8_MAP* aProperties = nullptr ) override;
|
||||
void SaveLibrary( const wxString& aLibraryPath,
|
||||
const STRING_UTF8_MAP* aProperties = nullptr ) override;
|
||||
|
||||
bool IsSymbolLibWritable( const wxString& aLibraryPath ) override;
|
||||
bool IsLibraryWritable( const wxString& aLibraryPath ) override;
|
||||
|
||||
const wxString& GetError() const override { return m_error; }
|
||||
|
||||
|
@ -1535,7 +1535,7 @@ void SCH_IO_KICAD_SEXPR::DeleteSymbol( const wxString& aLibraryPath, const wxStr
|
||||
}
|
||||
|
||||
|
||||
void SCH_IO_KICAD_SEXPR::CreateSymbolLib( const wxString& aLibraryPath,
|
||||
void SCH_IO_KICAD_SEXPR::CreateLibrary( const wxString& aLibraryPath,
|
||||
const STRING_UTF8_MAP* aProperties )
|
||||
{
|
||||
if( wxFileExists( aLibraryPath ) )
|
||||
@ -1554,7 +1554,7 @@ void SCH_IO_KICAD_SEXPR::CreateSymbolLib( const wxString& aLibraryPath,
|
||||
}
|
||||
|
||||
|
||||
bool SCH_IO_KICAD_SEXPR::DeleteSymbolLib( const wxString& aLibraryPath,
|
||||
bool SCH_IO_KICAD_SEXPR::DeleteLibrary( const wxString& aLibraryPath,
|
||||
const STRING_UTF8_MAP* aProperties )
|
||||
{
|
||||
wxFileName fn = aLibraryPath;
|
||||
@ -1599,7 +1599,7 @@ void SCH_IO_KICAD_SEXPR::SaveLibrary( const wxString& aLibraryPath, const STRING
|
||||
}
|
||||
|
||||
|
||||
bool SCH_IO_KICAD_SEXPR::IsSymbolLibWritable( const wxString& aLibraryPath )
|
||||
bool SCH_IO_KICAD_SEXPR::IsLibraryWritable( const wxString& aLibraryPath )
|
||||
{
|
||||
wxFileName fn( aLibraryPath );
|
||||
|
||||
|
@ -117,14 +117,14 @@ public:
|
||||
const STRING_UTF8_MAP* aProperties = nullptr ) override;
|
||||
void DeleteSymbol( const wxString& aLibraryPath, const wxString& aSymbolName,
|
||||
const STRING_UTF8_MAP* aProperties = nullptr ) override;
|
||||
void CreateSymbolLib( const wxString& aLibraryPath,
|
||||
const STRING_UTF8_MAP* aProperties = nullptr ) override;
|
||||
bool DeleteSymbolLib( const wxString& aLibraryPath,
|
||||
const STRING_UTF8_MAP* aProperties = nullptr ) override;
|
||||
void CreateLibrary( const wxString& aLibraryPath,
|
||||
const STRING_UTF8_MAP* aProperties = nullptr ) override;
|
||||
bool DeleteLibrary( const wxString& aLibraryPath,
|
||||
const STRING_UTF8_MAP* aProperties = nullptr ) override;
|
||||
void SaveLibrary( const wxString& aLibraryPath,
|
||||
const STRING_UTF8_MAP* aProperties = nullptr ) override;
|
||||
|
||||
bool IsSymbolLibWritable( const wxString& aLibraryPath ) override;
|
||||
bool IsLibraryWritable( const wxString& aLibraryPath ) override;
|
||||
|
||||
void GetAvailableSymbolFields( std::vector<wxString>& aNames ) override;
|
||||
void GetDefaultSymbolFields( std::vector<wxString>& aNames ) override;
|
||||
|
@ -179,29 +179,11 @@ void SCH_IO::DeleteSymbol( const wxString& aLibraryPath, const wxString& aSymbol
|
||||
}
|
||||
|
||||
|
||||
void SCH_IO::CreateSymbolLib( const wxString& aLibraryPath, const STRING_UTF8_MAP* aProperties )
|
||||
void SCH_IO::GetLibraryOptions( STRING_UTF8_MAP* aListToAppendTo ) const
|
||||
{
|
||||
// not pure virtual so that plugins only have to implement subset of the SCH_IO interface.
|
||||
NOT_IMPLEMENTED( __FUNCTION__ );
|
||||
}
|
||||
// Get base options first
|
||||
IO_BASE::GetLibraryOptions( aListToAppendTo );
|
||||
|
||||
|
||||
bool SCH_IO::DeleteSymbolLib( const wxString& aLibraryPath, const STRING_UTF8_MAP* aProperties )
|
||||
{
|
||||
// not pure virtual so that plugins only have to implement subset of the SCH_IO interface.
|
||||
NOT_IMPLEMENTED( __FUNCTION__ );
|
||||
}
|
||||
|
||||
|
||||
bool SCH_IO::IsSymbolLibWritable( const wxString& aLibraryPath )
|
||||
{
|
||||
// not pure virtual so that plugins only have to implement subset of the SCH_IO interface.
|
||||
NOT_IMPLEMENTED( __FUNCTION__ );
|
||||
}
|
||||
|
||||
|
||||
void SCH_IO::SymbolLibOptions( STRING_UTF8_MAP* aListToAppendTo ) const
|
||||
{
|
||||
// Empty for most plugins
|
||||
//
|
||||
// To add a new option override and use example code below:
|
||||
|
@ -76,11 +76,7 @@ public:
|
||||
*/
|
||||
virtual bool CanReadSchematicFile( const wxString& aFileName ) const;
|
||||
|
||||
/**
|
||||
* Checks if this SCH_IO can read the specified symbol library file.
|
||||
* If not overriden, extension check is used.
|
||||
*/
|
||||
virtual bool CanReadLibrary( const wxString& aFileName ) const;
|
||||
bool CanReadLibrary( const wxString& aFileName ) const override;
|
||||
|
||||
/**
|
||||
* Return the modification hash from the library cache.
|
||||
@ -267,57 +263,6 @@ public:
|
||||
virtual void DeleteSymbol( const wxString& aLibraryPath, const wxString& aSymbolName,
|
||||
const STRING_UTF8_MAP* aProperties = nullptr );
|
||||
|
||||
/**
|
||||
* Create 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.
|
||||
*
|
||||
* @param aLibraryPath is a locator for the "library", usually a directory, file,
|
||||
* or URL containing several footprints.
|
||||
*
|
||||
* @param aProperties is an associative array that can be used to tell the library
|
||||
* create 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 library, or creating it.
|
||||
*/
|
||||
virtual void CreateSymbolLib( const wxString& aLibraryPath,
|
||||
const STRING_UTF8_MAP* aProperties = nullptr );
|
||||
|
||||
/**
|
||||
* Delete an existing symbol library and returns true if successful, 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 or file
|
||||
* which will contain symbols.
|
||||
*
|
||||
* @param aProperties is an associative array that can be used to tell the library
|
||||
* 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 true if library deleted or false if library did not exist.
|
||||
*
|
||||
* @throw IO_ERROR if there is a problem deleting an existing library.
|
||||
*/
|
||||
virtual bool DeleteSymbolLib( const wxString& aLibraryPath,
|
||||
const STRING_UTF8_MAP* aProperties = nullptr );
|
||||
|
||||
/**
|
||||
* Return true if the library at \a aLibraryPath is writable. (Often
|
||||
* system libraries are read only because of where they are installed.)
|
||||
*
|
||||
* @param aLibraryPath is a locator for the "library", usually a directory, file,
|
||||
* or URL containing several symbols.
|
||||
*
|
||||
* @throw IO_ERROR if no library at aLibraryPath exists.
|
||||
*/
|
||||
virtual bool IsSymbolLibWritable( const wxString& aLibraryPath );
|
||||
|
||||
/**
|
||||
* Append supported #SCH_IO options to \a aListToAppenTo along with internationalized
|
||||
* descriptions. Options are typically appended so that a derived SCH_IO can call
|
||||
@ -342,7 +287,7 @@ public:
|
||||
* This would require a 3 column list, and introducing wx GUI knowledge to
|
||||
* #SCH_IO, which has been avoided to date.
|
||||
*/
|
||||
virtual void SymbolLibOptions( STRING_UTF8_MAP* aListToAppendTo ) const;
|
||||
virtual void GetLibraryOptions( STRING_UTF8_MAP* aListToAppendTo ) const override;
|
||||
|
||||
/**
|
||||
* @return true if this plugin supports libraries that contain sub-libraries.
|
||||
|
@ -215,7 +215,7 @@ void SYMBOL_EDIT_FRAME::ExportSymbol()
|
||||
try
|
||||
{
|
||||
if( !fn.FileExists() )
|
||||
pi->CreateSymbolLib( fn.GetFullPath() );
|
||||
pi->CreateLibrary( fn.GetFullPath() );
|
||||
|
||||
// The flattened symbol is most likely what the user would want. As some point in
|
||||
// the future as more of the symbol library inheritance is implemented, this may have
|
||||
|
@ -446,7 +446,7 @@ SYMBOL_LIB_TABLE::SAVE_T SYMBOL_LIB_TABLE::SaveSymbol( const wxString& aNickname
|
||||
const SYMBOL_LIB_TABLE_ROW* row = FindRow( aNickname, true );
|
||||
wxCHECK( row && row->plugin, SAVE_SKIPPED );
|
||||
|
||||
if( !row->plugin->IsSymbolLibWritable( row->GetFullURI( true ) ) )
|
||||
if( !row->plugin->IsLibraryWritable( row->GetFullURI( true ) ) )
|
||||
return SAVE_SKIPPED;
|
||||
|
||||
if( !aOverwrite )
|
||||
@ -488,7 +488,7 @@ bool SYMBOL_LIB_TABLE::IsSymbolLibWritable( const wxString& aNickname )
|
||||
{
|
||||
const SYMBOL_LIB_TABLE_ROW* row = FindRow( aNickname, true );
|
||||
wxCHECK( row && row->plugin, false );
|
||||
return row->plugin->IsSymbolLibWritable( row->GetFullURI( true ) );
|
||||
return row->plugin->IsLibraryWritable( row->GetFullURI( true ) );
|
||||
}
|
||||
|
||||
bool SYMBOL_LIB_TABLE::IsSymbolLibLoaded( const wxString& aNickname )
|
||||
@ -503,7 +503,7 @@ void SYMBOL_LIB_TABLE::DeleteSymbolLib( const wxString& aNickname )
|
||||
{
|
||||
const SYMBOL_LIB_TABLE_ROW* row = FindRow( aNickname, true );
|
||||
wxCHECK( row && row->plugin, /* void */ );
|
||||
row->plugin->DeleteSymbolLib( row->GetFullURI( true ), row->GetProperties() );
|
||||
row->plugin->DeleteLibrary( row->GetFullURI( true ), row->GetProperties() );
|
||||
}
|
||||
|
||||
|
||||
@ -511,7 +511,7 @@ void SYMBOL_LIB_TABLE::CreateSymbolLib( const wxString& aNickname )
|
||||
{
|
||||
const SYMBOL_LIB_TABLE_ROW* row = FindRow( aNickname, true );
|
||||
wxCHECK( row && row->plugin, /* void */ );
|
||||
row->plugin->CreateSymbolLib( row->GetFullURI( true ), row->GetProperties() );
|
||||
row->plugin->CreateLibrary( row->GetFullURI( true ), row->GetProperties() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -95,7 +95,7 @@ void SYMBOL_LIB::Create( const wxString& aFileName )
|
||||
if( !aFileName.IsEmpty() )
|
||||
tmpFileName = aFileName;
|
||||
|
||||
m_plugin->CreateSymbolLib( tmpFileName, m_properties.get() );
|
||||
m_plugin->CreateLibrary( tmpFileName, m_properties.get() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
class REPORTER;
|
||||
class PROGRESS_REPORTER;
|
||||
class STRING_UTF8_MAP;
|
||||
|
||||
class IO_BASE
|
||||
{
|
||||
@ -47,6 +48,97 @@ public:
|
||||
*/
|
||||
virtual void SetProgressReporter( PROGRESS_REPORTER* aReporter ) { m_progressReporter = aReporter; }
|
||||
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
// Library-related functions
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Checks if this IO object can read the specified library file/directory.
|
||||
* If not overriden, extension check is used.
|
||||
*
|
||||
* @note This is not a check that the file system object is readable by the user,
|
||||
* but a check that this IO object can parse the given library.
|
||||
*/
|
||||
virtual bool CanReadLibrary( const wxString& aFileName ) const;
|
||||
|
||||
/**
|
||||
* Create a new empty library at @a aLibraryPath empty.
|
||||
*
|
||||
* It is an error to attempt to create an existing library or to attempt to create
|
||||
* on a "read only" location.
|
||||
*
|
||||
* @param aLibraryPath is a locator for the "library", usually a directory, file, or URL
|
||||
* containing several elements.
|
||||
* @param aProperties is an associative array that can be used to tell the library create
|
||||
* function anything special, because it can take any number of additional
|
||||
* named tuning arguments that the IO is known to support. The caller
|
||||
* continues to own this object (IO may not delete it), and IOs
|
||||
* should expect it to be optionally NULL.
|
||||
*
|
||||
* @throw IO_ERROR if there is a problem finding the library, or creating it.
|
||||
*/
|
||||
virtual void CreateLibrary( const wxString& aLibraryPath,
|
||||
const STRING_UTF8_MAP* aProperties = nullptr );
|
||||
|
||||
/**
|
||||
* Delete an existing 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 or file which
|
||||
* will contain several elements.
|
||||
* @param aProperties is an associative array that can be used to tell the library 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 true if library deleted, false if library did not exist.
|
||||
*
|
||||
* @throw IO_ERROR if there is a problem deleting an existing library.
|
||||
*/
|
||||
virtual bool DeleteLibrary( const wxString& aLibraryPath,
|
||||
const STRING_UTF8_MAP* aProperties = nullptr );
|
||||
|
||||
/**
|
||||
* Return true if the library at @a aLibraryPath is writable.
|
||||
*
|
||||
* The system libraries are typically read only because of where they are installed..
|
||||
*
|
||||
* @param aLibraryPath is a locator for the "library", usually a directory, file, or URL
|
||||
* containing several footprints.
|
||||
*
|
||||
* @throw IO_ERROR if no library at aLibraryPath exists.
|
||||
*/
|
||||
virtual bool IsLibraryWritable( const wxString& aLibraryPath );
|
||||
|
||||
/**
|
||||
* Append supported IO options to \a aListToAppenTo along with internationalized
|
||||
* descriptions. Options are typically appended so that a derived IO_BASE can call
|
||||
* its base class function by the same name first, thus inheriting options declared there.
|
||||
* (Some base class options could pertain to all functions in all derived IOs.)
|
||||
* Note that since aListToAppendTo is a PROPERTIES object, all options
|
||||
* will be unique and last guy wins.
|
||||
*
|
||||
* @param aListToAppendTo holds a tuple of
|
||||
* <dl>
|
||||
* <dt>option</dt>
|
||||
* <dd>This eventually is what shows up into the "options"
|
||||
* field, possibly combined with others.</dd>
|
||||
* <dt>internationalized description</dt>
|
||||
* <dd>The internationalized description is displayed in DIALOG_PLUGIN_OPTIONS.
|
||||
* It may be multi-line and be quite explanatory of the option.</dd>
|
||||
* </dl>
|
||||
* <br>
|
||||
* In the future perhaps \a aListToAppendTo evolves to something capable of also
|
||||
* holding a wxValidator for the cells in said dialog:
|
||||
* http://forums.wxwidgets.org/viewtopic.php?t=23277&p=104180.
|
||||
* This would require a 3 column list, and introducing wx GUI knowledge to
|
||||
* #SCH_IO, which has been avoided to date.
|
||||
*/
|
||||
virtual void GetLibraryOptions( STRING_UTF8_MAP* aListToAppendTo ) const;
|
||||
|
||||
protected:
|
||||
// Delete the zero-argument base constructor to force proper construction
|
||||
IO_BASE() = delete;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user