Introduce main base class for all IO loaders

This commit is contained in:
Ian McInerney 2023-12-24 04:31:22 +00:00
parent 7d25675e2b
commit cad91312aa
52 changed files with 126 additions and 322 deletions

View File

@ -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;

View File

@ -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<LIB_SYMBOL*> ParseLibComponent( const std::map<wxString, wxString>& 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

View File

@ -37,12 +37,6 @@
#include <wx/txtstrm.h>
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 ) )

View File

@ -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_

View File

@ -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()

View File

@ -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" ),

View File

@ -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;

View File

@ -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<int, bool> units;
};
REPORTER* m_reporter; ///< Reporter for warnings/errors
///< Map references to missing symbol units data
std::map<wxString, EAGLE_MISSING_CMP> m_missingCmps;
@ -261,7 +250,6 @@ private:
SCH_IO::SCH_IO_RELEASER m_pi; ///< PI to create KiCad symbol library.
std::unique_ptr<STRING_UTF8_MAP> 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

View File

@ -40,13 +40,6 @@
#include <wx/wfstream.h>
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 )

View File

@ -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
};

View File

@ -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" ) ) )

View File

@ -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
};

View File

@ -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 )
{
}

View File

@ -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" ),

View File

@ -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 )

View File

@ -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

View File

@ -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 );
}

View File

@ -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<wxString> m_currentPath; ///< Stack to maintain nested sheet paths

View File

@ -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;

View File

@ -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_

View File

@ -23,6 +23,7 @@
#ifndef SCH_IO_H_
#define SCH_IO_H_
#include <io/io_base.h>
#include <sch_io/sch_io_mgr.h>
#include <import_export.h>
#include <map>
@ -53,27 +54,12 @@
* }
* </pre>
*/
class SCH_IO
class SCH_IO : public IO_BASE
{
public:
//-----<PUBLIC SCH_IO API>-------------------------------------------------
/**
* 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 )
{}
};

76
include/io/io_base.h Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef IO_BASE_H_
#define IO_BASE_H_
#include <wx/string.h>
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_

View File

@ -39,10 +39,8 @@
#include <compoundfilereader.h>
#include <utf.h>
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" } );

View File

@ -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_

View File

@ -39,10 +39,8 @@
#include <compoundfilereader.h>
#include <utf.h>
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" } );

View File

@ -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_

View File

@ -39,10 +39,8 @@
#include <compoundfilereader.h>
#include <utf.h>
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;
}

View File

@ -37,9 +37,6 @@ class PCB_IO_ALTIUM_DESIGNER : public PCB_IO
{
public:
// -----<PUBLIC PCB_IO API>--------------------------------------------------
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<wxString, std::vector<std::unique_ptr<ALTIUM_COMPOUND_FILE>>> m_fplibFiles;
void loadAltiumLibrary( const wxString& aLibraryPath );

View File

@ -30,10 +30,8 @@
#include <compoundfilereader.h>
#include <utf.h>
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" } );

View File

@ -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;
};

View File

@ -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 );

View File

@ -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<wxString, NAME_TO_FOOTPRINT_MAP> m_cache;
std::map<wxString, long long> m_timestamps;
const STRING_UTF8_MAP* m_props;
BOARD* m_board;
std::vector<FOOTPRINT*> m_loaded_footprints;
bool m_show_layer_mapping_warnings;

View File

@ -220,7 +220,7 @@ void ERULES::parse( wxXmlNode* aRules, std::function<void()> 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 ),

View File

@ -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;

View File

@ -43,10 +43,8 @@
#include <core/map_helpers.h>
PCB_IO_EASYEDA::PCB_IO_EASYEDA()
PCB_IO_EASYEDA::PCB_IO_EASYEDA() : PCB_IO( wxS( "EasyEDA (JLCEDA) Standard" ) )
{
m_board = nullptr;
m_props = nullptr;
}

View File

@ -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<wxString, std::unique_ptr<FOOTPRINT>> m_loadedFootprints;
};

View File

@ -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;
}

View File

@ -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;
};

View File

@ -33,10 +33,8 @@
#include <macros.h>
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" } );

View File

@ -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;
};

View File

@ -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 )
{

View File

@ -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.

View File

@ -72,12 +72,6 @@ void PCB_IO_IPC2581::clearLoadedFootprints()
}
const wxString PCB_IO_IPC2581::PluginName() const
{
return wxT( "IPC-2581" );
}
std::vector<FOOTPRINT*> PCB_IO_IPC2581::GetImportedCachedLibraryFootprints()
{
std::vector<FOOTPRINT*> retval;

View File

@ -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;
/**
*
*/

View File

@ -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 ),

View File

@ -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

View File

@ -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() )

View File

@ -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

View File

@ -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;
}

View File

@ -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_

View File

@ -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 ) ) );

View File

@ -25,16 +25,17 @@
#ifndef PCB_IO_H_
#define PCB_IO_H_
#include <io/io_base.h>
#include <plugin_file_desc.h>
#include <pcb_io/pcb_io_mgr.h>
#include <cstdint>
#include <config.h>
#include <vector>
#include <wx/arrstr.h>
#include <i18n_utility.h>
#include <plugin_file_desc.h>
#include <pcb_io/pcb_io_mgr.h>
class BOARD;
class PLUGIN;
class FOOTPRINT;
class STRING_UTF8_MAP;
class PROJECT;
@ -68,14 +69,9 @@ class PROGRESS_REPORTER;
* }
* </pre>
*/
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_