diff --git a/eeschema/netlist_exporters/netlist_exporter_base.h b/eeschema/netlist_exporters/netlist_exporter_base.h index 4ba369956d..3d95ec9382 100644 --- a/eeschema/netlist_exporters/netlist_exporter_base.h +++ b/eeschema/netlist_exporters/netlist_exporter_base.h @@ -108,7 +108,7 @@ protected: std::set m_libParts; /// The schematic we're generating a netlist for - SCHEMATIC* m_schematic; + SCHEMATIC_IFACE* m_schematic; /// The schematic's CurrentSheet when we entered. Restore on exiting. SCH_SHEET_PATH m_savedCurrentSheet; @@ -163,7 +163,7 @@ public: * @param aMasterList we take ownership of this here. * @param aLibTable is the symbol library table of the project. */ - NETLIST_EXPORTER_BASE( SCHEMATIC* aSchematic ) : + NETLIST_EXPORTER_BASE( SCHEMATIC_IFACE* aSchematic ) : m_schematic( aSchematic ) { wxASSERT( aSchematic ); diff --git a/eeschema/netlist_exporters/netlist_exporter_pspice.h b/eeschema/netlist_exporters/netlist_exporter_pspice.h index b6a3bbbdf0..469e2b7158 100644 --- a/eeschema/netlist_exporters/netlist_exporter_pspice.h +++ b/eeschema/netlist_exporters/netlist_exporter_pspice.h @@ -101,7 +101,7 @@ struct SPICE_ITEM class NETLIST_EXPORTER_PSPICE : public NETLIST_EXPORTER_BASE { public: - NETLIST_EXPORTER_PSPICE( SCHEMATIC* aSchematic ) : + NETLIST_EXPORTER_PSPICE( SCHEMATIC_IFACE* aSchematic ) : NETLIST_EXPORTER_BASE( aSchematic ) { } diff --git a/eeschema/schematic.h b/eeschema/schematic.h index ccf0fabc4d..abd864a9c1 100644 --- a/eeschema/schematic.h +++ b/eeschema/schematic.h @@ -35,13 +35,27 @@ class SCH_SHEET; class SCH_SHEET_LIST; +class SCHEMATIC_IFACE +{ +public: + SCHEMATIC_IFACE() {}; + virtual ~SCHEMATIC_IFACE() {}; + + virtual CONNECTION_GRAPH* ConnectionGraph() const = 0; + virtual SCH_SHEET_LIST GetSheets() const = 0; + virtual void SetCurrentSheet( const SCH_SHEET_PATH& aPath ) = 0; + virtual SCH_SHEET_PATH& CurrentSheet() const = 0; + virtual wxString GetFileName() const = 0; + virtual PROJECT& Prj() const = 0; +}; + /** * Holds all the data relating to one schematic * A schematic may consist of one or more sheets (and one root sheet) * Right now, eeschema can have only one schematic open at a time, but this could change. * Please keep this possibility in mind when adding to this object. */ -class SCHEMATIC : public EDA_ITEM +class SCHEMATIC : public SCHEMATIC_IFACE, public EDA_ITEM { friend class SCH_EDIT_FRAME; @@ -71,7 +85,7 @@ private: public: SCHEMATIC( PROJECT* aPrj ); - ~SCHEMATIC(); + virtual ~SCHEMATIC(); virtual wxString GetClass() const override { @@ -82,7 +96,7 @@ public: void Reset(); /// Return a reference to the project this schematic is part of - PROJECT& Prj() const + PROJECT& Prj() const override { return *m_project; } @@ -94,7 +108,7 @@ public: * TODO: can this be cached? * @return a SCH_SHEET_LIST containing the schematic hierarchy */ - SCH_SHEET_LIST GetSheets() const + SCH_SHEET_LIST GetSheets() const override { return SCH_SHEET_LIST( m_rootSheet ); } @@ -122,19 +136,19 @@ public: SCH_SCREEN* RootScreen() const; /// Helper to retrieve the filename from the root sheet screen - wxString GetFileName() const; + wxString GetFileName() const override; - SCH_SHEET_PATH& CurrentSheet() const + SCH_SHEET_PATH& CurrentSheet() const override { return *m_currentSheet; } - void SetCurrentSheet( const SCH_SHEET_PATH& aPath ) + void SetCurrentSheet( const SCH_SHEET_PATH& aPath ) override { *m_currentSheet = aPath; } - CONNECTION_GRAPH* ConnectionGraph() const + CONNECTION_GRAPH* ConnectionGraph() const override { return m_connectionGraph; } diff --git a/eeschema/sim/netlist_exporter_pspice_sim.h b/eeschema/sim/netlist_exporter_pspice_sim.h index a1bd47aedf..e0854162f1 100644 --- a/eeschema/sim/netlist_exporter_pspice_sim.h +++ b/eeschema/sim/netlist_exporter_pspice_sim.h @@ -46,7 +46,7 @@ struct SPICE_DC_PARAMS class NETLIST_EXPORTER_PSPICE_SIM : public NETLIST_EXPORTER_PSPICE { public: - NETLIST_EXPORTER_PSPICE_SIM( SCHEMATIC* aSchematic ) : + NETLIST_EXPORTER_PSPICE_SIM( SCHEMATIC_IFACE* aSchematic ) : NETLIST_EXPORTER_PSPICE( aSchematic ) { }