From cad91312aaa1ad09b98fb53feb266465d78e23ab Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Sun, 24 Dec 2023 04:31:22 +0000 Subject: [PATCH] Introduce main base class for all IO loaders --- eeschema/sch_io/altium/sch_io_altium.cpp | 8 +- eeschema/sch_io/altium/sch_io_altium.h | 6 -- .../sch_io/cadstar/sch_io_cadstar_archive.cpp | 6 -- .../sch_io/cadstar/sch_io_cadstar_archive.h | 8 +- eeschema/sch_io/database/sch_io_database.cpp | 2 +- eeschema/sch_io/database/sch_io_database.h | 5 -- eeschema/sch_io/eagle/sch_io_eagle.cpp | 9 +-- eeschema/sch_io/eagle/sch_io_eagle.h | 12 --- eeschema/sch_io/easyeda/sch_io_easyeda.cpp | 7 -- eeschema/sch_io/easyeda/sch_io_easyeda.h | 16 +--- .../sch_io/easyedapro/sch_io_easyedapro.cpp | 9 +-- .../sch_io/easyedapro/sch_io_easyedapro.h | 12 --- eeschema/sch_io/http_lib/sch_io_http_lib.cpp | 2 +- eeschema/sch_io/http_lib/sch_io_http_lib.h | 5 -- .../kicad_legacy/sch_io_kicad_legacy.cpp | 3 +- .../sch_io/kicad_legacy/sch_io_kicad_legacy.h | 11 --- .../sch_io/kicad_sexpr/sch_io_kicad_sexpr.cpp | 3 +- .../sch_io/kicad_sexpr/sch_io_kicad_sexpr.h | 11 --- eeschema/sch_io/ltspice/sch_io_ltspice.cpp | 6 -- eeschema/sch_io/ltspice/sch_io_ltspice.h | 15 +--- eeschema/sch_io/sch_io.h | 23 ++---- include/io/io_base.h | 76 +++++++++++++++++++ .../altium/pcb_io_altium_circuit_maker.cpp | 10 +-- .../altium/pcb_io_altium_circuit_maker.h | 6 -- .../altium/pcb_io_altium_circuit_studio.cpp | 10 +-- .../altium/pcb_io_altium_circuit_studio.h | 6 -- .../pcb_io/altium/pcb_io_altium_designer.cpp | 4 +- pcbnew/pcb_io/altium/pcb_io_altium_designer.h | 6 -- pcbnew/pcb_io/altium/pcb_io_solidworks.cpp | 10 +-- pcbnew/pcb_io/altium/pcb_io_solidworks.h | 6 -- .../pcb_io/cadstar/pcb_io_cadstar_archive.cpp | 4 +- .../pcb_io/cadstar/pcb_io_cadstar_archive.h | 4 - pcbnew/pcb_io/eagle/pcb_io_eagle.cpp | 2 +- pcbnew/pcb_io/eagle/pcb_io_eagle.h | 5 -- .../pcb_io/easyeda/pcb_io_easyeda_plugin.cpp | 4 +- pcbnew/pcb_io/easyeda/pcb_io_easyeda_plugin.h | 7 -- .../pcb_io/easyedapro/pcb_io_easyedapro.cpp | 4 +- pcbnew/pcb_io/easyedapro/pcb_io_easyedapro.h | 8 -- pcbnew/pcb_io/fabmaster/pcb_io_fabmaster.cpp | 10 +-- pcbnew/pcb_io/fabmaster/pcb_io_fabmaster.h | 5 -- pcbnew/pcb_io/geda/pcb_io_geda.cpp | 4 +- pcbnew/pcb_io/geda/pcb_io_geda.h | 6 -- pcbnew/pcb_io/ipc2581/pcb_io_ipc2581.cpp | 6 -- pcbnew/pcb_io/ipc2581/pcb_io_ipc2581.h | 7 +- .../kicad_legacy/pcb_io_kicad_legacy.cpp | 4 +- .../pcb_io/kicad_legacy/pcb_io_kicad_legacy.h | 8 -- .../pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.cpp | 2 +- .../pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.h | 7 -- pcbnew/pcb_io/pcad/pcb_io_pcad.cpp | 4 +- pcbnew/pcb_io/pcad/pcb_io_pcad.h | 6 -- pcbnew/pcb_io/pcb_io.cpp | 2 +- pcbnew/pcb_io/pcb_io.h | 26 ++++--- 52 files changed, 126 insertions(+), 322 deletions(-) create mode 100644 include/io/io_base.h diff --git a/eeschema/sch_io/altium/sch_io_altium.cpp b/eeschema/sch_io/altium/sch_io_altium.cpp index 9bab7ec6b1..fab3fed566 100644 --- a/eeschema/sch_io/altium/sch_io_altium.cpp +++ b/eeschema/sch_io/altium/sch_io_altium.cpp @@ -223,7 +223,7 @@ static void SetLibShapeFillAndColor( const ASCH_FILL_INTERFACE& elem, LIB_SHAPE* } -SCH_IO_ALTIUM::SCH_IO_ALTIUM() +SCH_IO_ALTIUM::SCH_IO_ALTIUM() : SCH_IO( wxS( "Altium" ) ) { m_isIntLib = false; m_rootSheet = nullptr; @@ -247,12 +247,6 @@ SCH_IO_ALTIUM::~SCH_IO_ALTIUM() } -const wxString SCH_IO_ALTIUM::GetName() const -{ - return "Altium"; -} - - int SCH_IO_ALTIUM::GetModifyHash() const { return 0; diff --git a/eeschema/sch_io/altium/sch_io_altium.h b/eeschema/sch_io/altium/sch_io_altium.h index 0f17dd7047..93b6f8eec3 100644 --- a/eeschema/sch_io/altium/sch_io_altium.h +++ b/eeschema/sch_io/altium/sch_io_altium.h @@ -58,10 +58,6 @@ public: SCH_IO_ALTIUM(); ~SCH_IO_ALTIUM(); - const wxString GetName() const override; - - void SetReporter( REPORTER* aReporter ) override { m_reporter = aReporter; } - const PLUGIN_FILE_DESC GetSchematicFileDesc() const override { return PLUGIN_FILE_DESC( _HKI( "Altium schematic files" ), { "SchDoc" } ); @@ -187,8 +183,6 @@ private: std::vector ParseLibComponent( const std::map& aProperties ); private: - REPORTER* m_reporter; // current reporter for warnings/errors - SCH_SHEET* m_rootSheet; // The root sheet of the schematic being loaded.. SCH_SHEET_PATH m_sheetPath; SCHEMATIC* m_schematic; // Passed to Load(), the schematic object being loaded diff --git a/eeschema/sch_io/cadstar/sch_io_cadstar_archive.cpp b/eeschema/sch_io/cadstar/sch_io_cadstar_archive.cpp index 8aa7544c0e..35b63d5cdb 100644 --- a/eeschema/sch_io/cadstar/sch_io_cadstar_archive.cpp +++ b/eeschema/sch_io/cadstar/sch_io_cadstar_archive.cpp @@ -37,12 +37,6 @@ #include -const wxString SCH_IO_CADSTAR_ARCHIVE::GetName() const -{ - return wxT( "CADSTAR Schematic Archive" ); -} - - bool SCH_IO_CADSTAR_ARCHIVE::CanReadLibrary( const wxString& aFileName ) const { if( !SCH_IO::CanReadLibrary( aFileName ) ) diff --git a/eeschema/sch_io/cadstar/sch_io_cadstar_archive.h b/eeschema/sch_io/cadstar/sch_io_cadstar_archive.h index 5293d8a2d6..75139e2413 100644 --- a/eeschema/sch_io/cadstar/sch_io_cadstar_archive.h +++ b/eeschema/sch_io/cadstar/sch_io_cadstar_archive.h @@ -35,17 +35,14 @@ class SCH_SCREEN; class SCH_IO_CADSTAR_ARCHIVE : public SCH_IO { public: - SCH_IO_CADSTAR_ARCHIVE() : + SCH_IO_CADSTAR_ARCHIVE() : SCH_IO( wxS( "CADSTAR Schematic Archive" ) ), m_cacheTimestamp( 0 ) { m_reporter = &WXLOG_REPORTER::GetInstance(); - m_progressReporter = nullptr; } virtual ~SCH_IO_CADSTAR_ARCHIVE() {} - const wxString GetName() const override; - void SetReporter( REPORTER* aReporter ) override { m_reporter = aReporter; } void SetProgressReporter( PROGRESS_REPORTER* aReporter ) override @@ -106,9 +103,6 @@ private: wxString m_cachePath; wxFileName m_cachecsafn; wxString m_cachefplibname; - - REPORTER* m_reporter; // current reporter for warnings/errors - PROGRESS_REPORTER* m_progressReporter; // optional; may be nullptr }; #endif // SCH_IO_CADSTAR_ARCHIVE_H_ diff --git a/eeschema/sch_io/database/sch_io_database.cpp b/eeschema/sch_io/database/sch_io_database.cpp index b0d8d3dd3c..28a39a06cc 100644 --- a/eeschema/sch_io/database/sch_io_database.cpp +++ b/eeschema/sch_io/database/sch_io_database.cpp @@ -33,7 +33,7 @@ #include "sch_io_database.h" -SCH_IO_DATABASE::SCH_IO_DATABASE() : +SCH_IO_DATABASE::SCH_IO_DATABASE() : SCH_IO( wxS( "Database library" ) ), m_libTable( nullptr ), m_settings(), m_conn() diff --git a/eeschema/sch_io/database/sch_io_database.h b/eeschema/sch_io/database/sch_io_database.h index 72a7928883..8302f2bbc5 100644 --- a/eeschema/sch_io/database/sch_io_database.h +++ b/eeschema/sch_io/database/sch_io_database.h @@ -45,11 +45,6 @@ public: SCH_IO_DATABASE(); virtual ~SCH_IO_DATABASE(); - const wxString GetName() const override - { - return wxT( "Database library" ); - } - const PLUGIN_FILE_DESC GetLibraryFileDesc() const override { return PLUGIN_FILE_DESC( _HKI( "KiCad database library files" ), diff --git a/eeschema/sch_io/eagle/sch_io_eagle.cpp b/eeschema/sch_io/eagle/sch_io_eagle.cpp index 2be62c1c21..3b0ab6872c 100644 --- a/eeschema/sch_io/eagle/sch_io_eagle.cpp +++ b/eeschema/sch_io/eagle/sch_io_eagle.cpp @@ -356,8 +356,7 @@ static void eagleToKicadAlignment( EDA_TEXT* aText, int aEagleAlignment, int aRe } -SCH_IO_EAGLE::SCH_IO_EAGLE() : - m_progressReporter( nullptr ), +SCH_IO_EAGLE::SCH_IO_EAGLE() : SCH_IO( wxS( "EAGLE" ) ), m_doneCount( 0 ), m_lastProgressCount( 0 ), m_totalCount( 0 ) @@ -374,12 +373,6 @@ SCH_IO_EAGLE::~SCH_IO_EAGLE() } -const wxString SCH_IO_EAGLE::GetName() const -{ - return wxT( "EAGLE" ); -} - - int SCH_IO_EAGLE::GetModifyHash() const { return 0; diff --git a/eeschema/sch_io/eagle/sch_io_eagle.h b/eeschema/sch_io/eagle/sch_io_eagle.h index eebc3ae92f..dbb48e80a5 100644 --- a/eeschema/sch_io/eagle/sch_io_eagle.h +++ b/eeschema/sch_io/eagle/sch_io_eagle.h @@ -86,15 +86,6 @@ public: SCH_IO_EAGLE(); ~SCH_IO_EAGLE(); - const wxString GetName() const override; - - void SetReporter( REPORTER* aReporter ) override { m_reporter = aReporter; } - - void SetProgressReporter( PROGRESS_REPORTER* aReporter ) override - { - m_progressReporter = aReporter; - } - const PLUGIN_FILE_DESC GetSchematicFileDesc() const override { return PLUGIN_FILE_DESC( _HKI( "Eagle XML schematic files" ), { "sch" } ); @@ -241,8 +232,6 @@ private: std::map units; }; - REPORTER* m_reporter; ///< Reporter for warnings/errors - ///< Map references to missing symbol units data std::map m_missingCmps; @@ -261,7 +250,6 @@ private: SCH_IO::SCH_IO_RELEASER m_pi; ///< PI to create KiCad symbol library. std::unique_ptr m_properties; ///< Library plugin properties. - PROGRESS_REPORTER* m_progressReporter; ///< optional; may be nullptr unsigned m_doneCount; unsigned m_lastProgressCount; unsigned m_totalCount; ///< for progress reporting diff --git a/eeschema/sch_io/easyeda/sch_io_easyeda.cpp b/eeschema/sch_io/easyeda/sch_io_easyeda.cpp index c376263867..6d4b219ed3 100644 --- a/eeschema/sch_io/easyeda/sch_io_easyeda.cpp +++ b/eeschema/sch_io/easyeda/sch_io_easyeda.cpp @@ -40,13 +40,6 @@ #include - -const wxString SCH_IO_EASYEDA::GetName() const -{ - return wxT( "EasyEDA (JLCEDA) Schematic Importer" ); -} - - static bool FindSchFileInStream( const wxString& aName, wxInputStream& aStream, nlohmann::json& aOut, EASYEDA::DOCUMENT& aDoc, EASYEDA::DOC_TYPE& aDocType ) diff --git a/eeschema/sch_io/easyeda/sch_io_easyeda.h b/eeschema/sch_io/easyeda/sch_io_easyeda.h index 5280a1dc67..55e3d635ed 100644 --- a/eeschema/sch_io/easyeda/sch_io_easyeda.h +++ b/eeschema/sch_io/easyeda/sch_io_easyeda.h @@ -38,23 +38,13 @@ class SCH_SCREEN; class SCH_IO_EASYEDA : public SCH_IO { public: - SCH_IO_EASYEDA() + SCH_IO_EASYEDA() : SCH_IO( wxS( "EasyEDA (JLCEDA) Schematic" ) ) { m_reporter = &WXLOG_REPORTER::GetInstance(); - m_progressReporter = nullptr; } ~SCH_IO_EASYEDA() {} - const wxString GetName() const override; - - void SetReporter( REPORTER* aReporter ) override { m_reporter = aReporter; } - - void SetProgressReporter( PROGRESS_REPORTER* aReporter ) override - { - m_progressReporter = aReporter; - } - const PLUGIN_FILE_DESC GetSchematicFileDesc() const override { return PLUGIN_FILE_DESC( _HKI( "EasyEDA (JLCEDA) Std files" ), { "json" } ); @@ -82,10 +72,6 @@ public: const STRING_UTF8_MAP* aProperties = nullptr ) override; bool IsSymbolLibWritable( const wxString& aLibraryPath ) override { return false; } - -private: - REPORTER* m_reporter; // current reporter for warnings/errors - PROGRESS_REPORTER* m_progressReporter; // optional; may be nullptr }; diff --git a/eeschema/sch_io/easyedapro/sch_io_easyedapro.cpp b/eeschema/sch_io/easyedapro/sch_io_easyedapro.cpp index 3e5aa69ed4..2f20345d7e 100644 --- a/eeschema/sch_io/easyedapro/sch_io_easyedapro.cpp +++ b/eeschema/sch_io/easyedapro/sch_io_easyedapro.cpp @@ -54,10 +54,9 @@ struct SCH_IO_EASYEDAPRO::PRJ_DATA }; -SCH_IO_EASYEDAPRO::SCH_IO_EASYEDAPRO() +SCH_IO_EASYEDAPRO::SCH_IO_EASYEDAPRO() : SCH_IO( wxS( "EasyEDA Pro (JLCEDA) Schematic" ) ) { m_reporter = &WXLOG_REPORTER::GetInstance(); - m_progressReporter = nullptr; } @@ -68,12 +67,6 @@ SCH_IO_EASYEDAPRO::~SCH_IO_EASYEDAPRO() } -const wxString SCH_IO_EASYEDAPRO::GetName() const -{ - return wxT( "EasyEDA (JLCEDA) Schematic Importer" ); -} - - bool SCH_IO_EASYEDAPRO::CanReadSchematicFile( const wxString& aFileName ) const { if( aFileName.Lower().EndsWith( wxS( ".epro" ) ) ) diff --git a/eeschema/sch_io/easyedapro/sch_io_easyedapro.h b/eeschema/sch_io/easyedapro/sch_io_easyedapro.h index 0513ac09b0..3f84a480ea 100644 --- a/eeschema/sch_io/easyedapro/sch_io_easyedapro.h +++ b/eeschema/sch_io/easyedapro/sch_io_easyedapro.h @@ -41,15 +41,6 @@ public: SCH_IO_EASYEDAPRO(); ~SCH_IO_EASYEDAPRO(); - const wxString GetName() const override; - - void SetReporter( REPORTER* aReporter ) override { m_reporter = aReporter; } - - void SetProgressReporter( PROGRESS_REPORTER* aReporter ) override - { - m_progressReporter = aReporter; - } - const PLUGIN_FILE_DESC GetSchematicFileDesc() const override { return PLUGIN_FILE_DESC( _HKI( "EasyEDA (JLCEDA) Pro files" ), { "epro", "zip" } ); @@ -84,9 +75,6 @@ public: private: struct PRJ_DATA; // Opaque data structure PRJ_DATA* m_projectData = nullptr; - - REPORTER* m_reporter; // current reporter for warnings/errors - PROGRESS_REPORTER* m_progressReporter; // optional; may be nullptr }; diff --git a/eeschema/sch_io/http_lib/sch_io_http_lib.cpp b/eeschema/sch_io/http_lib/sch_io_http_lib.cpp index d4627e2dd2..8386ffd0b1 100644 --- a/eeschema/sch_io/http_lib/sch_io_http_lib.cpp +++ b/eeschema/sch_io/http_lib/sch_io_http_lib.cpp @@ -28,7 +28,7 @@ #include "sch_io_http_lib.h" -SCH_IO_HTTP_LIB::SCH_IO_HTTP_LIB() : +SCH_IO_HTTP_LIB::SCH_IO_HTTP_LIB() : SCH_IO( wxS( "HTTP library" ) ), m_libTable( nullptr ) { } 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 76517f17b5..182fa6fcbd 100644 --- a/eeschema/sch_io/http_lib/sch_io_http_lib.h +++ b/eeschema/sch_io/http_lib/sch_io_http_lib.h @@ -42,11 +42,6 @@ public: SCH_IO_HTTP_LIB(); virtual ~SCH_IO_HTTP_LIB(); - const wxString GetName() const override - { - return wxT( "HTTP library" ); - } - const PLUGIN_FILE_DESC GetLibraryFileDesc() const override { return PLUGIN_FILE_DESC( _HKI( "KiCad HTTP library files" ), 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 3961e7988d..0ad18c8ef5 100644 --- a/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy.cpp +++ b/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy.cpp @@ -72,9 +72,8 @@ #define T_WIDTH "width" -SCH_IO_KICAD_LEGACY::SCH_IO_KICAD_LEGACY() : +SCH_IO_KICAD_LEGACY::SCH_IO_KICAD_LEGACY() : SCH_IO( wxS( "Eeschema legacy" ) ), m_appending( false ), - m_progressReporter( nullptr ), m_lineReader( nullptr ), m_lastProgressLine( 0 ), m_lineCount( 0 ) 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 82d37de34b..daca0c59cd 100644 --- a/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy.h +++ b/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy.h @@ -70,11 +70,6 @@ public: SCH_IO_KICAD_LEGACY(); virtual ~SCH_IO_KICAD_LEGACY(); - const wxString GetName() const override - { - return wxT( "Eeschema-Legacy" ); - } - const PLUGIN_FILE_DESC GetSchematicFileDesc() const override { return PLUGIN_FILE_DESC( _HKI( "KiCad legacy schematic files" ), @@ -91,11 +86,6 @@ public: bool CanReadLibrary( const wxString& aFileName ) const override; - void SetProgressReporter( PROGRESS_REPORTER* aReporter ) override - { - m_progressReporter = aReporter; - } - /** * The property used internally by the plugin to enable cache buffering which prevents * the library file from being written every time the cache is changed. This is useful @@ -191,7 +181,6 @@ protected: wxString m_error; ///< For throwing exceptions or errors on partial ///< schematic loads. - PROGRESS_REPORTER* m_progressReporter; ///< optional; may be nullptr LINE_READER* m_lineReader; ///< for progress reporting unsigned m_lastProgressLine; unsigned m_lineCount; ///< for progress reporting 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 7275138f77..51d8324eab 100644 --- a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr.cpp +++ b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr.cpp @@ -74,8 +74,7 @@ using namespace TSCHEMATIC_T; reader.LineNumber(), pos - reader.Line() ) -SCH_IO_KICAD_SEXPR::SCH_IO_KICAD_SEXPR() : - m_progressReporter( nullptr ) +SCH_IO_KICAD_SEXPR::SCH_IO_KICAD_SEXPR() : SCH_IO( wxS( "Eeschema s-expression" ) ) { init( nullptr ); } 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 17f95a166d..228afe95d7 100644 --- a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr.h +++ b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr.h @@ -69,11 +69,6 @@ public: SCH_IO_KICAD_SEXPR(); virtual ~SCH_IO_KICAD_SEXPR(); - const wxString GetName() const override - { - return wxT( "Eeschema s-expression" ); - } - const PLUGIN_FILE_DESC GetSchematicFileDesc() const override { return PLUGIN_FILE_DESC( _HKI( "KiCad s-expression schematic files" ), @@ -86,11 +81,6 @@ public: { KiCadSymbolLibFileExtension } ); } - void SetProgressReporter( PROGRESS_REPORTER* aReporter ) override - { - m_progressReporter = aReporter; - } - /** * The property used internally by the plugin to enable cache buffering which prevents * the library file from being written every time the cache is changed. This is useful @@ -174,7 +164,6 @@ protected: bool m_appending; ///< Schematic load append status. wxString m_error; ///< For throwing exceptions or errors on partial ///< loads. - PROGRESS_REPORTER* m_progressReporter; wxString m_path; ///< Root project path for loading child sheets. std::stack m_currentPath; ///< Stack to maintain nested sheet paths diff --git a/eeschema/sch_io/ltspice/sch_io_ltspice.cpp b/eeschema/sch_io/ltspice/sch_io_ltspice.cpp index 2be95cb1ce..71a6f85fe2 100644 --- a/eeschema/sch_io/ltspice/sch_io_ltspice.cpp +++ b/eeschema/sch_io/ltspice/sch_io_ltspice.cpp @@ -33,12 +33,6 @@ * @brief schematic PLUGIN for LTspice (*.asc) and (.asy) format. */ -const wxString SCH_IO_LTSPICE::GetName() const -{ - return wxT( "LTspice Schematic Importer" ); -} - - int SCH_IO_LTSPICE::GetModifyHash() const { return 0; diff --git a/eeschema/sch_io/ltspice/sch_io_ltspice.h b/eeschema/sch_io/ltspice/sch_io_ltspice.h index a08329e505..379a942a33 100644 --- a/eeschema/sch_io/ltspice/sch_io_ltspice.h +++ b/eeschema/sch_io/ltspice/sch_io_ltspice.h @@ -35,25 +35,15 @@ class SCH_SCREEN; class SCH_IO_LTSPICE : public SCH_IO { public: - SCH_IO_LTSPICE() + SCH_IO_LTSPICE() : SCH_IO( wxS( "LTspice Schematic" ) ) { m_reporter = &WXLOG_REPORTER::GetInstance(); - m_progressReporter = nullptr; } ~SCH_IO_LTSPICE() { } - const wxString GetName() const override; - - void SetReporter( REPORTER* aReporter ) override { m_reporter = aReporter; } - - void SetProgressReporter( PROGRESS_REPORTER* aReporter ) override - { - m_progressReporter = aReporter; - } - const PLUGIN_FILE_DESC GetSchematicFileDesc() const override { return PLUGIN_FILE_DESC( _HKI( "LTspice schematic files" ), { "asc" } ); @@ -70,8 +60,5 @@ public: SCH_SHEET* aAppendToMe = nullptr, const STRING_UTF8_MAP* aProperties = nullptr ) override; -private: - REPORTER* m_reporter; // current reporter for warnings/errors - PROGRESS_REPORTER* m_progressReporter; // optional; may be nullptr }; #endif // SCH_IO_LTSPICE_H_ diff --git a/eeschema/sch_io/sch_io.h b/eeschema/sch_io/sch_io.h index 601ce73bba..efaadcd8ba 100644 --- a/eeschema/sch_io/sch_io.h +++ b/eeschema/sch_io/sch_io.h @@ -23,6 +23,7 @@ #ifndef SCH_IO_H_ #define SCH_IO_H_ +#include #include #include #include @@ -53,27 +54,12 @@ * } * */ -class SCH_IO +class SCH_IO : public IO_BASE { public: //------------------------------------------------------ - /** - * Return a brief hard coded name for this SCH_IO. - */ - virtual const wxString GetName() const = 0; - - /** - * Set an optional reporter for warnings/errors. - */ - virtual void SetReporter( REPORTER* aReporter ) {} - - /** - * Set an optional progress reporter. - */ - virtual void SetProgressReporter( PROGRESS_REPORTER* aReporter ) {} - /** * Returns schematic file description for the #SCH_IO. */ @@ -483,6 +469,11 @@ public: return plugin; } }; + +protected: + + SCH_IO( const wxString& aName ) : IO_BASE( aName ) + {} }; diff --git a/include/io/io_base.h b/include/io/io_base.h new file mode 100644 index 0000000000..8fff99a2b2 --- /dev/null +++ b/include/io/io_base.h @@ -0,0 +1,76 @@ +/* + * 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 . + */ + + +#ifndef IO_BASE_H_ +#define IO_BASE_H_ + +#include + +class REPORTER; +class PROGRESS_REPORTER; + +class IO_BASE +{ +public: + + virtual ~IO_BASE() = default; + + /** + * Return a brief hard coded name for this IO interface. + */ + const wxString& GetName() const { return m_name; } + + /** + * Set an optional reporter for warnings/errors. + */ + virtual void SetReporter( REPORTER* aReporter ) { m_reporter = aReporter; } + + /** + * Set an optional progress reporter. + */ + virtual void SetProgressReporter( PROGRESS_REPORTER* aReporter ) { m_progressReporter = aReporter; } + +protected: + // Delete the zero-argument base constructor to force proper construction + IO_BASE() = delete; + + /** + * + * @param aName is the user-visible name for the IO loader + */ + IO_BASE( const wxString& aName ) : + m_name( aName ), + m_reporter( nullptr ), + m_progressReporter( nullptr ) + { + } + + + /// Name of the IO loader + wxString m_name; + + /// Reporter to log errors/warnings to, may be nullptr + REPORTER* m_reporter; + + /// Progress reporter to track the progress of the operation, may be nullptr + PROGRESS_REPORTER* m_progressReporter; +}; + +#endif // IO_BASE_H_ \ No newline at end of file diff --git a/pcbnew/pcb_io/altium/pcb_io_altium_circuit_maker.cpp b/pcbnew/pcb_io/altium/pcb_io_altium_circuit_maker.cpp index 70b5b57d47..70d5a8bac9 100644 --- a/pcbnew/pcb_io/altium/pcb_io_altium_circuit_maker.cpp +++ b/pcbnew/pcb_io/altium/pcb_io_altium_circuit_maker.cpp @@ -39,10 +39,8 @@ #include #include -PCB_IO_ALTIUM_CIRCUIT_MAKER::PCB_IO_ALTIUM_CIRCUIT_MAKER() +PCB_IO_ALTIUM_CIRCUIT_MAKER::PCB_IO_ALTIUM_CIRCUIT_MAKER() : PCB_IO( wxS( "Altium Circuit Maker" ) ) { - m_board = nullptr; - m_props = nullptr; } @@ -51,12 +49,6 @@ PCB_IO_ALTIUM_CIRCUIT_MAKER::~PCB_IO_ALTIUM_CIRCUIT_MAKER() } -const wxString PCB_IO_ALTIUM_CIRCUIT_MAKER::PluginName() const -{ - return wxT( "Altium Circuit Maker" ); -} - - PLUGIN_FILE_DESC PCB_IO_ALTIUM_CIRCUIT_MAKER::GetBoardFileDesc() const { return PLUGIN_FILE_DESC( _HKI( "Altium Circuit Maker PCB files" ), { "CMPcbDoc" } ); diff --git a/pcbnew/pcb_io/altium/pcb_io_altium_circuit_maker.h b/pcbnew/pcb_io/altium/pcb_io_altium_circuit_maker.h index 83001442d7..ddc771e7da 100644 --- a/pcbnew/pcb_io/altium/pcb_io_altium_circuit_maker.h +++ b/pcbnew/pcb_io/altium/pcb_io_altium_circuit_maker.h @@ -32,8 +32,6 @@ class PCB_IO_ALTIUM_CIRCUIT_MAKER : public PCB_IO { public: - const wxString PluginName() const override; - PLUGIN_FILE_DESC GetBoardFileDesc() const override; bool CanReadBoard( const wxString& aFileName ) const override; @@ -50,10 +48,6 @@ public: PCB_IO_ALTIUM_CIRCUIT_MAKER(); ~PCB_IO_ALTIUM_CIRCUIT_MAKER(); - -private: - const STRING_UTF8_MAP* m_props; - BOARD* m_board; }; #endif // PCB_IO_ALTIUM_CIRCUIT_MAKER_H_ diff --git a/pcbnew/pcb_io/altium/pcb_io_altium_circuit_studio.cpp b/pcbnew/pcb_io/altium/pcb_io_altium_circuit_studio.cpp index edaf831493..c89765de2f 100644 --- a/pcbnew/pcb_io/altium/pcb_io_altium_circuit_studio.cpp +++ b/pcbnew/pcb_io/altium/pcb_io_altium_circuit_studio.cpp @@ -39,10 +39,8 @@ #include #include -PCB_IO_ALTIUM_CIRCUIT_STUDIO::PCB_IO_ALTIUM_CIRCUIT_STUDIO() +PCB_IO_ALTIUM_CIRCUIT_STUDIO::PCB_IO_ALTIUM_CIRCUIT_STUDIO() : PCB_IO( wxS( "Altium Circuit Studio" ) ) { - m_board = nullptr; - m_props = nullptr; } @@ -51,12 +49,6 @@ PCB_IO_ALTIUM_CIRCUIT_STUDIO::~PCB_IO_ALTIUM_CIRCUIT_STUDIO() } -const wxString PCB_IO_ALTIUM_CIRCUIT_STUDIO::PluginName() const -{ - return wxT( "Altium Circuit Studio" ); -} - - PLUGIN_FILE_DESC PCB_IO_ALTIUM_CIRCUIT_STUDIO::GetBoardFileDesc() const { return PLUGIN_FILE_DESC( _HKI( "Altium Circuit Studio PCB files" ), { "CSPcbDoc" } ); diff --git a/pcbnew/pcb_io/altium/pcb_io_altium_circuit_studio.h b/pcbnew/pcb_io/altium/pcb_io_altium_circuit_studio.h index 2323384c5a..02993acf08 100644 --- a/pcbnew/pcb_io/altium/pcb_io_altium_circuit_studio.h +++ b/pcbnew/pcb_io/altium/pcb_io_altium_circuit_studio.h @@ -31,8 +31,6 @@ class PCB_IO_ALTIUM_CIRCUIT_STUDIO : public PCB_IO { public: - const wxString PluginName() const override; - PLUGIN_FILE_DESC GetBoardFileDesc() const override; bool CanReadBoard( const wxString& aFileName ) const override; @@ -49,10 +47,6 @@ public: PCB_IO_ALTIUM_CIRCUIT_STUDIO(); ~PCB_IO_ALTIUM_CIRCUIT_STUDIO(); - -private: - const STRING_UTF8_MAP* m_props; - BOARD* m_board; }; #endif // PCB_IO_ALTIUM_CIRCUIT_STUDIO_H_ diff --git a/pcbnew/pcb_io/altium/pcb_io_altium_designer.cpp b/pcbnew/pcb_io/altium/pcb_io_altium_designer.cpp index 5062b34ff0..ec17e39522 100644 --- a/pcbnew/pcb_io/altium/pcb_io_altium_designer.cpp +++ b/pcbnew/pcb_io/altium/pcb_io_altium_designer.cpp @@ -39,10 +39,8 @@ #include #include -PCB_IO_ALTIUM_DESIGNER::PCB_IO_ALTIUM_DESIGNER() +PCB_IO_ALTIUM_DESIGNER::PCB_IO_ALTIUM_DESIGNER() : PCB_IO( wxS( "Altium Designer" ) ) { - m_board = nullptr; - m_props = nullptr; } diff --git a/pcbnew/pcb_io/altium/pcb_io_altium_designer.h b/pcbnew/pcb_io/altium/pcb_io_altium_designer.h index 8080ca1a7a..b3a24c423d 100644 --- a/pcbnew/pcb_io/altium/pcb_io_altium_designer.h +++ b/pcbnew/pcb_io/altium/pcb_io_altium_designer.h @@ -37,9 +37,6 @@ class PCB_IO_ALTIUM_DESIGNER : public PCB_IO { public: // ------------------------------------------------------- - - const wxString PluginName() const override { return wxT( "Altium Designer" ); } - PLUGIN_FILE_DESC GetBoardFileDesc() const override { return PLUGIN_FILE_DESC( _HKI( "Altium Designer PCB files" ), { "PcbDoc" } ); @@ -81,9 +78,6 @@ public: static bool checkFileHeader( const wxString& aFileName ); private: - const STRING_UTF8_MAP* m_props; - BOARD* m_board; - std::map>> m_fplibFiles; void loadAltiumLibrary( const wxString& aLibraryPath ); diff --git a/pcbnew/pcb_io/altium/pcb_io_solidworks.cpp b/pcbnew/pcb_io/altium/pcb_io_solidworks.cpp index 0e8313a2c0..696dcbdbad 100644 --- a/pcbnew/pcb_io/altium/pcb_io_solidworks.cpp +++ b/pcbnew/pcb_io/altium/pcb_io_solidworks.cpp @@ -30,10 +30,8 @@ #include #include -PCB_IO_SOLIDWORKS::PCB_IO_SOLIDWORKS() +PCB_IO_SOLIDWORKS::PCB_IO_SOLIDWORKS() : PCB_IO( wxS( "Solidworks PCB" ) ) { - m_board = nullptr; - m_props = nullptr; } @@ -42,12 +40,6 @@ PCB_IO_SOLIDWORKS::~PCB_IO_SOLIDWORKS() } -const wxString PCB_IO_SOLIDWORKS::PluginName() const -{ - return wxT( "Solidworks PCB" ); -} - - PLUGIN_FILE_DESC PCB_IO_SOLIDWORKS::GetBoardFileDesc() const { return PLUGIN_FILE_DESC( _HKI( "Solidworks PCB files" ), { "SWPcbDoc" } ); diff --git a/pcbnew/pcb_io/altium/pcb_io_solidworks.h b/pcbnew/pcb_io/altium/pcb_io_solidworks.h index 859efdbf33..0117d83fc1 100644 --- a/pcbnew/pcb_io/altium/pcb_io_solidworks.h +++ b/pcbnew/pcb_io/altium/pcb_io_solidworks.h @@ -26,8 +26,6 @@ class PCB_IO_SOLIDWORKS : public PCB_IO { public: - const wxString PluginName() const override; - PLUGIN_FILE_DESC GetBoardFileDesc() const override; bool CanReadBoard( const wxString& aFileName ) const override; @@ -43,10 +41,6 @@ public: PCB_IO_SOLIDWORKS(); ~PCB_IO_SOLIDWORKS(); - -private: - const STRING_UTF8_MAP* m_props; - BOARD* m_board; }; diff --git a/pcbnew/pcb_io/cadstar/pcb_io_cadstar_archive.cpp b/pcbnew/pcb_io/cadstar/pcb_io_cadstar_archive.cpp index 7a51f1c660..a57213a117 100644 --- a/pcbnew/pcb_io/cadstar/pcb_io_cadstar_archive.cpp +++ b/pcbnew/pcb_io/cadstar/pcb_io_cadstar_archive.cpp @@ -55,10 +55,8 @@ void PCB_IO_CADSTAR_ARCHIVE::RegisterLayerMappingCallback( } -PCB_IO_CADSTAR_ARCHIVE::PCB_IO_CADSTAR_ARCHIVE() +PCB_IO_CADSTAR_ARCHIVE::PCB_IO_CADSTAR_ARCHIVE() : PCB_IO( wxS( "CADSTAR PCB Archive" ) ) { - m_board = nullptr; - m_props = nullptr; m_show_layer_mapping_warnings = true; LAYER_REMAPPABLE_PLUGIN::RegisterLayerMappingCallback( PCB_IO_CADSTAR_ARCHIVE::DefaultLayerMappingCallback ); diff --git a/pcbnew/pcb_io/cadstar/pcb_io_cadstar_archive.h b/pcbnew/pcb_io/cadstar/pcb_io_cadstar_archive.h index 51fbc5d2cf..b4be8e6530 100644 --- a/pcbnew/pcb_io/cadstar/pcb_io_cadstar_archive.h +++ b/pcbnew/pcb_io/cadstar/pcb_io_cadstar_archive.h @@ -32,8 +32,6 @@ class PCB_IO_CADSTAR_ARCHIVE : public PCB_IO, public LAYER_REMAPPABLE_PLUGIN { public: - const wxString PluginName() const override { return wxT( "CADSTAR PCB Archive" ); } - PLUGIN_FILE_DESC GetBoardFileDesc() const override { return PLUGIN_FILE_DESC( _HKI( "CADSTAR PCB Archive files" ), { "cpa" } ); @@ -101,8 +99,6 @@ private: std::map m_cache; std::map m_timestamps; - const STRING_UTF8_MAP* m_props; - BOARD* m_board; std::vector m_loaded_footprints; bool m_show_layer_mapping_warnings; diff --git a/pcbnew/pcb_io/eagle/pcb_io_eagle.cpp b/pcbnew/pcb_io/eagle/pcb_io_eagle.cpp index 166660d66d..1be4f8cfbb 100644 --- a/pcbnew/pcb_io/eagle/pcb_io_eagle.cpp +++ b/pcbnew/pcb_io/eagle/pcb_io_eagle.cpp @@ -220,7 +220,7 @@ void ERULES::parse( wxXmlNode* aRules, std::function aCheckpoint ) } -PCB_IO_EAGLE::PCB_IO_EAGLE() : +PCB_IO_EAGLE::PCB_IO_EAGLE() : PCB_IO( wxS( "Eagle" ) ), m_rules( new ERULES() ), m_xpath( new XPATH() ), m_progressReporter( nullptr ), diff --git a/pcbnew/pcb_io/eagle/pcb_io_eagle.h b/pcbnew/pcb_io/eagle/pcb_io_eagle.h index 0e226388e3..f276a4801f 100644 --- a/pcbnew/pcb_io/eagle/pcb_io_eagle.h +++ b/pcbnew/pcb_io/eagle/pcb_io_eagle.h @@ -131,8 +131,6 @@ struct ERULES class PCB_IO_EAGLE : public PCB_IO, public LAYER_REMAPPABLE_PLUGIN { public: - const wxString PluginName() const override { return wxT( "Eagle" ); } - PLUGIN_FILE_DESC GetBoardFileDesc() const override { return PLUGIN_FILE_DESC( _HKI( "Eagle ver. 6.x XML PCB files" ), { "brd" } ); @@ -356,9 +354,6 @@ private: ///< simply packagename if FootprintLoad() or ///< FootprintEnumberate() - const STRING_UTF8_MAP* m_props; ///< passed via Save() or Load(), no ownership, may be NULL. - BOARD* m_board; ///< which BOARD is being worked on, no ownership here - PROGRESS_REPORTER* m_progressReporter; ///< optional; may be nullptr unsigned m_doneCount; unsigned m_lastProgressCount; diff --git a/pcbnew/pcb_io/easyeda/pcb_io_easyeda_plugin.cpp b/pcbnew/pcb_io/easyeda/pcb_io_easyeda_plugin.cpp index 6bb2f2c905..51888bdba4 100644 --- a/pcbnew/pcb_io/easyeda/pcb_io_easyeda_plugin.cpp +++ b/pcbnew/pcb_io/easyeda/pcb_io_easyeda_plugin.cpp @@ -43,10 +43,8 @@ #include -PCB_IO_EASYEDA::PCB_IO_EASYEDA() +PCB_IO_EASYEDA::PCB_IO_EASYEDA() : PCB_IO( wxS( "EasyEDA (JLCEDA) Standard" ) ) { - m_board = nullptr; - m_props = nullptr; } diff --git a/pcbnew/pcb_io/easyeda/pcb_io_easyeda_plugin.h b/pcbnew/pcb_io/easyeda/pcb_io_easyeda_plugin.h index 12fd495a2c..5a804bc63a 100644 --- a/pcbnew/pcb_io/easyeda/pcb_io_easyeda_plugin.h +++ b/pcbnew/pcb_io/easyeda/pcb_io_easyeda_plugin.h @@ -32,11 +32,6 @@ class PCB_IO_EASYEDA : public PCB_IO { public: - const wxString PluginName() const override - { - return wxS( "EasyEDA (JLCEDA) Standard" ); - } - PLUGIN_FILE_DESC GetBoardFileDesc() const override { return PLUGIN_FILE_DESC( _HKI( "EasyEDA (JLCEDA) Std files" ), { "json", "zip" } ); @@ -74,8 +69,6 @@ public: ~PCB_IO_EASYEDA(); private: - const STRING_UTF8_MAP* m_props; - BOARD* m_board; std::map> m_loadedFootprints; }; diff --git a/pcbnew/pcb_io/easyedapro/pcb_io_easyedapro.cpp b/pcbnew/pcb_io/easyedapro/pcb_io_easyedapro.cpp index b70db93719..62ae10819f 100644 --- a/pcbnew/pcb_io/easyedapro/pcb_io_easyedapro.cpp +++ b/pcbnew/pcb_io/easyedapro/pcb_io_easyedapro.cpp @@ -55,10 +55,8 @@ struct PCB_IO_EASYEDAPRO::PRJ_DATA }; -PCB_IO_EASYEDAPRO::PCB_IO_EASYEDAPRO() +PCB_IO_EASYEDAPRO::PCB_IO_EASYEDAPRO() : PCB_IO( wxS( "EasyEDA (JLCEDA) Professional" ) ) { - m_board = nullptr; - m_props = nullptr; } diff --git a/pcbnew/pcb_io/easyedapro/pcb_io_easyedapro.h b/pcbnew/pcb_io/easyedapro/pcb_io_easyedapro.h index 3fb78d2bcf..f5f54a2bac 100644 --- a/pcbnew/pcb_io/easyedapro/pcb_io_easyedapro.h +++ b/pcbnew/pcb_io/easyedapro/pcb_io_easyedapro.h @@ -35,11 +35,6 @@ class PCB_IO_EASYEDAPRO : public PCB_IO, public PROJECT_CHOOSER_PLUGIN { public: - const wxString PluginName() const override - { - return wxS( "EasyEDA (JLCEDA) Professional" ); - } - PLUGIN_FILE_DESC GetBoardFileDesc() const override { return PLUGIN_FILE_DESC( _HKI( "EasyEDA (JLCEDA) Pro project" ), { "epro", "zip" } ); @@ -85,9 +80,6 @@ private: PRJ_DATA* m_projectData = nullptr; void LoadAllDataFromProject( const wxString& aLibraryPath, const nlohmann::json& aProject ); - - const STRING_UTF8_MAP* m_props; - BOARD* m_board; }; diff --git a/pcbnew/pcb_io/fabmaster/pcb_io_fabmaster.cpp b/pcbnew/pcb_io/fabmaster/pcb_io_fabmaster.cpp index bb2c6363f1..18d197576e 100644 --- a/pcbnew/pcb_io/fabmaster/pcb_io_fabmaster.cpp +++ b/pcbnew/pcb_io/fabmaster/pcb_io_fabmaster.cpp @@ -33,10 +33,8 @@ #include -PCB_IO_FABMASTER::PCB_IO_FABMASTER() +PCB_IO_FABMASTER::PCB_IO_FABMASTER() : PCB_IO( wxS( "Fabmaster" ) ) { - m_board = nullptr; - m_props = nullptr; } @@ -45,12 +43,6 @@ PCB_IO_FABMASTER::~PCB_IO_FABMASTER() } -const wxString PCB_IO_FABMASTER::PluginName() const -{ - return wxT( "Fabmaster" ); -} - - PLUGIN_FILE_DESC PCB_IO_FABMASTER::GetBoardFileDesc() const { return PLUGIN_FILE_DESC( _HKI( "Fabmaster PCB files" ), { "txt", "fab" } ); diff --git a/pcbnew/pcb_io/fabmaster/pcb_io_fabmaster.h b/pcbnew/pcb_io/fabmaster/pcb_io_fabmaster.h index 6451db4c18..b356d76ca0 100644 --- a/pcbnew/pcb_io/fabmaster/pcb_io_fabmaster.h +++ b/pcbnew/pcb_io/fabmaster/pcb_io_fabmaster.h @@ -33,8 +33,6 @@ class PCB_IO_FABMASTER : public PCB_IO { public: - const wxString PluginName() const override; - PLUGIN_FILE_DESC GetBoardFileDesc() const override; BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe, @@ -51,9 +49,6 @@ public: ~PCB_IO_FABMASTER(); private: - const STRING_UTF8_MAP* m_props; - BOARD* m_board; - FABMASTER m_fabmaster; }; diff --git a/pcbnew/pcb_io/geda/pcb_io_geda.cpp b/pcbnew/pcb_io/geda/pcb_io_geda.cpp index b8ca3ea92d..4a1267af7a 100644 --- a/pcbnew/pcb_io/geda/pcb_io_geda.cpp +++ b/pcbnew/pcb_io/geda/pcb_io_geda.cpp @@ -792,7 +792,7 @@ bool GPCB_FPL_CACHE::testFlags( const wxString& aFlag, long aMask, const wxChar* } -PCB_IO_GEDA::PCB_IO_GEDA() : +PCB_IO_GEDA::PCB_IO_GEDA() : PCB_IO( wxS( "gEDA PCB" ) ), m_cache( nullptr ), m_ctl( 0 ) { @@ -801,7 +801,7 @@ PCB_IO_GEDA::PCB_IO_GEDA() : } -PCB_IO_GEDA::PCB_IO_GEDA( int aControlFlags ) : +PCB_IO_GEDA::PCB_IO_GEDA( int aControlFlags ) : PCB_IO( wxS( "gEDA PCB" ) ), m_cache( nullptr ), m_ctl( aControlFlags ) { diff --git a/pcbnew/pcb_io/geda/pcb_io_geda.h b/pcbnew/pcb_io/geda/pcb_io_geda.h index ac2ec202ae..015ccad88a 100644 --- a/pcbnew/pcb_io/geda/pcb_io_geda.h +++ b/pcbnew/pcb_io/geda/pcb_io_geda.h @@ -47,11 +47,6 @@ class GPCB_FPL_CACHE; class PCB_IO_GEDA : public PCB_IO { public: - const wxString PluginName() const override - { - return wxT( "gEDA PCB" ); - } - PLUGIN_FILE_DESC GetFootprintFileDesc() const override { return PLUGIN_FILE_DESC( _HKI( "gEDA PCB footprint file" ), { "fp" } ); @@ -108,7 +103,6 @@ private: protected: wxString m_error; ///< for throwing exceptions - const STRING_UTF8_MAP* m_props; ///< passed via Save() or Load(), no ownership, may be NULL. GPCB_FPL_CACHE* m_cache; ///< Footprint library cache. int m_ctl; LINE_READER* m_reader; ///< no ownership here. diff --git a/pcbnew/pcb_io/ipc2581/pcb_io_ipc2581.cpp b/pcbnew/pcb_io/ipc2581/pcb_io_ipc2581.cpp index fedba78c44..801f36d72e 100644 --- a/pcbnew/pcb_io/ipc2581/pcb_io_ipc2581.cpp +++ b/pcbnew/pcb_io/ipc2581/pcb_io_ipc2581.cpp @@ -72,12 +72,6 @@ void PCB_IO_IPC2581::clearLoadedFootprints() } -const wxString PCB_IO_IPC2581::PluginName() const -{ - return wxT( "IPC-2581" ); -} - - std::vector PCB_IO_IPC2581::GetImportedCachedLibraryFootprints() { std::vector retval; diff --git a/pcbnew/pcb_io/ipc2581/pcb_io_ipc2581.h b/pcbnew/pcb_io/ipc2581/pcb_io_ipc2581.h index 6b212a09dc..b9f7384055 100644 --- a/pcbnew/pcb_io/ipc2581/pcb_io_ipc2581.h +++ b/pcbnew/pcb_io/ipc2581/pcb_io_ipc2581.h @@ -53,7 +53,7 @@ public: * @brief PCB_IO_IPC2581 * */ - PCB_IO_IPC2581() + PCB_IO_IPC2581() : PCB_IO( wxS( "IPC-2581" ) ) { m_show_layer_mapping_warnings = false; m_total_bytes = 0; @@ -74,11 +74,6 @@ public: ~PCB_IO_IPC2581() override; - /** - * @brief PCB_IO_IPC2581 - */ - const wxString PluginName() const override; - /** * */ 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 957d7167d4..b71c7cba9b 100644 --- a/pcbnew/pcb_io/kicad_legacy/pcb_io_kicad_legacy.cpp +++ b/pcbnew/pcb_io/kicad_legacy/pcb_io_kicad_legacy.cpp @@ -3287,10 +3287,8 @@ bool PCB_IO_KICAD_LEGACY::IsFootprintLibWritable( const wxString& aLibraryPath ) } -PCB_IO_KICAD_LEGACY::PCB_IO_KICAD_LEGACY() : +PCB_IO_KICAD_LEGACY::PCB_IO_KICAD_LEGACY() : PCB_IO( wxS( "KiCad-Legacy" ) ), m_cu_count( 16 ), // for FootprintLoad() - m_board( nullptr ), - m_props( nullptr ), m_progressReporter( nullptr ), m_lastProgressLine( 0 ), m_lineCount( 0 ), 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 20f59b1044..a0b6c30b9a 100644 --- a/pcbnew/pcb_io/kicad_legacy/pcb_io_kicad_legacy.h +++ b/pcbnew/pcb_io/kicad_legacy/pcb_io_kicad_legacy.h @@ -66,11 +66,6 @@ public: PCB_IO_KICAD_LEGACY(); ~PCB_IO_KICAD_LEGACY(); - const wxString PluginName() const override - { - return wxT( "KiCad-Legacy" ); - } - PLUGIN_FILE_DESC GetBoardFileDesc() const override { return PLUGIN_FILE_DESC( _HKI( "Eagle ver. 6.x XML PCB files" ), { "brd" } ); @@ -192,9 +187,6 @@ protected: int m_cu_count; wxString m_error; ///< for throwing exceptions - BOARD* m_board; ///< which BOARD, no ownership here - const STRING_UTF8_MAP* m_props; ///< passed via Save() or Load(), no ownership, - ///< may be NULL. PROGRESS_REPORTER* m_progressReporter; ///< may be NULL, no ownership unsigned m_lastProgressLine; unsigned m_lineCount; ///< for progress reporting 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 17be88b8df..37695011d8 100644 --- a/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.cpp +++ b/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.cpp @@ -2397,7 +2397,7 @@ void PCB_IO_KICAD_SEXPR::format( const ZONE* aZone, int aNestLevel ) const } -PCB_IO_KICAD_SEXPR::PCB_IO_KICAD_SEXPR( int aControlFlags ) : +PCB_IO_KICAD_SEXPR::PCB_IO_KICAD_SEXPR( int aControlFlags ) : PCB_IO( wxS( "KiCad" ) ), m_cache( nullptr ), m_ctl( aControlFlags ), m_mapping( new NETINFO_MAPPING() ) 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 b9d087fc6f..22380e9560 100644 --- a/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.h +++ b/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.h @@ -277,11 +277,6 @@ public: class PCB_IO_KICAD_SEXPR : public PCB_IO { public: - const wxString PluginName() const override - { - return wxT( "KiCad" ); - } - PLUGIN_FILE_DESC GetBoardFileDesc() const override { // Would have used wildcards_and_files_ext.cpp's KiCadPcbFileExtension, @@ -447,9 +442,7 @@ private: protected: wxString m_error; ///< for throwing exceptions - BOARD* m_board; ///< which BOARD, no ownership here - const STRING_UTF8_MAP* m_props; ///< passed via Save() or Load(), no ownership, may be NULL FP_CACHE* m_cache; ///< Footprint library cache LINE_READER* m_reader; ///< no ownership diff --git a/pcbnew/pcb_io/pcad/pcb_io_pcad.cpp b/pcbnew/pcb_io/pcad/pcb_io_pcad.cpp index a1b3dfcae6..ce89d087bb 100644 --- a/pcbnew/pcb_io/pcad/pcb_io_pcad.cpp +++ b/pcbnew/pcb_io/pcad/pcb_io_pcad.cpp @@ -43,10 +43,8 @@ using namespace PCAD2KICAD; -PCB_IO_PCAD::PCB_IO_PCAD() +PCB_IO_PCAD::PCB_IO_PCAD() : PCB_IO( wxS( "P-Cad" ) ) { - m_board = nullptr; - m_props = nullptr; } diff --git a/pcbnew/pcb_io/pcad/pcb_io_pcad.h b/pcbnew/pcb_io/pcad/pcb_io_pcad.h index d10740ba34..74bdb99e16 100644 --- a/pcbnew/pcb_io/pcad/pcb_io_pcad.h +++ b/pcbnew/pcb_io/pcad/pcb_io_pcad.h @@ -39,8 +39,6 @@ public: PCB_IO_PCAD(); ~PCB_IO_PCAD(); - const wxString PluginName() const override { return wxT( "P-Cad" ); } - PLUGIN_FILE_DESC GetBoardFileDesc() const override { return PLUGIN_FILE_DESC( _HKI( "P-Cad 200x ASCII PCB files" ), { "pcb" } ); @@ -57,10 +55,6 @@ public: // No support for libraries.... return 0; } - -private: - const STRING_UTF8_MAP* m_props; - BOARD* m_board; }; #endif // PCB_IO_PCAD_H_ diff --git a/pcbnew/pcb_io/pcb_io.cpp b/pcbnew/pcb_io/pcb_io.cpp index 0dbe77e5f8..df59c68751 100644 --- a/pcbnew/pcb_io/pcb_io.cpp +++ b/pcbnew/pcb_io/pcb_io.cpp @@ -36,7 +36,7 @@ #define FMT_UNIMPLEMENTED wxT( "Plugin \"%s\" does not implement the \"%s\" function." ) #define NOT_IMPLEMENTED( aCaller ) \ THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, \ - PluginName(), \ + GetName(), \ wxString::FromUTF8( aCaller ) ) ); diff --git a/pcbnew/pcb_io/pcb_io.h b/pcbnew/pcb_io/pcb_io.h index e4f3bc1d8e..2d15b191c1 100644 --- a/pcbnew/pcb_io/pcb_io.h +++ b/pcbnew/pcb_io/pcb_io.h @@ -25,16 +25,17 @@ #ifndef PCB_IO_H_ #define PCB_IO_H_ +#include +#include +#include + #include #include #include #include #include -#include -#include class BOARD; -class PLUGIN; class FOOTPRINT; class STRING_UTF8_MAP; class PROJECT; @@ -68,14 +69,9 @@ class PROGRESS_REPORTER; * } * */ -class PCB_IO +class PCB_IO : public IO_BASE { public: - /** - * Return a brief hard coded name for this PCB_IO. - */ - virtual const wxString PluginName() const = 0; - /** * Returns board file description for the PCB_IO. */ @@ -456,6 +452,18 @@ public: } }; #endif + +protected: + PCB_IO( const wxString& aName ) : IO_BASE( aName ), + m_board( nullptr ), + m_props( nullptr ) + {} + + /// The board BOARD being worked on, no ownership here + BOARD* m_board; + + /// Properties passed via Save() or Load(), no ownership, may be NULL. + const STRING_UTF8_MAP* m_props; }; #endif // PCB_IO_H_ \ No newline at end of file