diff --git a/eeschema/dialogs/dialog_sim_model.cpp b/eeschema/dialogs/dialog_sim_model.cpp index 510c03c325..5be44d8ea4 100644 --- a/eeschema/dialogs/dialog_sim_model.cpp +++ b/eeschema/dialogs/dialog_sim_model.cpp @@ -203,11 +203,10 @@ bool DIALOG_SIM_MODEL::TransferDataToWindow() if( !loadLibrary( libraryFilename ) ) { m_libraryPathText->ChangeValue( libraryFilename ); - m_curModelType = SIM_MODEL::ReadTypeFromFields( m_fields, &reporter ); + m_curModelType = SIM_MODEL::ReadTypeFromFields( m_fields, reporter ); // load library will mangle the set reporter - m_libraryModelsMgr.SetReporter( &reporter ); - m_libraryModelsMgr.CreateModel( nullptr, m_sortedPartPins, m_fields ); + m_libraryModelsMgr.CreateModel( nullptr, m_sortedPartPins, m_fields, reporter ); m_modelNameChoice->Append( _( "" ) ); m_modelNameChoice->SetSelection( 0 ); @@ -285,20 +284,18 @@ bool DIALOG_SIM_MODEL::TransferDataToWindow() m_rbBuiltinModel->SetValue( true ); msg.clear(); - m_curModelType = SIM_MODEL::ReadTypeFromFields( m_fields, &reporter ); + m_curModelType = SIM_MODEL::ReadTypeFromFields( m_fields, reporter ); if( reporter.HasMessage() ) DisplayErrorMessage( this, msg ); } - m_builtinModelsMgr.SetReporter( &reporter ); - for( SIM_MODEL::TYPE type : SIM_MODEL::TYPE_ITERATOR() ) { if( m_rbBuiltinModel->GetValue() && type == m_curModelType ) { msg.clear(); - m_builtinModelsMgr.CreateModel( m_fields, m_sortedPartPins, false ); + m_builtinModelsMgr.CreateModel( m_fields, m_sortedPartPins, false, reporter ); if( reporter.HasMessage() ) { @@ -308,7 +305,7 @@ bool DIALOG_SIM_MODEL::TransferDataToWindow() } else { - m_builtinModelsMgr.CreateModel( type, m_sortedPartPins ); + m_builtinModelsMgr.CreateModel( type, m_sortedPartPins, reporter ); } SIM_MODEL::DEVICE_T deviceTypeT = SIM_MODEL::TypeInfo( type ).deviceType; @@ -723,9 +720,8 @@ bool DIALOG_SIM_MODEL::loadLibrary( const wxString& aLibraryP wxString msg; WX_STRING_REPORTER reporter( &msg ); - m_libraryModelsMgr.SetReporter( &reporter ); m_libraryModelsMgr.SetForceFullParse(); - m_libraryModelsMgr.SetLibrary( aLibraryPath ); + m_libraryModelsMgr.SetLibrary( aLibraryPath, reporter ); if( reporter.HasMessage() ) { @@ -738,9 +734,9 @@ bool DIALOG_SIM_MODEL::loadLibrary( const wxString& aLibraryP for( const auto& [baseModelName, baseModel] : library()->GetModels() ) { if( baseModelName == modelName ) - m_libraryModelsMgr.CreateModel( &baseModel, m_sortedPartPins, m_fields ); + m_libraryModelsMgr.CreateModel( &baseModel, m_sortedPartPins, m_fields, reporter ); else - m_libraryModelsMgr.CreateModel( &baseModel, m_sortedPartPins ); + m_libraryModelsMgr.CreateModel( &baseModel, m_sortedPartPins, reporter ); } if( reporter.HasMessage() ) diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp index 56fa9e8c26..f1aa0c548d 100644 --- a/eeschema/erc.cpp +++ b/eeschema/erc.cpp @@ -1048,7 +1048,7 @@ int ERC_TESTER::TestSimModelIssues() WX_STRING_REPORTER reporter( &msg ); SCH_SHEET_LIST sheets = m_schematic->GetSheets(); int err_count = 0; - SIM_LIB_MGR libMgr( &m_schematic->Prj(), &reporter ); + SIM_LIB_MGR libMgr( &m_schematic->Prj() ); for( SCH_SHEET_PATH& sheet : sheets ) { @@ -1066,7 +1066,7 @@ int ERC_TESTER::TestSimModelIssues() // Reset for each symbol msg.Clear(); - SIM_LIBRARY::MODEL model = libMgr.CreateModel( &sheet, *symbol ); + SIM_LIBRARY::MODEL model = libMgr.CreateModel( &sheet, *symbol, reporter ); if( !msg.IsEmpty() ) { diff --git a/eeschema/netlist_exporters/netlist_exporter_spice.cpp b/eeschema/netlist_exporters/netlist_exporter_spice.cpp index 9a0086ac3f..1b2f24893b 100644 --- a/eeschema/netlist_exporters/netlist_exporter_spice.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_spice.cpp @@ -104,7 +104,6 @@ NETLIST_EXPORTER_SPICE::NETLIST_EXPORTER_SPICE( SCHEMATIC_IFACE* aSchematic, bool NETLIST_EXPORTER_SPICE::WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions, REPORTER& aReporter ) { - m_libMgr.SetReporter( &aReporter ); FILE_OUTPUTFORMATTER formatter( aOutFileName, wxT( "wt" ), '\'' ); return DoWriteNetlist( wxEmptyString, aNetlistOptions, formatter, aReporter ); } @@ -156,8 +155,6 @@ bool NETLIST_EXPORTER_SPICE::ReadSchematicAndLibraries( unsigned aNetlistOptions std::set refNames; // Set of reference names to check for duplication. int ncCounter = 1; - m_libMgr.SetReporter( &aReporter ); - ReadDirectives( aNetlistOptions ); m_nets.clear(); @@ -227,7 +224,7 @@ bool NETLIST_EXPORTER_SPICE::ReadSchematicAndLibraries( unsigned aNetlistOptions } readRefName( sheet, *symbol, spiceItem, refNames ); - readModel( sheet, *symbol, spiceItem ); + readModel( sheet, *symbol, spiceItem, aReporter ); readPinNumbers( *symbol, spiceItem, pins ); readPinNetNames( *symbol, spiceItem, pins, ncCounter ); @@ -237,8 +234,6 @@ bool NETLIST_EXPORTER_SPICE::ReadSchematicAndLibraries( unsigned aNetlistOptions } } - m_libMgr.SetReporter( nullptr ); - return !aReporter.HasMessage(); } @@ -446,9 +441,9 @@ void NETLIST_EXPORTER_SPICE::readRefName( SCH_SHEET_PATH& aSheet, SCH_SYMBOL& aS void NETLIST_EXPORTER_SPICE::readModel( SCH_SHEET_PATH& aSheet, SCH_SYMBOL& aSymbol, - SPICE_ITEM& aItem ) + SPICE_ITEM& aItem, REPORTER& aReporter ) { - SIM_LIBRARY::MODEL libModel = m_libMgr.CreateModel( &aSheet, aSymbol ); + SIM_LIBRARY::MODEL libModel = m_libMgr.CreateModel( &aSheet, aSymbol, aReporter ); aItem.baseModelName = libModel.name; aItem.model = &libModel.model; diff --git a/eeschema/netlist_exporters/netlist_exporter_spice.h b/eeschema/netlist_exporters/netlist_exporter_spice.h index 2ac03d7b84..39b2dd60b7 100644 --- a/eeschema/netlist_exporters/netlist_exporter_spice.h +++ b/eeschema/netlist_exporters/netlist_exporter_spice.h @@ -146,7 +146,8 @@ protected: private: void readRefName( SCH_SHEET_PATH& aSheet, SCH_SYMBOL& aSymbol, SPICE_ITEM& aItem, std::set& aRefNames ); - void readModel( SCH_SHEET_PATH& aSheet, SCH_SYMBOL& aSymbol, SPICE_ITEM& aItem ); + void readModel( SCH_SHEET_PATH& aSheet, SCH_SYMBOL& aSymbol, SPICE_ITEM& aItem, + REPORTER& aReporter ); void readPinNumbers( SCH_SYMBOL& aSymbol, SPICE_ITEM& aItem, const std::vector& aPins ); void readPinNetNames( SCH_SYMBOL& aSymbol, SPICE_ITEM& aItem, diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 96a845f9d5..32aac1594a 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -1406,8 +1406,6 @@ void SCH_EDIT_FRAME::RefreshOperatingPointDisplay() SIM_LIB_MGR simLibMgr( &Prj() ); NULL_REPORTER devnull; - simLibMgr.SetReporter( &devnull ); - // Patch for bug early in V7.99 dev if( settings.m_OPO_VRange.EndsWith( 'A' ) ) settings.m_OPO_VRange[ settings.m_OPO_VRange.Length() - 1 ] = 'V'; @@ -1493,7 +1491,7 @@ void SCH_EDIT_FRAME::RefreshOperatingPointDisplay() } else { - SIM_MODEL& model = simLibMgr.CreateModel( &GetCurrentSheet(), *symbol ).model; + SIM_MODEL& model = simLibMgr.CreateModel( &GetCurrentSheet(), *symbol, devnull ).model; SPICE_ITEM spiceItem; spiceItem.refName = ref; diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index 5a8836f2dc..f7ad13baca 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -715,9 +715,10 @@ void SCH_FIELD::OnScintillaCharAdded( SCINTILLA_TRICKS* aScintillaTricks, // SPICE operating points use ':' syntax for ports if( SCH_SYMBOL* symbol = dynamic_cast( parent ) ) { + NULL_REPORTER devnull; SCH_SHEET_PATH& sheet = schematic->CurrentSheet(); SIM_LIB_MGR mgr( &schematic->Prj() ); - SIM_MODEL& model = mgr.CreateModel( &sheet, *symbol ).model; + SIM_MODEL& model = mgr.CreateModel( &sheet, *symbol, devnull ).model; for( wxString pin : model.GetPinNames() ) { diff --git a/eeschema/sim/kibis/ibis_parser.h b/eeschema/sim/kibis/ibis_parser.h index 0b61dd1da6..00c0ef2203 100644 --- a/eeschema/sim/kibis/ibis_parser.h +++ b/eeschema/sim/kibis/ibis_parser.h @@ -49,13 +49,11 @@ #include -#define IBIS_REPORTER REPORTER - class IBIS_ANY { public: - IBIS_ANY( IBIS_REPORTER* aReporter ) { m_reporter = aReporter; }; - IBIS_REPORTER* m_reporter; + IBIS_ANY( REPORTER* aReporter ) { m_reporter = aReporter; }; + REPORTER* m_reporter; /** @brief Print a message * @@ -64,11 +62,12 @@ public: * @param aMsg Message * @param aSeverity Message sevirity */ - void Report( std::string aMsg, SEVERITY aSeverity = RPT_SEVERITY_INFO ) + void Report( std::string aMsg, SEVERITY aSeverity = RPT_SEVERITY_INFO ) { if( m_reporter ) m_reporter->Report( aMsg, aSeverity ); }; + protected: /** @brief Convert a double to string using scientific notation * @@ -82,7 +81,7 @@ protected: class IBIS_INPUT : public IBIS_ANY { public: - IBIS_INPUT( IBIS_REPORTER* aReporter ) : IBIS_ANY( aReporter ){}; + IBIS_INPUT( REPORTER* aReporter ) : IBIS_ANY( aReporter ){}; /** @brief Check if the data held by the object is valid. * * @return true in case of success @@ -111,7 +110,7 @@ enum class IBIS_MATRIX_TYPE class IBIS_MATRIX : public IBIS_INPUT { public: - IBIS_MATRIX( IBIS_REPORTER* aReporter ) : IBIS_INPUT( aReporter ){}; + IBIS_MATRIX( REPORTER* aReporter ) : IBIS_INPUT( aReporter ){}; virtual ~IBIS_MATRIX(){}; IBIS_MATRIX_TYPE m_type = IBIS_MATRIX_TYPE::UNDEFINED; @@ -122,7 +121,7 @@ public: class IBIS_MATRIX_BANDED : public IBIS_MATRIX { public: - IBIS_MATRIX_BANDED( IBIS_REPORTER* aReporter ) : IBIS_MATRIX( aReporter ){}; + IBIS_MATRIX_BANDED( REPORTER* aReporter ) : IBIS_MATRIX( aReporter ){}; IBIS_MATRIX_TYPE m_type = IBIS_MATRIX_TYPE::BANDED; int m_dim = -2; int m_bandwidth = 0; @@ -134,7 +133,7 @@ public: class IBIS_MATRIX_SPARSE : public IBIS_MATRIX { public: - IBIS_MATRIX_SPARSE( IBIS_REPORTER* aReporter ) : IBIS_MATRIX( aReporter ){}; + IBIS_MATRIX_SPARSE( REPORTER* aReporter ) : IBIS_MATRIX( aReporter ){}; IBIS_MATRIX_TYPE m_type = IBIS_MATRIX_TYPE::BANDED; int m_dim = -3; std::vector m_data; @@ -146,7 +145,7 @@ public: class IBIS_MATRIX_FULL : public IBIS_MATRIX { public: - IBIS_MATRIX_FULL( IBIS_REPORTER* aReporter ) : IBIS_MATRIX( aReporter ){}; + IBIS_MATRIX_FULL( REPORTER* aReporter ) : IBIS_MATRIX( aReporter ){}; IBIS_MATRIX_TYPE m_type = IBIS_MATRIX_TYPE::FULL; int m_dim = -4; std::vector m_data; @@ -158,14 +157,14 @@ public: class IBIS_SECTION : public IBIS_INPUT { public: - IBIS_SECTION( IBIS_REPORTER* aReporter ) : IBIS_INPUT( aReporter ){}; + IBIS_SECTION( REPORTER* aReporter ) : IBIS_INPUT( aReporter ){}; }; class IbisHeader : IBIS_SECTION { public: - IbisHeader( IBIS_REPORTER* aReporter ) : IBIS_SECTION( aReporter ){}; + IbisHeader( REPORTER* aReporter ) : IBIS_SECTION( aReporter ){}; double m_ibisVersion = -1; double m_fileRevision = -1; std::string m_fileName; @@ -182,7 +181,7 @@ public: class TypMinMaxValue : public IBIS_INPUT { public: - TypMinMaxValue( IBIS_REPORTER* aReporter ) : IBIS_INPUT( aReporter ){}; + TypMinMaxValue( REPORTER* aReporter ) : IBIS_INPUT( aReporter ){}; double value[3] = { -1, -1, -1 }; bool Check() override; @@ -192,7 +191,7 @@ public: class IbisComponentPackage : public IBIS_INPUT { public: - IbisComponentPackage( IBIS_REPORTER* aReporter ) : + IbisComponentPackage( REPORTER* aReporter ) : IBIS_INPUT( aReporter ), m_Rpkg( aReporter ), m_Lpkg( aReporter ), @@ -210,7 +209,7 @@ public: class IbisComponentPin : public IBIS_INPUT { public: - IbisComponentPin( IBIS_REPORTER* aReporter ) : + IbisComponentPin( REPORTER* aReporter ) : IBIS_INPUT( aReporter ) {}; @@ -237,7 +236,7 @@ public: class IbisComponentPinMapping : public IBIS_INPUT { public: - IbisComponentPinMapping( IBIS_REPORTER* aReporter ) : + IbisComponentPinMapping( REPORTER* aReporter ) : IBIS_INPUT( aReporter ) {}; @@ -258,7 +257,7 @@ public: class IbisDiffPinEntry : public IBIS_INPUT { public: - IbisDiffPinEntry( IBIS_REPORTER* aReporter ) : + IbisDiffPinEntry( REPORTER* aReporter ) : IBIS_INPUT( aReporter ), tdelay( aReporter ) {}; @@ -276,7 +275,7 @@ public: class IbisDiffPin : IBIS_INPUT { public: - IbisDiffPin( IBIS_REPORTER* aReporter ) : + IbisDiffPin( REPORTER* aReporter ) : IBIS_INPUT( aReporter ) {}; @@ -286,7 +285,7 @@ public: class IbisComponent : public IBIS_INPUT { public: - IbisComponent( IBIS_REPORTER* aReporter ) : + IbisComponent( REPORTER* aReporter ) : IBIS_INPUT( aReporter ), m_package( aReporter ), m_diffPin( aReporter ) @@ -320,7 +319,7 @@ public: class IbisModelSelector : public IBIS_INPUT { public: - IbisModelSelector( IBIS_REPORTER* aReporter ) : + IbisModelSelector( REPORTER* aReporter ) : IBIS_INPUT( aReporter ) {}; @@ -337,7 +336,7 @@ public: class IVtableEntry : public IBIS_INPUT { public: - IVtableEntry( IBIS_REPORTER* aReporter ) : + IVtableEntry( REPORTER* aReporter ) : IBIS_INPUT( aReporter ), I( aReporter ) {}; @@ -353,7 +352,7 @@ public: class IVtable : public IBIS_INPUT { public: - IVtable( IBIS_REPORTER* aReporter ) : + IVtable( REPORTER* aReporter ) : IBIS_INPUT( aReporter ) {}; @@ -392,7 +391,7 @@ private: class VTtableEntry : public IBIS_INPUT { public: - VTtableEntry( IBIS_REPORTER* aReporter ) : + VTtableEntry( REPORTER* aReporter ) : IBIS_INPUT( aReporter ), V( aReporter ) {}; @@ -407,7 +406,7 @@ public: class VTtable : public IBIS_INPUT { public: - VTtable( IBIS_REPORTER* aReporter ) : + VTtable( REPORTER* aReporter ) : IBIS_INPUT( aReporter ) {}; @@ -460,7 +459,7 @@ public: class dvdtTypMinMax : public IBIS_INPUT { public: - dvdtTypMinMax( IBIS_REPORTER* aReporter ) : IBIS_INPUT( aReporter ){}; + dvdtTypMinMax( REPORTER* aReporter ) : IBIS_INPUT( aReporter ){}; dvdt value[3]; bool Check() override; @@ -470,7 +469,7 @@ public: class IbisRamp : public IBIS_INPUT { public: - IbisRamp( IBIS_REPORTER* aReporter ) : + IbisRamp( REPORTER* aReporter ) : IBIS_INPUT( aReporter ), m_falling( aReporter ), m_rising( aReporter ) @@ -492,7 +491,7 @@ enum class IBIS_WAVEFORM_TYPE class IbisWaveform : public IBIS_INPUT { public: - IbisWaveform( IBIS_REPORTER* aReporter ) : IBIS_INPUT( aReporter ), m_table( aReporter ){}; + IbisWaveform( REPORTER* aReporter ) : IBIS_INPUT( aReporter ), m_table( aReporter ){}; VTtable m_table; IBIS_WAVEFORM_TYPE m_type = IBIS_WAVEFORM_TYPE::RISING; @@ -517,7 +516,7 @@ enum class IBIS_MODEL_POLARITY class IbisModel : IBIS_INPUT { public: - IbisModel( IBIS_REPORTER* aReporter ) : + IbisModel( REPORTER* aReporter ) : IBIS_INPUT( aReporter ), m_C_comp( aReporter ), m_voltageRange( aReporter ), @@ -580,7 +579,7 @@ public: class IbisPackageModel : public IBIS_INPUT { public: - IbisPackageModel( IBIS_REPORTER* aReporter ) : + IbisPackageModel( REPORTER* aReporter ) : IBIS_INPUT( aReporter ) {}; @@ -604,7 +603,7 @@ public: class IbisFile : public IBIS_INPUT { public: - IbisFile( IBIS_REPORTER* aReporter ) : + IbisFile( REPORTER* aReporter ) : IBIS_INPUT( aReporter ), m_header( aReporter ) {}; @@ -653,7 +652,7 @@ enum class IBIS_PARSER_CONTEXT class IbisParser : public IBIS_INPUT { public: - IbisParser( IBIS_REPORTER* aReporter ) : IBIS_INPUT( aReporter ), m_ibisFile( aReporter ){}; + IbisParser( REPORTER* aReporter ) : IBIS_INPUT( aReporter ), m_ibisFile( aReporter ){}; bool m_parrot = true; // Write back all lines. diff --git a/eeschema/sim/kibis/kibis.cpp b/eeschema/sim/kibis/kibis.cpp index a16ff1e046..1c447c99ac 100644 --- a/eeschema/sim/kibis/kibis.cpp +++ b/eeschema/sim/kibis/kibis.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2022 Fabien Corona f.coronalaposte.net + * Copyright (C) 2022-2023 KiCad Developers, see AUTHORS.txt for contributors. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: @@ -85,7 +86,7 @@ IBIS_CORNER ReverseLogic( IBIS_CORNER aIn ) return out; } -KIBIS::KIBIS( std::string aFileName, IBIS_REPORTER* aReporter ) : +KIBIS::KIBIS( std::string aFileName, REPORTER* aReporter ) : KIBIS_ANY( this ), m_reporter( aReporter ), m_file( this ) diff --git a/eeschema/sim/kibis/kibis.h b/eeschema/sim/kibis/kibis.h index 76c6bad9d3..d1d8738ec7 100644 --- a/eeschema/sim/kibis/kibis.h +++ b/eeschema/sim/kibis/kibis.h @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2022 Fabien Corona f.coronalaposte.net + * Copyright (C) 2022-2023 KiCad Developers, see AUTHORS.txt for contributors. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: @@ -218,9 +219,10 @@ public: { m_valid = false; }; // Constructor for unitialized KIBIS members - KIBIS( std::string aFileName, IBIS_REPORTER* aReporter = nullptr ); - IBIS_REPORTER* m_reporter; + KIBIS( std::string aFileName, REPORTER* aReporter = nullptr ); + + REPORTER* m_reporter; std::vector m_components; std::vector m_models; KIBIS_FILE m_file; diff --git a/eeschema/sim/sim_lib_mgr.cpp b/eeschema/sim/sim_lib_mgr.cpp index 5d5ac8d42e..2d7b87adf6 100644 --- a/eeschema/sim/sim_lib_mgr.cpp +++ b/eeschema/sim/sim_lib_mgr.cpp @@ -39,9 +39,8 @@ using namespace std::placeholders; -SIM_LIB_MGR::SIM_LIB_MGR( const PROJECT* aPrj, REPORTER* aReporter ) : +SIM_LIB_MGR::SIM_LIB_MGR( const PROJECT* aPrj ) : m_project( aPrj ), - m_reporter( aReporter ), m_forceFullParse( false ) { } @@ -128,7 +127,7 @@ wxString SIM_LIB_MGR::ResolveEmbeddedLibraryPath( const wxString& aLibPath, } -void SIM_LIB_MGR::SetLibrary( const wxString& aLibraryPath ) +void SIM_LIB_MGR::SetLibrary( const wxString& aLibraryPath, REPORTER& aReporter ) { try { @@ -138,29 +137,30 @@ void SIM_LIB_MGR::SetLibrary( const wxString& aLibraryPath ) std::bind( &SIM_LIB_MGR::ResolveEmbeddedLibraryPath, this, _1, _2 ); std::unique_ptr library = SIM_LIBRARY::Create( path, m_forceFullParse, - m_reporter, &f2 ); + aReporter, &f2 ); Clear(); m_libraries[path] = std::move( library ); } catch( const IO_ERROR& e ) { - m_reporter->Report( e.What() ); + aReporter.Report( e.What() ); } } -SIM_MODEL& SIM_LIB_MGR::CreateModel( SIM_MODEL::TYPE aType, const std::vector& aPins ) +SIM_MODEL& SIM_LIB_MGR::CreateModel( SIM_MODEL::TYPE aType, const std::vector& aPins, + REPORTER& aReporter ) { - m_models.push_back( SIM_MODEL::Create( aType, aPins, m_reporter ) ); + m_models.push_back( SIM_MODEL::Create( aType, aPins, aReporter ) ); return *m_models.back(); } SIM_MODEL& SIM_LIB_MGR::CreateModel( const SIM_MODEL* aBaseModel, - const std::vector& aPins ) + const std::vector& aPins, REPORTER& aReporter ) { - m_models.push_back( SIM_MODEL::Create( aBaseModel, aPins, m_reporter ) ); + m_models.push_back( SIM_MODEL::Create( aBaseModel, aPins, aReporter ) ); return *m_models.back(); } @@ -168,21 +168,24 @@ SIM_MODEL& SIM_LIB_MGR::CreateModel( const SIM_MODEL* aBaseModel, template SIM_MODEL& SIM_LIB_MGR::CreateModel( const SIM_MODEL* aBaseModel, const std::vector& aPins, - const std::vector& aFields ) + const std::vector& aFields, REPORTER& aReporter ) { - m_models.push_back( SIM_MODEL::Create( aBaseModel, aPins, aFields, m_reporter ) ); + m_models.push_back( SIM_MODEL::Create( aBaseModel, aPins, aFields, aReporter ) ); return *m_models.back(); } template SIM_MODEL& SIM_LIB_MGR::CreateModel( const SIM_MODEL* aBaseModel, const std::vector& aPins, - const std::vector& aFields ); + const std::vector& aFields, + REPORTER& aReporter ); template SIM_MODEL& SIM_LIB_MGR::CreateModel( const SIM_MODEL* aBaseModel, const std::vector& aPins, - const std::vector& aFields ); + const std::vector& aFields, + REPORTER& aReporter ); -SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const SCH_SHEET_PATH* aSheetPath, SCH_SYMBOL& aSymbol ) +SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const SCH_SHEET_PATH* aSheetPath, SCH_SYMBOL& aSymbol, + REPORTER& aReporter ) { // Note: currently this creates a resolved model (all Kicad variables references are resolved // before building the model). @@ -239,7 +242,7 @@ SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const SCH_SHEET_PATH* aSheetPath, S return StrNumCmp( lhs->GetNumber(), rhs->GetNumber(), true ) < 0; } ); - SIM_LIBRARY::MODEL model = CreateModel( fields, sourcePins, true ); + SIM_LIBRARY::MODEL model = CreateModel( fields, sourcePins, true, aReporter ); model.model.SetIsStoredInValue( storeInValue ); @@ -249,35 +252,37 @@ SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const SCH_SHEET_PATH* aSheetPath, S template SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const std::vector& aFields, - const std::vector& aPins, bool aResolved ) + const std::vector& aPins, bool aResolved, + REPORTER& aReporter ) { std::string libraryPath = SIM_MODEL::GetFieldValue( &aFields, SIM_LIBRARY::LIBRARY_FIELD ); std::string baseModelName = SIM_MODEL::GetFieldValue( &aFields, SIM_LIBRARY::NAME_FIELD ); if( libraryPath != "" ) { - return CreateModel( libraryPath, baseModelName, aFields, aPins ); + return CreateModel( libraryPath, baseModelName, aFields, aPins, aReporter ); } else { - m_models.push_back( SIM_MODEL::Create( aFields, aPins, aResolved, m_reporter ) ); + m_models.push_back( SIM_MODEL::Create( aFields, aPins, aResolved, aReporter ) ); return { baseModelName, *m_models.back() }; } } template SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const std::vector& aFields, const std::vector& aPins, - bool aResolved ); + bool aResolved, REPORTER& aReporter ); template SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const std::vector& aFields, const std::vector& aPins, - bool aResolved ); + bool aResolved, REPORTER& aReporter ); template SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const wxString& aLibraryPath, const std::string& aBaseModelName, const std::vector& aFields, - const std::vector& aPins ) + const std::vector& aPins, + REPORTER& aReporter ) { wxString path; wxString msg; @@ -297,32 +302,26 @@ SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const wxString& aLibraryPath, std::bind( &SIM_LIB_MGR::ResolveEmbeddedLibraryPath, this, _1, _2 ); it = m_libraries.emplace( path, SIM_LIBRARY::Create( path, m_forceFullParse, - m_reporter, &f2 ) ).first; + aReporter, &f2 ) ).first; } library = &*it->second; } catch( const IO_ERROR& e ) { - if( m_reporter ) - { - msg.Printf( _( "Error loading simulation model library '%s': %s" ), - path, - e.What() ); + msg.Printf( _( "Error loading simulation model library '%s': %s" ), + path, + e.What() ); - m_reporter->Report( msg, RPT_SEVERITY_ERROR ); - } + aReporter.Report( msg, RPT_SEVERITY_ERROR ); } if( aBaseModelName == "" ) { - if( m_reporter ) - { - msg.Printf( _( "Error loading simulation model: no '%s' field" ), - SIM_LIBRARY::NAME_FIELD ); + msg.Printf( _( "Error loading simulation model: no '%s' field" ), + SIM_LIBRARY::NAME_FIELD ); - m_reporter->Report( msg, RPT_SEVERITY_ERROR ); - } + aReporter.Report( msg, RPT_SEVERITY_ERROR ); modelName = _( "unknown" ).ToStdString(); } @@ -333,19 +332,16 @@ SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const wxString& aLibraryPath, if( !baseModel ) { - if( m_reporter ) - { - msg.Printf( _( "Error loading simulation model: could not find base model '%s' " - "in library '%s'" ), - aBaseModelName, - path ); + msg.Printf( _( "Error loading simulation model: could not find base model '%s' " + "in library '%s'" ), + aBaseModelName, + path ); - m_reporter->Report( msg, RPT_SEVERITY_ERROR ); - } + aReporter.Report( msg, RPT_SEVERITY_ERROR ); } } - m_models.push_back( SIM_MODEL::Create( baseModel, aPins, aFields, m_reporter ) ); + m_models.push_back( SIM_MODEL::Create( baseModel, aPins, aFields, aReporter ) ); return { modelName, *m_models.back() }; } diff --git a/eeschema/sim/sim_lib_mgr.h b/eeschema/sim/sim_lib_mgr.h index 01458b7458..06b53200c7 100644 --- a/eeschema/sim/sim_lib_mgr.h +++ b/eeschema/sim/sim_lib_mgr.h @@ -40,36 +40,39 @@ class SCH_SYMBOL; class SIM_LIB_MGR { public: - SIM_LIB_MGR( const PROJECT* aPrj, REPORTER* aReporter = nullptr ); + SIM_LIB_MGR( const PROJECT* aPrj ); virtual ~SIM_LIB_MGR() = default; - void SetReporter( REPORTER* aReporter ) { m_reporter = aReporter; } void SetForceFullParse() { m_forceFullParse = true; } void Clear(); - void SetLibrary( const wxString& aLibraryPath ); + void SetLibrary( const wxString& aLibraryPath, REPORTER& aReporter ); - SIM_MODEL& CreateModel( SIM_MODEL::TYPE aType, const std::vector& aPins ); + SIM_MODEL& CreateModel( SIM_MODEL::TYPE aType, const std::vector& aPins, + REPORTER& aReporter ); - SIM_MODEL& CreateModel( const SIM_MODEL* aBaseModel, const std::vector& aPins ); + SIM_MODEL& CreateModel( const SIM_MODEL* aBaseModel, const std::vector& aPins, + REPORTER& aReporter ); template SIM_MODEL& CreateModel( const SIM_MODEL* aBaseModel, const std::vector& aPins, - const std::vector& aFields ); + const std::vector& aFields, REPORTER& aReporter ); // TODO: The argument can be made const. - SIM_LIBRARY::MODEL CreateModel( const SCH_SHEET_PATH* aSheetPath, SCH_SYMBOL& aSymbol ); + SIM_LIBRARY::MODEL CreateModel( const SCH_SHEET_PATH* aSheetPath, SCH_SYMBOL& aSymbol, + REPORTER& aReporter ); template SIM_LIBRARY::MODEL CreateModel( const std::vector& aFields, - const std::vector& aPins, bool aResolved ); + const std::vector& aPins, bool aResolved, + REPORTER& aReporter ); template SIM_LIBRARY::MODEL CreateModel( const wxString& aLibraryPath, const std::string& aBaseModelName, const std::vector& aFields, - const std::vector& aPins ); + const std::vector& aPins, REPORTER& aReporter ); void SetModel( int aIndex, std::unique_ptr aModel ); @@ -81,7 +84,6 @@ public: private: const PROJECT* m_project; - REPORTER* m_reporter; bool m_forceFullParse; std::map> m_libraries; std::vector> m_models; diff --git a/eeschema/sim/sim_library.cpp b/eeschema/sim/sim_library.cpp index 8550d22bae..a6ec979b27 100644 --- a/eeschema/sim/sim_library.cpp +++ b/eeschema/sim/sim_library.cpp @@ -30,7 +30,7 @@ std::unique_ptr -SIM_LIBRARY::Create( const wxString& aFilePath, bool aForceFullParse, REPORTER* aReporter, +SIM_LIBRARY::Create( const wxString& aFilePath, bool aForceFullParse, REPORTER& aReporter, std::function* aResolver ) { std::unique_ptr library; @@ -40,7 +40,6 @@ SIM_LIBRARY::Create( const wxString& aFilePath, bool aForceFullParse, REPORTER* else library = std::make_unique( aForceFullParse ); - library->m_reporter = aReporter; library->m_pathResolver = aResolver; library->ReadFile( aFilePath, aReporter ); @@ -48,7 +47,7 @@ SIM_LIBRARY::Create( const wxString& aFilePath, bool aForceFullParse, REPORTER* } -void SIM_LIBRARY::ReadFile( const wxString& aFilePath, REPORTER* aReporter ) +void SIM_LIBRARY::ReadFile( const wxString& aFilePath, REPORTER& aReporter ) { m_filePath = aFilePath; } diff --git a/eeschema/sim/sim_library.h b/eeschema/sim/sim_library.h index 3a759b9d65..d0e6177899 100644 --- a/eeschema/sim/sim_library.h +++ b/eeschema/sim/sim_library.h @@ -55,7 +55,7 @@ public: * @return The library loaded in a newly constructed object. */ static std::unique_ptr - Create( const wxString& aFilePath, bool aForceFullParse, REPORTER* aReporter, + Create( const wxString& aFilePath, bool aForceFullParse, REPORTER& aReporter, std::function* aResolver ); /** @@ -65,7 +65,7 @@ public: * @param aFilePath Path to the file. * @throw IO_ERROR on read or parsing error. */ - virtual void ReadFile( const wxString& aFilePath, REPORTER* aReporter ) = 0; + virtual void ReadFile( const wxString& aFilePath, REPORTER& aReporter ) = 0; SIM_MODEL* FindModel( const std::string& aModelName ) const; @@ -80,8 +80,6 @@ protected: std::function* m_pathResolver; std::string m_filePath; - - REPORTER* m_reporter = nullptr; }; diff --git a/eeschema/sim/sim_library_kibis.cpp b/eeschema/sim/sim_library_kibis.cpp index ab0f67a785..7c857b23a6 100644 --- a/eeschema/sim/sim_library_kibis.cpp +++ b/eeschema/sim/sim_library_kibis.cpp @@ -29,15 +29,15 @@ #include -void SIM_LIBRARY_KIBIS::ReadFile( const wxString& aFilePath, REPORTER* aReporter ) +void SIM_LIBRARY_KIBIS::ReadFile( const wxString& aFilePath, REPORTER& aReporter ) { SIM_LIBRARY::ReadFile( aFilePath, aReporter ); - m_kibis = KIBIS( aFilePath.ToStdString(), m_reporter ); + m_kibis = KIBIS( aFilePath.ToStdString(), &aReporter ); if( !m_kibis.m_valid ) { - aReporter->Report( wxString::Format( _( "Invalid IBIS file '%s'" ), aFilePath ), - RPT_SEVERITY_ERROR ); + aReporter.Report( wxString::Format( _( "Invalid IBIS file '%s'" ), aFilePath ), + RPT_SEVERITY_ERROR ); return; } diff --git a/eeschema/sim/sim_library_kibis.h b/eeschema/sim/sim_library_kibis.h index 17dec0ad9c..9749605928 100644 --- a/eeschema/sim/sim_library_kibis.h +++ b/eeschema/sim/sim_library_kibis.h @@ -38,7 +38,7 @@ public: static constexpr auto DIFF_FIELD = "Sim.Ibis.Diff"; // @copydoc SIM_LIBRARY::ReadFile() - void ReadFile( const wxString& aFilePath, REPORTER* aReporter ) override; + void ReadFile( const wxString& aFilePath, REPORTER& aReporter ) override; bool InitModel( SIM_MODEL_KIBIS& aModel, wxString aCompName ); bool isPinDiff( const std::string& aComp, const std::string& aPinNumber ) const; diff --git a/eeschema/sim/sim_library_spice.cpp b/eeschema/sim/sim_library_spice.cpp index 6b360cb375..e966550d64 100644 --- a/eeschema/sim/sim_library_spice.cpp +++ b/eeschema/sim/sim_library_spice.cpp @@ -33,7 +33,7 @@ SIM_LIBRARY_SPICE::SIM_LIBRARY_SPICE( bool aForceFullParse ) : } -void SIM_LIBRARY_SPICE::ReadFile( const wxString& aFilePath, REPORTER* aReporter ) +void SIM_LIBRARY_SPICE::ReadFile( const wxString& aFilePath, REPORTER& aReporter ) { SIM_LIBRARY::ReadFile( aFilePath, aReporter ); m_spiceLibraryParser->ReadFile( aFilePath, aReporter ); diff --git a/eeschema/sim/sim_library_spice.h b/eeschema/sim/sim_library_spice.h index 3ac2f93a85..5f78a8debd 100644 --- a/eeschema/sim/sim_library_spice.h +++ b/eeschema/sim/sim_library_spice.h @@ -37,7 +37,7 @@ public: SIM_LIBRARY_SPICE( bool aForceFullParse ); // @copydoc SIM_LIBRARY::ReadFile() - void ReadFile( const wxString& aFilePath, REPORTER* aReporter ) override; + void ReadFile( const wxString& aFilePath, REPORTER& aReporter ) override; private: std::unique_ptr m_spiceLibraryParser; diff --git a/eeschema/sim/sim_model.cpp b/eeschema/sim/sim_model.cpp index 1d9e7ed0e1..4e49ed4c16 100644 --- a/eeschema/sim/sim_model.cpp +++ b/eeschema/sim/sim_model.cpp @@ -373,12 +373,12 @@ SIM_MODEL::SPICE_INFO SIM_MODEL::SpiceInfo( TYPE aType ) template TYPE SIM_MODEL::ReadTypeFromFields( const std::vector& aFields, - REPORTER* aReporter ); + REPORTER& aReporter ); template TYPE SIM_MODEL::ReadTypeFromFields( const std::vector& aFields, - REPORTER* aReporter ); + REPORTER& aReporter ); template -TYPE SIM_MODEL::ReadTypeFromFields( const std::vector& aFields, REPORTER* aReporter ) +TYPE SIM_MODEL::ReadTypeFromFields( const std::vector& aFields, REPORTER& aReporter ) { std::string deviceTypeFieldValue = GetFieldValue( &aFields, SIM_DEVICE_TYPE_FIELD ); std::string typeFieldValue = GetFieldValue( &aFields, SIM_TYPE_FIELD ); @@ -398,20 +398,17 @@ TYPE SIM_MODEL::ReadTypeFromFields( const std::vector& aFields, REPORTER* aRe if( typeFieldValue != "" ) return TYPE::NONE; - if( aReporter ) + if( aFields.size() > REFERENCE_FIELD ) { - if( aFields.size() > REFERENCE_FIELD ) - { - aReporter->Report( wxString::Format( _( "No simulation model definition found for " - "symbol '%s'." ), - aFields[REFERENCE_FIELD].GetText() ), - RPT_SEVERITY_ERROR ); - } - else - { - aReporter->Report( _( "No simulation model definition found." ), - RPT_SEVERITY_ERROR ); - } + aReporter.Report( wxString::Format( _( "No simulation model definition found for " + "symbol '%s'." ), + aFields[REFERENCE_FIELD].GetText() ), + RPT_SEVERITY_ERROR ); + } + else + { + aReporter.Report( _( "No simulation model definition found." ), + RPT_SEVERITY_ERROR ); } return TYPE::NONE; @@ -449,7 +446,7 @@ void SIM_MODEL::WriteFields( std::vector& aFields ) const std::unique_ptr SIM_MODEL::Create( TYPE aType, const std::vector& aPins, - REPORTER* aReporter ) + REPORTER& aReporter ) { std::unique_ptr model = Create( aType ); @@ -469,7 +466,7 @@ std::unique_ptr SIM_MODEL::Create( TYPE aType, const std::vector SIM_MODEL::Create( const SIM_MODEL* aBaseModel, const std::vector& aPins, - REPORTER* aReporter ) + REPORTER& aReporter ) { std::unique_ptr model; @@ -508,17 +505,18 @@ template std::unique_ptr SIM_MODEL::Create( const SIM_MODEL* aBaseModel, const std::vector& aPins, const std::vector& aFields, - REPORTER* aReporter ) + REPORTER& aReporter ) { std::unique_ptr model; if( aBaseModel ) { - TYPE type = aBaseModel->GetType(); + NULL_REPORTER devnull; + TYPE type = aBaseModel->GetType(); // No REPORTER here; we're just checking to see if we have an override - if( ReadTypeFromFields( aFields, nullptr ) != TYPE::NONE ) - type = ReadTypeFromFields( aFields, nullptr ); + if( ReadTypeFromFields( aFields, devnull ) != TYPE::NONE ) + type = ReadTypeFromFields( aFields, devnull ); if( dynamic_cast( aBaseModel ) ) model = std::make_unique( type ); @@ -541,14 +539,11 @@ std::unique_ptr SIM_MODEL::Create( const SIM_MODEL* aBaseModel, } catch( IO_ERROR& err ) { - if( aReporter ) - { - aReporter->Report( wxString::Format( _( "Error reading simulation model from " - "symbol '%s':\n%s" ), - aFields[REFERENCE_FIELD].GetText(), - err.Problem() ), - RPT_SEVERITY_ERROR ); - } + aReporter.Report( wxString::Format( _( "Error reading simulation model from " + "symbol '%s':\n%s" ), + aFields[REFERENCE_FIELD].GetText(), + err.Problem() ), + RPT_SEVERITY_ERROR ); } return model; @@ -557,18 +552,18 @@ std::unique_ptr SIM_MODEL::Create( const SIM_MODEL* aBaseModel, template std::unique_ptr SIM_MODEL::Create( const SIM_MODEL* aBaseModel, const std::vector& aPins, const std::vector& aFields, - REPORTER* aReporter ); + REPORTER& aReporter ); template std::unique_ptr SIM_MODEL::Create( const SIM_MODEL* aBaseModel, const std::vector& aPins, const std::vector& aFields, - REPORTER* aReporter ); + REPORTER& aReporter ); template std::unique_ptr SIM_MODEL::Create( const std::vector& aFields, const std::vector& aPins, - bool aResolved, REPORTER* aReporter ) + bool aResolved, REPORTER& aReporter ) { TYPE type = ReadTypeFromFields( aFields, aReporter ); std::unique_ptr model = SIM_MODEL::Create( type ); @@ -581,7 +576,7 @@ std::unique_ptr SIM_MODEL::Create( const std::vector& aFields, { if( !aResolved ) { - aReporter->Report( parse_err.What(), RPT_SEVERITY_ERROR ); + aReporter.Report( parse_err.What(), RPT_SEVERITY_ERROR ); return model; } @@ -603,14 +598,11 @@ std::unique_ptr SIM_MODEL::Create( const std::vector& aFields, catch( const IO_ERROR& err ) { // We own the pin syntax, so if we can't parse it then there's an error. - if( aReporter ) - { - aReporter->Report( wxString::Format( _( "Error reading simulation model from " - "symbol '%s':\n%s" ), - aFields[REFERENCE_FIELD].GetText(), - err.Problem() ), - RPT_SEVERITY_ERROR ); - } + aReporter.Report( wxString::Format( _( "Error reading simulation model from " + "symbol '%s':\n%s" ), + aFields[REFERENCE_FIELD].GetText(), + err.Problem() ), + RPT_SEVERITY_ERROR ); } } @@ -619,10 +611,10 @@ std::unique_ptr SIM_MODEL::Create( const std::vector& aFields, template std::unique_ptr SIM_MODEL::Create( const std::vector& aFields, const std::vector& aPins, - bool aResolved, REPORTER* aReporter ); + bool aResolved, REPORTER& aReporter ); template std::unique_ptr SIM_MODEL::Create( const std::vector& aFields, const std::vector& aPins, - bool aResolved, REPORTER* aReporter ); + bool aResolved, REPORTER& aReporter ); template @@ -1729,7 +1721,7 @@ void SIM_MODEL::MigrateSimModel( T_symbol& aSymbol, const PROJECT* aProject ) { wxString msg; WX_STRING_REPORTER reporter( &msg ); - SIM_LIB_MGR libMgr( aProject, &reporter ); + SIM_LIB_MGR libMgr( aProject ); std::vector emptyFields; // Pull out any following parameters from model name @@ -1737,7 +1729,7 @@ void SIM_MODEL::MigrateSimModel( T_symbol& aSymbol, const PROJECT* aProject ) spiceModelInfo.m_Text = spiceModel; SIM_LIBRARY::MODEL model = libMgr.CreateModel( spiceLib, spiceModel.ToStdString(), - emptyFields, sourcePins ); + emptyFields, sourcePins, reporter ); if( reporter.HasMessage() ) libraryModel = false; // Fall back to raw spice model diff --git a/eeschema/sim/sim_model.h b/eeschema/sim/sim_model.h index 83c3278a53..327cb6f86e 100644 --- a/eeschema/sim/sim_model.h +++ b/eeschema/sim/sim_model.h @@ -408,25 +408,25 @@ public: template - static TYPE ReadTypeFromFields( const std::vector& aFields, REPORTER* aReporter ); + static TYPE ReadTypeFromFields( const std::vector& aFields, REPORTER& aReporter ); static std::unique_ptr Create( TYPE aType, const std::vector& aPins, - REPORTER* aReporter ); + REPORTER& aReporter ); static std::unique_ptr Create( const SIM_MODEL* aBaseModel, const std::vector& aPins, - REPORTER* aReporter ); + REPORTER& aReporter ); template static std::unique_ptr Create( const SIM_MODEL* aBaseModel, const std::vector& aPins, const std::vector& aFields, - REPORTER* aReporter ); + REPORTER& aReporter ); template static std::unique_ptr Create( const std::vector& aFields, const std::vector& aPins, - bool aResolved, REPORTER* aReporter ); + bool aResolved, REPORTER& aReporter ); template static std::string GetFieldValue( const std::vector* aFields, const wxString& aFieldName, diff --git a/eeschema/sim/simulator_frame_ui.cpp b/eeschema/sim/simulator_frame_ui.cpp index ad42b04f05..57a64206bd 100644 --- a/eeschema/sim/simulator_frame_ui.cpp +++ b/eeschema/sim/simulator_frame_ui.cpp @@ -1395,8 +1395,9 @@ void SIMULATOR_FRAME_UI::UpdateTunerValue( const SCH_SHEET_PATH& aSheetPath, con return; } - SIM_LIB_MGR mgr( &m_schematicFrame->Prj() ); - SIM_MODEL& model = mgr.CreateModel( &aSheetPath, *symbol ).model; + NULL_REPORTER devnull; + SIM_LIB_MGR mgr( &m_schematicFrame->Prj() ); + SIM_MODEL& model = mgr.CreateModel( &aSheetPath, *symbol, devnull ).model; const SIM_MODEL::PARAM* tunerParam = model.GetTunerParam(); diff --git a/eeschema/sim/spice_library_parser.cpp b/eeschema/sim/spice_library_parser.cpp index 55d5851312..88839e48ac 100644 --- a/eeschema/sim/spice_library_parser.cpp +++ b/eeschema/sim/spice_library_parser.cpp @@ -205,7 +205,7 @@ void SPICE_LIBRARY_PARSER::parseFile( const wxString &aFilePath, REPORTER& aRepo } -void SPICE_LIBRARY_PARSER::ReadFile( const wxString& aFilePath, REPORTER* aReporter ) +void SPICE_LIBRARY_PARSER::ReadFile( const wxString& aFilePath, REPORTER& aReporter ) { m_library.m_models.clear(); m_library.m_modelNames.clear(); @@ -215,7 +215,7 @@ void SPICE_LIBRARY_PARSER::ReadFile( const wxString& aFilePath, REPORTER* aRepor // (cmp/standard.bjt, cmp/standard.mos, etc.) have copious error which trip up our parser, // and our parser is *really* slow on such large files (nearly 5 seconds on my dev machine). if( !m_forceFullParse && aFilePath.Contains( wxS( "/LTspiceXVII/lib/cmp/standard" ) ) ) - readFallbacks( aFilePath, *aReporter ); + readFallbacks( aFilePath, aReporter ); else - parseFile( aFilePath, *aReporter ); + parseFile( aFilePath, aReporter ); } diff --git a/eeschema/sim/spice_library_parser.h b/eeschema/sim/spice_library_parser.h index 8bfba9f1f4..3c1b5cc4e0 100644 --- a/eeschema/sim/spice_library_parser.h +++ b/eeschema/sim/spice_library_parser.h @@ -41,7 +41,7 @@ public: virtual ~SPICE_LIBRARY_PARSER() {}; - virtual void ReadFile( const wxString& aFilePath, REPORTER* aReporter ); + virtual void ReadFile( const wxString& aFilePath, REPORTER& aReporter ); protected: void readFallbacks( const wxString& aFilePath, REPORTER& aReporter ); diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index fba972c9fe..bd7c362989 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -545,9 +545,9 @@ int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent ) wxString msg; WX_STRING_REPORTER reporter( &msg ); - SIM_LIB_MGR mgr( &m_frame->Prj(), &reporter ); + SIM_LIB_MGR mgr( &m_frame->Prj() ); - SIM_MODEL& model = mgr.CreateModel( &sheet, *symbol ).model; + SIM_MODEL& model = mgr.CreateModel( &sheet, *symbol, reporter ).model; if( reporter.HasMessage() ) THROW_IO_ERROR( msg ); diff --git a/qa/tests/spice/test_library_spice.cpp b/qa/tests/spice/test_library_spice.cpp index 7aacc6cb09..16f1bc351e 100644 --- a/qa/tests/spice/test_library_spice.cpp +++ b/qa/tests/spice/test_library_spice.cpp @@ -46,9 +46,11 @@ public: void LoadLibrary( const std::string& aBaseName ) { - std::string path = GetLibraryPath( aBaseName ); + NULL_REPORTER devnull; + std::string path = GetLibraryPath( aBaseName ); + m_library = std::make_unique( true ); - m_library->ReadFile( path, nullptr ); + m_library->ReadFile( path, devnull ); } void CompareToUsualDiodeModel( const SIM_MODEL& aModel, const std::string& aModelName, int aModelIndex )