diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt
index b6a1f62803..30ac1d47af 100644
--- a/common/CMakeLists.txt
+++ b/common/CMakeLists.txt
@@ -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
diff --git a/common/fp_lib_table.cpp b/common/fp_lib_table.cpp
index 31a10e2de7..0ed088046c 100644
--- a/common/fp_lib_table.cpp
+++ b/common/fp_lib_table.cpp
@@ -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() );
}
diff --git a/common/io/io_base.cpp b/common/io/io_base.cpp
new file mode 100644
index 0000000000..e0be02a158
--- /dev/null
+++ b/common/io/io_base.cpp
@@ -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 .
+ */
+
+
+#include
+#include
+
+#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;
+}
diff --git a/eeschema/dialogs/panel_sym_lib_table.cpp b/eeschema/dialogs/panel_sym_lib_table.cpp
index 1524b9eff9..ca622db000 100644
--- a/eeschema/dialogs/panel_sym_lib_table.cpp
+++ b/eeschema/dialogs/panel_sym_lib_table.cpp
@@ -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();
diff --git a/eeschema/sch_io/altium/sch_io_altium.cpp b/eeschema/sch_io/altium/sch_io_altium.cpp
index fab3fed566..1102ece612 100644
--- a/eeschema/sch_io/altium/sch_io_altium.cpp
+++ b/eeschema/sch_io/altium/sch_io_altium.cpp
@@ -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.
diff --git a/eeschema/sch_io/altium/sch_io_altium.h b/eeschema/sch_io/altium/sch_io_altium.h
index 93b6f8eec3..1c546684a7 100644
--- a/eeschema/sch_io/altium/sch_io_altium.h
+++ b/eeschema/sch_io/altium/sch_io_altium.h
@@ -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();
diff --git a/eeschema/sch_io/cadstar/sch_io_cadstar_archive.cpp b/eeschema/sch_io/cadstar/sch_io_cadstar_archive.cpp
index 35b63d5cdb..0be4181db3 100644
--- a/eeschema/sch_io/cadstar/sch_io_cadstar_archive.cpp
+++ b/eeschema/sch_io/cadstar/sch_io_cadstar_archive.cpp
@@ -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& 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 "
diff --git a/eeschema/sch_io/cadstar/sch_io_cadstar_archive.h b/eeschema/sch_io/cadstar/sch_io_cadstar_archive.h
index 75139e2413..8716f579cf 100644
--- a/eeschema/sch_io/cadstar/sch_io_cadstar_archive.h
+++ b/eeschema/sch_io/cadstar/sch_io_cadstar_archive.h
@@ -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
diff --git a/eeschema/sch_io/database/sch_io_database.h b/eeschema/sch_io/database/sch_io_database.h
index 8302f2bbc5..75903fae34 100644
--- a/eeschema/sch_io/database/sch_io_database.h
+++ b/eeschema/sch_io/database/sch_io_database.h
@@ -73,10 +73,7 @@ public:
void GetDefaultSymbolFields( std::vector& 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
{
diff --git a/eeschema/sch_io/eagle/sch_io_eagle.cpp b/eeschema/sch_io/eagle/sch_io_eagle.cpp
index 3b0ab6872c..6d7352a37a 100644
--- a/eeschema/sch_io/eagle/sch_io_eagle.cpp
+++ b/eeschema/sch_io/eagle/sch_io_eagle.cpp
@@ -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.
diff --git a/eeschema/sch_io/eagle/sch_io_eagle.h b/eeschema/sch_io/eagle/sch_io_eagle.h
index dbb48e80a5..a25c8dd6f5 100644
--- a/eeschema/sch_io/eagle/sch_io_eagle.h
+++ b/eeschema/sch_io/eagle/sch_io_eagle.h
@@ -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();
diff --git a/eeschema/sch_io/easyeda/sch_io_easyeda.h b/eeschema/sch_io/easyeda/sch_io_easyeda.h
index 55e3d635ed..ccd31c8f84 100644
--- a/eeschema/sch_io/easyeda/sch_io_easyeda.h
+++ b/eeschema/sch_io/easyeda/sch_io_easyeda.h
@@ -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; }
};
diff --git a/eeschema/sch_io/easyedapro/sch_io_easyedapro.cpp b/eeschema/sch_io/easyedapro/sch_io_easyedapro.cpp
index 2f20345d7e..c979138664 100644
--- a/eeschema/sch_io/easyedapro/sch_io_easyedapro.cpp
+++ b/eeschema/sch_io/easyedapro/sch_io_easyedapro.cpp
@@ -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.
diff --git a/eeschema/sch_io/easyedapro/sch_io_easyedapro.h b/eeschema/sch_io/easyedapro/sch_io_easyedapro.h
index 3f84a480ea..096a9a2a39 100644
--- a/eeschema/sch_io/easyedapro/sch_io_easyedapro.h
+++ b/eeschema/sch_io/easyedapro/sch_io_easyedapro.h
@@ -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
diff --git a/eeschema/sch_io/http_lib/sch_io_http_lib.h b/eeschema/sch_io/http_lib/sch_io_http_lib.h
index 182fa6fcbd..c143fb6d37 100644
--- a/eeschema/sch_io/http_lib/sch_io_http_lib.h
+++ b/eeschema/sch_io/http_lib/sch_io_http_lib.h
@@ -69,7 +69,7 @@ public:
void GetDefaultSymbolFields( std::vector& 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;
diff --git a/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy.cpp b/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy.cpp
index 0ad18c8ef5..9789706145 100644
--- a/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy.cpp
+++ b/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy.cpp
@@ -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;
diff --git a/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy.h b/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy.h
index daca0c59cd..fa38970958 100644
--- a/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy.h
+++ b/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy.h
@@ -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; }
diff --git a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr.cpp b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr.cpp
index 51d8324eab..48c8cc93ee 100644
--- a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr.cpp
+++ b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr.cpp
@@ -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 );
diff --git a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr.h b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr.h
index 228afe95d7..26817fe0f8 100644
--- a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr.h
+++ b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr.h
@@ -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& aNames ) override;
void GetDefaultSymbolFields( std::vector& aNames ) override;
diff --git a/eeschema/sch_io/sch_io.cpp b/eeschema/sch_io/sch_io.cpp
index 40c76c8bc7..af905f36eb 100644
--- a/eeschema/sch_io/sch_io.cpp
+++ b/eeschema/sch_io/sch_io.cpp
@@ -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:
diff --git a/eeschema/sch_io/sch_io.h b/eeschema/sch_io/sch_io.h
index efaadcd8ba..f2dbd4c001 100644
--- a/eeschema/sch_io/sch_io.h
+++ b/eeschema/sch_io/sch_io.h
@@ -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.
diff --git a/eeschema/symbol_editor/symbol_editor_import_export.cpp b/eeschema/symbol_editor/symbol_editor_import_export.cpp
index e6ccbac191..01f99470d9 100644
--- a/eeschema/symbol_editor/symbol_editor_import_export.cpp
+++ b/eeschema/symbol_editor/symbol_editor_import_export.cpp
@@ -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
diff --git a/eeschema/symbol_lib_table.cpp b/eeschema/symbol_lib_table.cpp
index 5e23615353..1a86660498 100644
--- a/eeschema/symbol_lib_table.cpp
+++ b/eeschema/symbol_lib_table.cpp
@@ -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() );
}
diff --git a/eeschema/symbol_library.cpp b/eeschema/symbol_library.cpp
index c64641066b..8654f95e59 100644
--- a/eeschema/symbol_library.cpp
+++ b/eeschema/symbol_library.cpp
@@ -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() );
}
diff --git a/include/io/io_base.h b/include/io/io_base.h
index 8fff99a2b2..69efc11f76 100644
--- a/include/io/io_base.h
+++ b/include/io/io_base.h
@@ -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
+ *
+ * - option
+ * - This eventually is what shows up into the "options"
+ * field, possibly combined with others.
+ * - internationalized description
+ * - The internationalized description is displayed in DIALOG_PLUGIN_OPTIONS.
+ * It may be multi-line and be quite explanatory of the option.
+ *
+ *
+ * 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;
diff --git a/pcbnew/dialogs/panel_fp_lib_table.cpp b/pcbnew/dialogs/panel_fp_lib_table.cpp
index ce6620f22b..4e27685392 100644
--- a/pcbnew/dialogs/panel_fp_lib_table.cpp
+++ b/pcbnew/dialogs/panel_fp_lib_table.cpp
@@ -241,7 +241,7 @@ protected:
PCB_IO_MGR::PCB_FILE_T pi_type = PCB_IO_MGR::EnumFromStr( row->GetType() );
PCB_IO::RELEASER pi( PCB_IO_MGR::PluginFind( pi_type ) );
- pi->FootprintLibOptions( &choices );
+ pi->GetLibraryOptions( &choices );
DIALOG_PLUGIN_OPTIONS dlg( m_dialog, row->GetNickName(), choices, options, &result );
dlg.ShowModal();
diff --git a/pcbnew/footprint_edit_frame.h b/pcbnew/footprint_edit_frame.h
index c0bda0710a..65a92e0232 100644
--- a/pcbnew/footprint_edit_frame.h
+++ b/pcbnew/footprint_edit_frame.h
@@ -145,7 +145,7 @@ public:
/**
* Save a library to a new name and/or library type.
*
- * @see #PLUGIN::FootprintSave and #PLUGIN::FootprintLibCreate
+ * @see #PCB_IO::FootprintSave and #IO_BASE::LibraryCreate
*
* @note Saving as a new library type requires the plug-in to support saving libraries
*/
diff --git a/pcbnew/footprint_libraries_utils.cpp b/pcbnew/footprint_libraries_utils.cpp
index a0f62daf7c..b71e555b1b 100644
--- a/pcbnew/footprint_libraries_utils.cpp
+++ b/pcbnew/footprint_libraries_utils.cpp
@@ -353,7 +353,7 @@ wxString PCB_BASE_EDIT_FRAME::createNewLibrary( const wxString& aLibName,
try
{
- writable = pi->IsFootprintLibWritable( libPath );
+ writable = pi->IsLibraryWritable( libPath );
exists = true; // no exception was thrown, lib must exist.
}
catch( const IO_ERROR& )
@@ -379,11 +379,11 @@ wxString PCB_BASE_EDIT_FRAME::createNewLibrary( const wxString& aLibName,
if( dlg.ShowModal() == wxID_CANCEL )
return wxEmptyString;
- pi->FootprintLibDelete( libPath );
+ pi->DeleteLibrary( libPath );
}
}
- pi->FootprintLibCreate( libPath );
+ pi->CreateLibrary( libPath );
}
catch( const IO_ERROR& ioe )
{
diff --git a/pcbnew/pcb_io/altium/pcb_io_altium_designer.cpp b/pcbnew/pcb_io/altium/pcb_io_altium_designer.cpp
index ec17e39522..9893058791 100644
--- a/pcbnew/pcb_io/altium/pcb_io_altium_designer.cpp
+++ b/pcbnew/pcb_io/altium/pcb_io_altium_designer.cpp
@@ -65,9 +65,9 @@ bool PCB_IO_ALTIUM_DESIGNER::CanReadBoard( const wxString& aFileName ) const
}
-bool PCB_IO_ALTIUM_DESIGNER::CanReadFootprintLib( const wxString& aFileName ) const
+bool PCB_IO_ALTIUM_DESIGNER::CanReadLibrary( const wxString& aFileName ) const
{
- if( !PCB_IO::CanReadFootprintLib( aFileName ) )
+ if( !PCB_IO::CanReadLibrary( aFileName ) )
return false;
return checkFileHeader( aFileName );
diff --git a/pcbnew/pcb_io/altium/pcb_io_altium_designer.h b/pcbnew/pcb_io/altium/pcb_io_altium_designer.h
index b3a24c423d..91b455bce0 100644
--- a/pcbnew/pcb_io/altium/pcb_io_altium_designer.h
+++ b/pcbnew/pcb_io/altium/pcb_io_altium_designer.h
@@ -51,7 +51,7 @@ public:
PLUGIN_FILE_DESC GetFootprintFileDesc() const override { return GetFootprintLibDesc(); }
bool CanReadBoard( const wxString& aFileName ) const override;
- bool CanReadFootprintLib( const wxString& aFileName ) const override;
+ bool CanReadLibrary( const wxString& aFileName ) const override;
BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
const STRING_UTF8_MAP* aProperties, PROJECT* aProject = nullptr,
@@ -68,7 +68,7 @@ public:
//bool FootprintExists( const wxString& aLibraryPath, const wxString& aFootprintName, const PROPERTIES* aProperties = nullptr );
- bool IsFootprintLibWritable( const wxString& aLibraryPath ) override { return false; }
+ bool IsLibraryWritable( const wxString& aLibraryPath ) override { return false; }
// ------------------------------------------------------
diff --git a/pcbnew/pcb_io/cadstar/pcb_io_cadstar_archive.cpp b/pcbnew/pcb_io/cadstar/pcb_io_cadstar_archive.cpp
index a57213a117..e8ffa58528 100644
--- a/pcbnew/pcb_io/cadstar/pcb_io_cadstar_archive.cpp
+++ b/pcbnew/pcb_io/cadstar/pcb_io_cadstar_archive.cpp
@@ -151,9 +151,9 @@ bool PCB_IO_CADSTAR_ARCHIVE::CanReadBoard( const wxString& aFileName ) const
}
-bool PCB_IO_CADSTAR_ARCHIVE::CanReadFootprintLib( const wxString& aFileName ) const
+bool PCB_IO_CADSTAR_ARCHIVE::CanReadLibrary( const wxString& aFileName ) const
{
- if( !PCB_IO::CanReadFootprintLib( aFileName ) )
+ if( !PCB_IO::CanReadLibrary( aFileName ) )
return false;
return checkBoardHeader( aFileName );
diff --git a/pcbnew/pcb_io/cadstar/pcb_io_cadstar_archive.h b/pcbnew/pcb_io/cadstar/pcb_io_cadstar_archive.h
index b4be8e6530..caca508078 100644
--- a/pcbnew/pcb_io/cadstar/pcb_io_cadstar_archive.h
+++ b/pcbnew/pcb_io/cadstar/pcb_io_cadstar_archive.h
@@ -42,7 +42,7 @@ public:
PLUGIN_FILE_DESC GetFootprintFileDesc() const override { return GetFootprintLibDesc(); }
bool CanReadBoard( const wxString& aFileName ) const override;
- bool CanReadFootprintLib( const wxString& aFileName ) const override;
+ bool CanReadLibrary( const wxString& aFileName ) const override;
bool CanReadFootprint( const wxString& aFileName ) const override;
BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
@@ -85,7 +85,7 @@ public:
* CADSTAR Plugin is read-only
* @return Always false
*/
- bool IsFootprintLibWritable( const wxString& aLibraryPath ) override { return false; }
+ bool IsLibraryWritable( const wxString& aLibraryPath ) override { return false; }
PCB_IO_CADSTAR_ARCHIVE();
~PCB_IO_CADSTAR_ARCHIVE();
diff --git a/pcbnew/pcb_io/eagle/pcb_io_eagle.cpp b/pcbnew/pcb_io/eagle/pcb_io_eagle.cpp
index 1be4f8cfbb..68120e2c1c 100644
--- a/pcbnew/pcb_io/eagle/pcb_io_eagle.cpp
+++ b/pcbnew/pcb_io/eagle/pcb_io_eagle.cpp
@@ -255,9 +255,9 @@ bool PCB_IO_EAGLE::CanReadBoard( const wxString& aFileName ) const
}
-bool PCB_IO_EAGLE::CanReadFootprintLib( const wxString& aFileName ) const
+bool PCB_IO_EAGLE::CanReadLibrary( const wxString& aFileName ) const
{
- if( !PCB_IO::CanReadFootprintLib( aFileName ) )
+ if( !PCB_IO::CanReadLibrary( aFileName ) )
return false;
return checkHeader( aFileName );
@@ -266,7 +266,7 @@ bool PCB_IO_EAGLE::CanReadFootprintLib( const wxString& aFileName ) const
bool PCB_IO_EAGLE::CanReadFootprint( const wxString& aFileName ) const
{
- return CanReadFootprintLib( aFileName );
+ return CanReadLibrary( aFileName );
}
@@ -3225,11 +3225,6 @@ FOOTPRINT* PCB_IO_EAGLE::FootprintLoad( const wxString& aLibraryPath,
}
-void PCB_IO_EAGLE::FootprintLibOptions( STRING_UTF8_MAP* aListToAppendTo ) const
-{
- PCB_IO::FootprintLibOptions( aListToAppendTo );
-}
-
int PCB_IO_EAGLE::getMinimumCopperLayerCount() const
{
int minLayerCount = 2;
diff --git a/pcbnew/pcb_io/eagle/pcb_io_eagle.h b/pcbnew/pcb_io/eagle/pcb_io_eagle.h
index f276a4801f..7d0866dc5a 100644
--- a/pcbnew/pcb_io/eagle/pcb_io_eagle.h
+++ b/pcbnew/pcb_io/eagle/pcb_io_eagle.h
@@ -144,7 +144,7 @@ public:
PLUGIN_FILE_DESC GetFootprintFileDesc() const override { return GetFootprintLibDesc(); }
bool CanReadBoard( const wxString& aFileName ) const override;
- bool CanReadFootprintLib( const wxString& aFileName ) const override;
+ bool CanReadLibrary( const wxString& aFileName ) const override;
bool CanReadFootprint( const wxString& aFileName ) const override;
BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
@@ -165,13 +165,11 @@ public:
return getModificationTime( aLibraryPath ).GetValue().GetValue();
}
- bool IsFootprintLibWritable( const wxString& aLibraryPath ) override
+ bool IsLibraryWritable( const wxString& aLibraryPath ) override
{
return false; // until someone writes others like FootprintSave(), etc.
}
- void FootprintLibOptions( STRING_UTF8_MAP* aProperties ) const override;
-
typedef int BIU;
PCB_IO_EAGLE();
diff --git a/pcbnew/pcb_io/easyeda/pcb_io_easyeda_plugin.cpp b/pcbnew/pcb_io/easyeda/pcb_io_easyeda_plugin.cpp
index 51888bdba4..896d4dac85 100644
--- a/pcbnew/pcb_io/easyeda/pcb_io_easyeda_plugin.cpp
+++ b/pcbnew/pcb_io/easyeda/pcb_io_easyeda_plugin.cpp
@@ -126,7 +126,7 @@ bool PCB_IO_EASYEDA::CanReadFootprint( const wxString& aFileName ) const
}
-bool PCB_IO_EASYEDA::CanReadFootprintLib( const wxString& aFileName ) const
+bool PCB_IO_EASYEDA::CanReadLibrary( const wxString& aFileName ) const
{
return CanReadBoard( aFileName );
}
diff --git a/pcbnew/pcb_io/easyeda/pcb_io_easyeda_plugin.h b/pcbnew/pcb_io/easyeda/pcb_io_easyeda_plugin.h
index 5a804bc63a..a5f8a01bae 100644
--- a/pcbnew/pcb_io/easyeda/pcb_io_easyeda_plugin.h
+++ b/pcbnew/pcb_io/easyeda/pcb_io_easyeda_plugin.h
@@ -45,7 +45,7 @@ public:
bool CanReadFootprint( const wxString& aFileName ) const override;
- bool CanReadFootprintLib( const wxString& aFileName ) const override;
+ bool CanReadLibrary( const wxString& aFileName ) const override;
BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
const STRING_UTF8_MAP* aProperties = nullptr, PROJECT* aProject = nullptr,
@@ -63,7 +63,7 @@ public:
bool aKeepUUID = false,
const STRING_UTF8_MAP* aProperties = nullptr ) override;
- bool IsFootprintLibWritable( const wxString& aLibraryPath ) override { return false; }
+ bool IsLibraryWritable( const wxString& aLibraryPath ) override { return false; }
PCB_IO_EASYEDA();
~PCB_IO_EASYEDA();
diff --git a/pcbnew/pcb_io/easyedapro/pcb_io_easyedapro.h b/pcbnew/pcb_io/easyedapro/pcb_io_easyedapro.h
index f5f54a2bac..57efadfe8e 100644
--- a/pcbnew/pcb_io/easyedapro/pcb_io_easyedapro.h
+++ b/pcbnew/pcb_io/easyedapro/pcb_io_easyedapro.h
@@ -70,7 +70,7 @@ public:
bool aKeepUUID = false,
const STRING_UTF8_MAP* aProperties = nullptr ) override;
- bool IsFootprintLibWritable( const wxString& aLibraryPath ) override { return false; }
+ bool IsLibraryWritable( const wxString& aLibraryPath ) override { return false; }
PCB_IO_EASYEDAPRO();
~PCB_IO_EASYEDAPRO();
diff --git a/pcbnew/pcb_io/geda/pcb_io_geda.cpp b/pcbnew/pcb_io/geda/pcb_io_geda.cpp
index 4a1267af7a..2e9d2c0b5f 100644
--- a/pcbnew/pcb_io/geda/pcb_io_geda.cpp
+++ b/pcbnew/pcb_io/geda/pcb_io_geda.cpp
@@ -965,7 +965,7 @@ void PCB_IO_GEDA::FootprintDelete( const wxString& aLibraryPath, const wxString&
}
-bool PCB_IO_GEDA::FootprintLibDelete( const wxString& aLibraryPath, const STRING_UTF8_MAP* aProperties )
+bool PCB_IO_GEDA::DeleteLibrary( const wxString& aLibraryPath, const STRING_UTF8_MAP* aProperties )
{
wxFileName fn;
fn.SetPath( aLibraryPath );
@@ -1049,7 +1049,7 @@ long long PCB_IO_GEDA::GetLibraryTimestamp( const wxString& aLibraryPath ) const
}
-bool PCB_IO_GEDA::IsFootprintLibWritable( const wxString& aLibraryPath )
+bool PCB_IO_GEDA::IsLibraryWritable( const wxString& aLibraryPath )
{
LOCALE_IO toggle;
diff --git a/pcbnew/pcb_io/geda/pcb_io_geda.h b/pcbnew/pcb_io/geda/pcb_io_geda.h
index 015ccad88a..0a71e88c06 100644
--- a/pcbnew/pcb_io/geda/pcb_io_geda.h
+++ b/pcbnew/pcb_io/geda/pcb_io_geda.h
@@ -76,12 +76,12 @@ public:
void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
const STRING_UTF8_MAP* aProperties = nullptr ) override;
- bool FootprintLibDelete( const wxString& aLibraryPath,
- const STRING_UTF8_MAP* aProperties = nullptr ) override;
+ bool DeleteLibrary( const wxString& aLibraryPath,
+ const STRING_UTF8_MAP* aProperties = nullptr ) override;
long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override;
- bool IsFootprintLibWritable( const wxString& aLibraryPath ) override;
+ bool IsLibraryWritable( const wxString& aLibraryPath ) override;
//-------------------------------------------------------------
diff --git a/pcbnew/pcb_io/ipc2581/pcb_io_ipc2581.h b/pcbnew/pcb_io/ipc2581/pcb_io_ipc2581.h
index b9f7384055..6802997d1e 100644
--- a/pcbnew/pcb_io/ipc2581/pcb_io_ipc2581.h
+++ b/pcbnew/pcb_io/ipc2581/pcb_io_ipc2581.h
@@ -109,7 +109,7 @@ public:
}
// Reading currently disabled
- bool CanReadFootprintLib( const wxString& aFileName ) const override
+ bool CanReadLibrary( const wxString& aFileName ) const override
{
return false;
}
diff --git a/pcbnew/pcb_io/kicad_legacy/pcb_io_kicad_legacy.cpp b/pcbnew/pcb_io/kicad_legacy/pcb_io_kicad_legacy.cpp
index b71c7cba9b..b0f20f4c44 100644
--- a/pcbnew/pcb_io/kicad_legacy/pcb_io_kicad_legacy.cpp
+++ b/pcbnew/pcb_io/kicad_legacy/pcb_io_kicad_legacy.cpp
@@ -3245,8 +3245,8 @@ FOOTPRINT* PCB_IO_KICAD_LEGACY::FootprintLoad( const wxString& aLibraryPath,
}
-bool PCB_IO_KICAD_LEGACY::FootprintLibDelete( const wxString& aLibraryPath,
- const STRING_UTF8_MAP* aProperties )
+bool PCB_IO_KICAD_LEGACY::DeleteLibrary( const wxString& aLibraryPath,
+ const STRING_UTF8_MAP* aProperties )
{
wxFileName fn = aLibraryPath;
@@ -3271,7 +3271,7 @@ bool PCB_IO_KICAD_LEGACY::FootprintLibDelete( const wxString& aLibraryPath,
}
-bool PCB_IO_KICAD_LEGACY::IsFootprintLibWritable( const wxString& aLibraryPath )
+bool PCB_IO_KICAD_LEGACY::IsLibraryWritable( const wxString& aLibraryPath )
{
#if 0 // no support for 32 Cu layers in legacy format
return false;
diff --git a/pcbnew/pcb_io/kicad_legacy/pcb_io_kicad_legacy.h b/pcbnew/pcb_io/kicad_legacy/pcb_io_kicad_legacy.h
index a0b6c30b9a..1a376f1c4e 100644
--- a/pcbnew/pcb_io/kicad_legacy/pcb_io_kicad_legacy.h
+++ b/pcbnew/pcb_io/kicad_legacy/pcb_io_kicad_legacy.h
@@ -93,12 +93,12 @@ public:
bool aKeepUUID = false,
const STRING_UTF8_MAP* aProperties = nullptr ) override;
- bool FootprintLibDelete( const wxString& aLibraryPath,
- const STRING_UTF8_MAP* aProperties = nullptr ) override;
+ bool DeleteLibrary( const wxString& aLibraryPath,
+ const STRING_UTF8_MAP* aProperties = nullptr ) override;
long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override;
- bool IsFootprintLibWritable( const wxString& aLibraryPath ) override;
+ bool IsLibraryWritable( const wxString& aLibraryPath ) override;
typedef int BIU;
diff --git a/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.cpp b/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.cpp
index 37695011d8..78ba1699b8 100644
--- a/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.cpp
+++ b/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.cpp
@@ -2746,7 +2746,7 @@ long long PCB_IO_KICAD_SEXPR::GetLibraryTimestamp( const wxString& aLibraryPath
}
-void PCB_IO_KICAD_SEXPR::FootprintLibCreate( const wxString& aLibraryPath, const STRING_UTF8_MAP* aProperties )
+void PCB_IO_KICAD_SEXPR::CreateLibrary( const wxString& aLibraryPath, const STRING_UTF8_MAP* aProperties )
{
if( wxDir::Exists( aLibraryPath ) )
{
@@ -2764,7 +2764,7 @@ void PCB_IO_KICAD_SEXPR::FootprintLibCreate( const wxString& aLibraryPath, const
}
-bool PCB_IO_KICAD_SEXPR::FootprintLibDelete( const wxString& aLibraryPath, const STRING_UTF8_MAP* aProperties )
+bool PCB_IO_KICAD_SEXPR::DeleteLibrary( const wxString& aLibraryPath, const STRING_UTF8_MAP* aProperties )
{
wxFileName fn;
fn.SetPath( aLibraryPath );
@@ -2841,7 +2841,7 @@ bool PCB_IO_KICAD_SEXPR::FootprintLibDelete( const wxString& aLibraryPath, const
}
-bool PCB_IO_KICAD_SEXPR::IsFootprintLibWritable( const wxString& aLibraryPath )
+bool PCB_IO_KICAD_SEXPR::IsLibraryWritable( const wxString& aLibraryPath )
{
LOCALE_IO toggle;
diff --git a/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.h b/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.h
index 22380e9560..28de8da9f9 100644
--- a/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.h
+++ b/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.h
@@ -340,13 +340,13 @@ public:
long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override;
- void FootprintLibCreate( const wxString& aLibraryPath,
- const STRING_UTF8_MAP* aProperties = nullptr) override;
+ void CreateLibrary( const wxString& aLibraryPath,
+ const STRING_UTF8_MAP* aProperties = nullptr) override;
- bool FootprintLibDelete( const wxString& aLibraryPath,
- const STRING_UTF8_MAP* aProperties = nullptr ) override;
+ bool DeleteLibrary( const wxString& aLibraryPath,
+ const STRING_UTF8_MAP* aProperties = nullptr ) override;
- bool IsFootprintLibWritable( const wxString& aLibraryPath ) override;
+ bool IsLibraryWritable( const wxString& aLibraryPath ) override;
PCB_IO_KICAD_SEXPR( int aControlFlags = CTL_FOR_BOARD );
diff --git a/pcbnew/pcb_io/pcb_io.cpp b/pcbnew/pcb_io/pcb_io.cpp
index df59c68751..84d468a467 100644
--- a/pcbnew/pcb_io/pcb_io.cpp
+++ b/pcbnew/pcb_io/pcb_io.cpp
@@ -90,7 +90,7 @@ bool PCB_IO::CanReadFootprint( const wxString& aFileName ) const
}
-bool PCB_IO::CanReadFootprintLib( const wxString& aFileName ) const
+bool PCB_IO::CanReadLibrary( const wxString& aFileName ) const
{
const PLUGIN_FILE_DESC& desc = GetFootprintLibDesc();
@@ -239,29 +239,11 @@ void PCB_IO::FootprintDelete( const wxString& aLibraryPath, const wxString& aFoo
}
-void PCB_IO::FootprintLibCreate( const wxString& aLibraryPath, const STRING_UTF8_MAP* aProperties )
+void PCB_IO::GetLibraryOptions( STRING_UTF8_MAP* aListToAppendTo ) const
{
- // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
- NOT_IMPLEMENTED( __FUNCTION__ );
-}
+ // Get base options first
+ IO_BASE::GetLibraryOptions( aListToAppendTo );
-
-bool PCB_IO::FootprintLibDelete( const wxString& aLibraryPath, const STRING_UTF8_MAP* aProperties )
-{
- // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
- NOT_IMPLEMENTED( __FUNCTION__ );
-}
-
-
-bool PCB_IO::IsFootprintLibWritable( const wxString& aLibraryPath )
-{
- // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
- NOT_IMPLEMENTED( __FUNCTION__ );
-}
-
-
-void PCB_IO::FootprintLibOptions( STRING_UTF8_MAP* aListToAppendTo ) const
-{
// disable all these in another couple of months, after everyone has seen them:
#if 1
(*aListToAppendTo)["debug_level"] = UTF8( _( "Enable debug logging for Footprint*() "
diff --git a/pcbnew/pcb_io/pcb_io.h b/pcbnew/pcb_io/pcb_io.h
index 2d15b191c1..a731b98577 100644
--- a/pcbnew/pcb_io/pcb_io.h
+++ b/pcbnew/pcb_io/pcb_io.h
@@ -103,7 +103,7 @@ public:
* Checks if this PCB_IO can read footprint library from specified file or directory.
* If not overriden, extension check is used.
*/
- virtual bool CanReadFootprintLib( const wxString& aFileName ) const;
+ bool CanReadLibrary( const wxString& aFileName ) const override;
/**
* Registers a KIDIALOG callback for collecting info from the user.
@@ -319,56 +319,6 @@ public:
virtual void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
const STRING_UTF8_MAP* aProperties = nullptr );
- /**
- * Create a new empty footprint 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 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 FootprintLibCreate( const wxString& aLibraryPath,
- const STRING_UTF8_MAP* aProperties = nullptr );
-
- /**
- * Delete 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 or file which
- * will contain footprints.
- * @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 FootprintLibDelete( 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 IsFootprintLibWritable( const wxString& aLibraryPath );
-
/**
* Append supported PLUGIN options to @a aListToAppenTo along with internationalized
* descriptions.
@@ -396,7 +346,7 @@ public:
* This would require a 3 column list, and introducing wx GUI knowledge to
* PLUGIN, which has been avoided to date.
*/
- virtual void FootprintLibOptions( STRING_UTF8_MAP* aListToAppendTo ) const;
+ virtual void GetLibraryOptions( STRING_UTF8_MAP* aListToAppendTo ) const override;
virtual ~PCB_IO()
{};
diff --git a/pcbnew/pcb_io/pcb_io_mgr.cpp b/pcbnew/pcb_io/pcb_io_mgr.cpp
index df3c7abe8b..2d1fa449ff 100644
--- a/pcbnew/pcb_io/pcb_io_mgr.cpp
+++ b/pcbnew/pcb_io/pcb_io_mgr.cpp
@@ -155,7 +155,7 @@ PCB_IO_MGR::PCB_FILE_T PCB_IO_MGR::GuessPluginTypeFromLibPath( const wxString& a
PCB_IO::RELEASER pi( plugin.m_createFunc() );
- if( pi->CanReadFootprintLib( aLibPath ) )
+ if( pi->CanReadLibrary( aLibPath ) )
return plugin.m_type;
}
diff --git a/pcbnew/python/examples/createFPC40.py b/pcbnew/python/examples/createFPC40.py
index c3f2e1401d..c152300731 100755
--- a/pcbnew/python/examples/createFPC40.py
+++ b/pcbnew/python/examples/createFPC40.py
@@ -57,6 +57,6 @@ dst_type = IO_MGR.GuessPluginTypeFromLibPath( lib_name );
dst_plugin = IO_MGR.PluginFind( dst_type )
if os.path.exists(lib_name) == False:
- dst_plugin.FootprintLibCreate(lib_name)
+ dst_plugin.CreateLibrary(lib_name)
dst_plugin.FootprintSave(lib_name,module)
diff --git a/pcbnew/python/swig/footprint.i b/pcbnew/python/swig/footprint.i
index ae726e758e..aa3a45211e 100644
--- a/pcbnew/python/swig/footprint.i
+++ b/pcbnew/python/swig/footprint.i
@@ -124,6 +124,18 @@
%{
def FootprintEnumerate(self, libname):
return self.footprintPyEnumerate( libname, True )
+
+ # Old function name for compatibility with pre-v8 scripts, use CreateLibrary() for new scripts.
+ def FootprintLibCreate(self, aLibraryPath, aProperties=None):
+ self.CreateLibrary(aLibraryPath, aProperties)
+
+ # Old function name for compatibility with pre-v8 scripts, use DeleteLibrary() for new scripts.
+ def FootprintLibDelete(self, aLibraryPath, aProperties=None):
+ return self.DeleteLibrary(aLibraryPath, aProperties)
+
+ # Old function name for compatibility with pre-v8 scripts, use IsLibraryWritable() for new scripts.
+ def IsFootprintLibWritable(self, aLibraryPath):
+ return self.IsLibraryWritable(aLibraryPath)
%}
}
@@ -151,11 +163,11 @@
def FootprintLibCreate(libname):
plug = GetPluginForPath(libname)
- plug.FootprintLibCreate(libname)
+ plug.CreateLibrary(libname)
def FootprintLibDelete(libname):
plug = GetPluginForPath(libname)
- plug.FootprintLibDelete(libname)
+ plug.DeleteLibrary(libname)
def FootprintIsWritable(libname):
plug = GetPluginForPath(libname)
diff --git a/tools/lib_convert.py b/tools/lib_convert.py
index 9bd414ec0f..a6248dcf1e 100644
--- a/tools/lib_convert.py
+++ b/tools/lib_convert.py
@@ -28,11 +28,11 @@ src_plugin = IO_MGR.PluginFind( src_type )
dst_plugin = IO_MGR.PluginFind( dst_type )
try:
- dst_plugin.FootprintLibDelete( dst_libpath )
+ dst_plugin.DeleteLibrary( dst_libpath )
except:
None # ignore, new may not exist if first run
-dst_plugin.FootprintLibCreate( dst_libpath )
+dst_plugin.CreateLibrary( dst_libpath )
list_of_parts = src_plugin.FootprintEnumerate( src_libpath )
diff --git a/tools/tests/test_kicad_plugin.py b/tools/tests/test_kicad_plugin.py
index 5a617681ae..3f613fe07a 100644
--- a/tools/tests/test_kicad_plugin.py
+++ b/tools/tests/test_kicad_plugin.py
@@ -27,20 +27,20 @@ plugin = IO_MGR.PluginFind( IO_MGR.KICAD_SEXP )
print( "Plugin Type: %s" % plugin.PluginName() )
try:
- plugin.FootprintLibDelete( lib_path1 )
+ plugin.DeleteLibrary( lib_path1 )
except:
pass # ignore, new may not exist if first run
try:
- plugin.FootprintLibDelete( lib_path2 )
+ plugin.DeleteLibrary( lib_path2 )
except:
pass # ignore, new may not exist if first run
-plugin.FootprintLibCreate( lib_path1 )
+plugin.CreateLibrary( lib_path1 )
# Verify that the same plugin instance can edge trigger on a lib_path change
-# for a FootprintLibCreate()
-plugin.FootprintLibCreate( lib_path2 )
+# for a CreateLibrary()
+plugin.CreateLibrary( lib_path2 )
board = BOARD()