|
KiCad PCB EDA Suite
|
A KiCad database library provides both symbol and footprint metadata, so there are "shim" plugins on both the symbol and footprint side of things that expose the database contents to the schematic and board editors. More...
#include <sch_io_database.h>
Public Member Functions | |
| SCH_IO_DATABASE () | |
| virtual | ~SCH_IO_DATABASE () |
| const IO_BASE::IO_FILE_DESC | GetLibraryDesc () const override |
| Get the descriptor for the library container that this IO plugin operates on. | |
| int | GetModifyHash () const override |
| Return the modification hash from the library cache. | |
| void | EnumerateSymbolLib (wxArrayString &aSymbolNameList, const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr) override |
| Populate a list of LIB_SYMBOL alias names contained within the library aLibraryPath. | |
| void | EnumerateSymbolLib (std::vector< LIB_SYMBOL * > &aSymbolList, const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr) override |
| Populate a list of LIB_SYMBOL aliases contained within the library aLibraryPath. | |
| void | CheckLibrary (const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr) override |
| Validate that the library at aLibraryPath is reachable and well-formed, without necessarily loading symbol data. | |
| LIB_SYMBOL * | LoadSymbol (const wxString &aLibraryPath, const wxString &aAliasName, const std::map< std::string, UTF8 > *aProperties=nullptr) override |
| Load a LIB_SYMBOL object having aPartName from the aLibraryPath containing a library format that this SCH_IO knows about. | |
| bool | SupportsSubLibraries () const override |
| void | GetSubLibraryNames (std::vector< wxString > &aNames) override |
| Retrieves a list of sub-libraries in this library. | |
| void | GetAvailableSymbolFields (std::vector< wxString > &aNames) override |
| Retrieves a list of (custom) field names that are present on symbols in this library. | |
| void | GetDefaultSymbolFields (std::vector< wxString > &aNames) override |
| Retrieves a list of (custom) field names that should be shown by default for this library in the symbol chooser. | |
| bool | IsLibraryWritable (const wxString &aLibraryPath) override |
| Return true if the library at aLibraryPath is writable. | |
| void | SetLibraryManagerAdapter (SYMBOL_LIBRARY_ADAPTER *aAdapter) override |
| Some library plugins need to interface with other loaded libraries. | |
| bool | SupportsConfigurationDialog () const override |
| DIALOG_SHIM * | CreateConfigurationDialog (wxWindow *aParent) override |
| DATABASE_LIB_SETTINGS * | Settings () const |
| bool | TestConnection (wxString *aErrorMsg=nullptr) |
| virtual const IO_BASE::IO_FILE_DESC | GetSchematicFileDesc () const |
| Returns schematic file description for the SCH_IO. | |
| virtual bool | CanReadSchematicFile (const wxString &aFileName) const |
| Checks if this SCH_IO can read the specified schematic file. | |
| virtual void | SaveLibrary (const wxString &aFileName, const std::map< std::string, UTF8 > *aProperties=nullptr) |
| virtual SCH_SHEET * | LoadSchematicFile (const wxString &aFileName, SCHEMATIC *aSchematic, SCH_SHEET *aAppendToMe=nullptr, const std::map< std::string, UTF8 > *aProperties=nullptr) |
| Load information from some input file format that this SCH_IO implementation knows about, into either a new SCH_SHEET or an existing one. | |
| virtual std::vector< LIB_SYMBOL * > | GetImportedCachedLibrarySymbols () |
| Return the canonical symbol definitions produced by the last LoadSchematicFile(). | |
| virtual void | SaveSchematicFile (const wxString &aFileName, SCH_SHEET *aSheet, SCHEMATIC *aSchematic, const std::map< std::string, UTF8 > *aProperties=nullptr) |
| Write aSchematic to a storage file in a format that this SCH_IO implementation knows about, or it can be used to write a portion of aSchematic to a special kind of export file. | |
| virtual void | SaveSymbol (const wxString &aLibraryPath, std::unique_ptr< LIB_SYMBOL > aSymbol, const std::map< std::string, UTF8 > *aProperties=nullptr) |
| Write aSymbol to an existing library located at aLibraryPath. | |
| virtual void | DeleteSymbol (const wxString &aLibraryPath, const wxString &aSymbolName, const std::map< std::string, UTF8 > *aProperties=nullptr) |
| Delete the entire LIB_SYMBOL associated with aAliasName from the library aLibraryPath. | |
| virtual void | GetLibraryOptions (std::map< std::string, UTF8 > *aListToAppendTo) const override |
| Append supported SCH_IO options to aListToAppenTo along with internationalized descriptions. | |
| virtual wxString | GetSubLibraryDescription (const wxString &aName) |
| Gets a description of a sublibrary. | |
| virtual const wxString & | GetError () const |
| Return an error string to the caller. | |
| const wxString & | GetName () const |
| Return a brief hard coded name for this IO interface. | |
| virtual bool | IsPCB_IO () const |
| Work-around for lack of dynamic_cast across compile units on Mac. | |
| virtual void | SetReporter (REPORTER *aReporter) |
| Set an optional reporter for warnings/errors. | |
| virtual void | SetProgressReporter (PROGRESS_REPORTER *aReporter) |
| Set an optional progress reporter. | |
| virtual const IO_FILE_DESC | GetLibraryFileDesc () const |
| Get the descriptor for the individual library elements that this IO plugin operates on. | |
| virtual bool | CanReadLibrary (const wxString &aFileName) const |
| Checks if this IO object can read the specified library file/directory. | |
| virtual void | CreateLibrary (const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr) |
| Create a new empty library at aLibraryPath empty. | |
| virtual bool | DeleteLibrary (const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr) |
| Delete an existing library and returns true, or if library does not exist returns false, or throws an exception if library exists but is read only or cannot be deleted for some other reason. | |
| virtual void | Report (const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) const |
| virtual void | AdvanceProgressPhase () |
Protected Attributes | |
| wxString | m_name |
| Name of the IO loader. | |
| REPORTER * | m_reporter |
| Reporter to log errors/warnings to, may be nullptr. | |
| PROGRESS_REPORTER * | m_progressReporter |
| Progress reporter to track the progress of the operation, may be nullptr. | |
Private Types | |
| typedef std::vector< std::pair< const DATABASE_LIB_TABLE *, std::vector< DATABASE_CONNECTION::ROW > > > | TABLE_RESULT_LIST |
Private Member Functions | |
| void | cacheLib () |
| size_t | computeSignature (const TABLE_RESULT_LIST &aTableResults) const |
| bool | materializeCache (const TABLE_RESULT_LIST &aTableResults, std::map< wxString, std::unique_ptr< LIB_SYMBOL > > &aSymbolCache, std::map< wxString, std::pair< std::string, std::string > > &aSanitizedNameMap) |
| void | ensureSettings (const wxString &aSettingsPath) |
| void | ensureConnection () |
| void | connect () |
| std::unique_ptr< LIB_SYMBOL > | loadSymbolFromRow (const wxString &aSymbolName, const DATABASE_LIB_TABLE &aTable, const DATABASE_CONNECTION::ROW &aRow) |
| void | startBackgroundRefresh () |
| void | stopBackgroundRefresh () |
| void | backgroundRefreshWorker () |
Static Private Member Functions | |
| static std::optional< bool > | boolFromAny (const std::any &aVal) |
Private Attributes | |
| SYMBOL_LIBRARY_ADAPTER * | m_adapter |
| std::unique_ptr< DATABASE_LIB_SETTINGS > | m_settings |
| std::unique_ptr< DATABASE_CONNECTION > | m_conn |
| Generally will be null if no valid connection is established. | |
| std::set< wxString > | m_customFields |
| std::set< wxString > | m_defaultShownFields |
| std::map< wxString, std::unique_ptr< LIB_SYMBOL > > | m_nameToSymbolcache |
| std::map< wxString, std::pair< std::string, std::string > > | m_sanitizedNameMap |
| long long | m_cacheTimestamp |
| std::atomic< bool > | m_cachePopulated { false } |
| True once the LIB_SYMBOL cache has been materialized at least once. | |
| int | m_modifyHash = 0 |
| size_t | m_cacheSignature |
| Signature of the raw database rows at last materialization; used to skip rebuilding the LIB_SYMBOL cache when a re-query returns identical data. | |
| std::unordered_set< wxString > | m_inProgressLoads |
| LIB_IDs whose resolution is in flight, used to break self-referential cycles where a row's Symbols column points back into the same database library (issue #24249). | |
| bool | m_inCacheLib = false |
| Re-entrancy guard for cacheLib(), tripped when a self-referential load routes back through the adapter into LoadSymbol mid-build. | |
| std::thread | m_refreshThread |
| std::atomic< bool > | m_refreshRunning { false } |
| std::condition_variable | m_refreshCV |
| std::mutex | m_refreshMutex |
| std::shared_mutex | m_cacheMutex |
| std::mutex | m_symbolLoadMutex |
| wxString | m_lastError |
Friends | |
| class | SCH_IO_DATABASE_CYCLE_DETECTION_FIXTURE |
A KiCad database library provides both symbol and footprint metadata, so there are "shim" plugins on both the symbol and footprint side of things that expose the database contents to the schematic and board editors.
The architecture of these is slightly different from the other plugins because the backing file is just a configuration file rather than something that contains symbol or footprint data.
Definition at line 49 of file sch_io_database.h.
|
private |
Definition at line 105 of file sch_io_database.h.
| SCH_IO_DATABASE::SCH_IO_DATABASE | ( | ) |
Definition at line 48 of file sch_io_database.cpp.
References m_adapter, m_cacheSignature, m_cacheTimestamp, m_conn, m_settings, and SCH_IO::SCH_IO().
|
virtual |
Definition at line 59 of file sch_io_database.cpp.
References stopBackgroundRefresh().
|
virtualinherited |
Definition at line 133 of file io_base.cpp.
References m_progressReporter, and THROW_IO_CANCELLED.
|
private |
Definition at line 429 of file sch_io_database.cpp.
References computeSignature(), m_cacheMutex, m_cachePopulated, m_cacheSignature, m_cacheTimestamp, m_conn, m_modifyHash, m_nameToSymbolcache, m_refreshCV, m_refreshMutex, m_refreshRunning, m_sanitizedNameMap, m_settings, materializeCache(), table, traceDatabase, IO_ERROR::What(), and IO_ERROR::what().
Referenced by startBackgroundRefresh().
|
staticprivate |
Definition at line 664 of file sch_io_database.cpp.
Referenced by loadSymbolFromRow().
|
private |
Definition at line 329 of file sch_io_database.cpp.
References _, computeSignature(), flag, m_cacheMutex, m_cachePopulated, m_cacheSignature, m_cacheTimestamp, m_conn, m_inCacheLib, m_modifyHash, m_nameToSymbolcache, m_refreshRunning, m_sanitizedNameMap, m_settings, materializeCache(), startBackgroundRefresh(), table, and THROW_IO_ERRORF.
Referenced by EnumerateSymbolLib(), and LoadSymbol().
|
virtualinherited |
Checks if this IO object can read the specified library file/directory.
If not overridden, extension check is used.
Reimplemented in PCB_IO_ALLEGRO, PCB_IO_ALTIUM_DESIGNER, PCB_IO_CADSTAR_ARCHIVE, PCB_IO_EAGLE, PCB_IO_EASYEDA, PCB_IO_EASYEDAPRO_V3, PCB_IO_IPC2581, PCB_IO_ODBPP, PCB_IO_PADS_BINARY, SCH_IO_ALTIUM, SCH_IO_CADSTAR_ARCHIVE, SCH_IO_EAGLE, SCH_IO_EASYEDA, SCH_IO_EASYEDAPRO_V3, SCH_IO_KICAD_LEGACY, SCH_IO_KICAD_SEXPR, SCH_IO_ORCAD, SCH_IO_PADS, and SCH_IO_PCAD.
Definition at line 71 of file io_base.cpp.
References GetLibraryDesc(), IO_BASE::IO_FILE_DESC::m_ExtensionsInDir, IO_BASE::IO_FILE_DESC::m_FileExtensions, and IO_BASE::IO_FILE_DESC::m_IsFile.
Referenced by PCB_IO_ALLEGRO::CanReadLibrary(), PCB_IO_ALTIUM_DESIGNER::CanReadLibrary(), PCB_IO_CADSTAR_ARCHIVE::CanReadLibrary(), PCB_IO_EAGLE::CanReadLibrary(), PCB_IO_EASYEDAPRO_V3::CanReadLibrary(), PCB_IO_PADS_BINARY::CanReadLibrary(), SCH_IO_ALTIUM::CanReadLibrary(), SCH_IO_CADSTAR_ARCHIVE::CanReadLibrary(), SCH_IO_EAGLE::CanReadLibrary(), SCH_IO_EASYEDAPRO_V3::CanReadLibrary(), SCH_IO_KICAD_LEGACY::CanReadLibrary(), SCH_IO_KICAD_SEXPR::CanReadLibrary(), SCH_IO_ORCAD::CanReadLibrary(), and SCH_IO_PADS::CanReadLibrary().
|
virtualinherited |
Checks if this SCH_IO can read the specified schematic file.
If not overriden, extension check is used.
Reimplemented in SCH_IO_ALTIUM, SCH_IO_DIPTRACE, SCH_IO_EAGLE, SCH_IO_EASYEDA, SCH_IO_EASYEDAPRO, SCH_IO_EASYEDAPRO_V3, SCH_IO_GEDA, SCH_IO_KICAD_LEGACY, SCH_IO_ORCAD, SCH_IO_PADS, and SCH_IO_PCAD.
Definition at line 47 of file sch_io.cpp.
References GetSchematicFileDesc(), and IO_BASE::IO_FILE_DESC::m_FileExtensions.
Referenced by SCH_IO_ALTIUM::CanReadSchematicFile(), SCH_IO_DIPTRACE::CanReadSchematicFile(), SCH_IO_EAGLE::CanReadSchematicFile(), SCH_IO_EASYEDA::CanReadSchematicFile(), SCH_IO_KICAD_LEGACY::CanReadSchematicFile(), SCH_IO_ORCAD::CanReadSchematicFile(), and SCH_IO_PADS::CanReadSchematicFile().
|
overridevirtual |
Validate that the library at aLibraryPath is reachable and well-formed, without necessarily loading symbol data.
This is used for editing library tables, where a full EnumerateSymbolLib can be expensive for some libraries (e.g. HTTP or Database) and should not be done just to check if the library is OK to use.
| aLibraryPath | is a locator for the "library", usually a directory, file, or URL containing one or more LIB_SYMBOL objects. |
| aProperties | is an associative array that can be used to tell the plugin anything needed about how to perform with respect to aLibraryPath. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL. |
| IO_ERROR | if the library cannot be found or is not well-formed. |
Reimplemented from SCH_IO.
Definition at line 106 of file sch_io_database.cpp.
References ensureConnection(), and ensureSettings().
|
private |
Definition at line 252 of file sch_io_database.cpp.
References UTF8::c_str(), LIB_ID::GetLibNickname(), hash_combine(), LIB_ID::IsValid(), m_adapter, LIB_ID::Parse(), result, and table.
Referenced by backgroundRefreshWorker(), and cacheLib().
|
private |
Definition at line 592 of file sch_io_database.cpp.
References DATABASE_FIELD_MAPPING::column, MAPPABLE_SYMBOL_PROPERTIES::description, MAPPABLE_SYMBOL_PROPERTIES::exclude_from_board, MAPPABLE_SYMBOL_PROPERTIES::exclude_from_bom, MAPPABLE_SYMBOL_PROPERTIES::exclude_from_sim, DATABASE_LIB_TABLE::fields, MAPPABLE_SYMBOL_PROPERTIES::footprint_filters, DATABASE_LIB_TABLE::footprints_col, DATABASE_LIB_TABLE::key_col, MAPPABLE_SYMBOL_PROPERTIES::keywords, m_cacheMutex, m_conn, m_lastError, m_settings, DATABASE_LIB_TABLE::pins_col, DATABASE_LIB_TABLE::properties, DATABASE_LIB_TABLE::symbols_col, and DATABASE_LIB_TABLE::table.
Referenced by ensureConnection(), and TestConnection().
|
overridevirtual |
Reimplemented from IO_BASE.
Definition at line 1193 of file sch_io_database.cpp.
|
virtualinherited |
Create a new empty library at aLibraryPath empty.
It is an error to attempt to create an existing library or to attempt to create on a "read only" location.
| aLibraryPath | is a locator for the "library", usually a directory, file, or URL containing several elements. |
| aProperties | is an associative array that can be used to tell the library create function anything special, because it can take any number of additional named tuning arguments that the IO is known to support. The caller continues to own this object (IO may not delete it), and IOs should expect it to be optionally NULL. |
| IO_ERROR | if there is a problem finding the library, or creating it. |
Reimplemented in DESIGN_BLOCK_IO, PCB_IO_KICAD_SEXPR, SCH_IO_KICAD_LEGACY, and SCH_IO_KICAD_SEXPR.
Definition at line 46 of file io_base.cpp.
References NOT_IMPLEMENTED.
Referenced by LIBRARY_MANAGER_ADAPTER::CreateLibrary().
|
virtualinherited |
Delete an existing library and returns true, or if library does not exist returns false, or throws an exception if library exists but is read only or cannot be deleted for some other reason.
| aLibraryPath | is a locator for the "library", usually a directory or file which will contain several elements. |
| aProperties | is an associative array that can be used to tell the library delete implementation function anything special, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL. |
| IO_ERROR | if there is a problem deleting an existing library. |
Reimplemented in DESIGN_BLOCK_IO, PCB_IO_GEDA, PCB_IO_KICAD_LEGACY, PCB_IO_KICAD_SEXPR, SCH_IO_KICAD_LEGACY, and SCH_IO_KICAD_SEXPR.
Definition at line 53 of file io_base.cpp.
References NOT_IMPLEMENTED.
Referenced by LIBRARY_MANAGER_ADAPTER::DeleteLibrary().
|
virtualinherited |
Delete the entire LIB_SYMBOL associated with aAliasName from the library aLibraryPath.
| aLibraryPath | is a locator for the "library", usually a directory, file, or URL containing several symbols. |
| aSymbolName | is the name of a LIB_SYMBOL associated with it's root LIB_SYMBOL object to delete from the specified library. |
| aProperties | is an associative array that can be used to tell the library delete function anything special, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL. |
| IO_ERROR | if there is a problem finding the alias or the library or deleting it. |
Reimplemented in SCH_IO_KICAD_LEGACY, and SCH_IO_KICAD_SEXPR.
Definition at line 132 of file sch_io.cpp.
References NOT_IMPLEMENTED.
Referenced by LIB_BUFFER::SaveBuffer().
|
private |
Definition at line 578 of file sch_io_database.cpp.
References _, connect(), m_conn, m_lastError, m_settings, and THROW_IO_ERRORF.
Referenced by CheckLibrary(), EnumerateSymbolLib(), and LoadSymbol().
|
private |
Definition at line 541 of file sch_io_database.cpp.
References _, m_conn, m_settings, path, THROW_IO_ERRORF, and traceDatabase.
Referenced by CheckLibrary(), EnumerateSymbolLib(), GetSubLibraryNames(), and LoadSymbol().
|
overridevirtual |
Populate a list of LIB_SYMBOL aliases contained within the library aLibraryPath.
| aSymbolList | is an array to populate with the LIB_SYMBOL pointers associated with the library. |
| aLibraryPath | is a locator for the "library", usually a directory, file, or URL containing one or more LIB_SYMBOL objects. |
| aProperties | is an associative array that can be used to tell the plugin anything needed about how to perform with respect to aLibraryPath. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL. |
| IO_ERROR | if the library cannot be found, the part library cannot be loaded. |
Reimplemented from SCH_IO.
Definition at line 80 of file sch_io_database.cpp.
References cacheLib(), LIB_SYMBOL::Duplicate(), ensureConnection(), ensureSettings(), LIB_SYMBOL::IsPower(), m_adapter, m_cacheMutex, m_conn, m_lastError, m_nameToSymbolcache, SYMBOL_LIBRARY_ADAPTER::PropPowerSymsOnly, and THROW_IO_ERROR.
|
overridevirtual |
Populate a list of LIB_SYMBOL alias names contained within the library aLibraryPath.
| aSymbolNameList | is an array to populate with the LIB_SYMBOL names associated with the library. |
| aLibraryPath | is a locator for the "library", usually a directory, file, or URL containing one or more LIB_SYMBOL objects. |
| aProperties | is an associative array that can be used to tell the plugin anything needed about how to perform with respect to aLibraryPath. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL. |
| IO_ERROR | if the library cannot be found, the part library cannot be loaded. |
Reimplemented from SCH_IO.
Definition at line 65 of file sch_io_database.cpp.
References EnumerateSymbolLib().
Referenced by BOOST_AUTO_TEST_CASE(), and EnumerateSymbolLib().
|
overridevirtual |
Retrieves a list of (custom) field names that are present on symbols in this library.
The plugin is responsible for guaranteeing that this list contains the set of unique custom field names present on any symbols contained in the library.
The required KiCad fields are not included in this list.
| aNames | will be filled with any custom fields present in this library. |
Reimplemented from SCH_IO.
Definition at line 222 of file sch_io_database.cpp.
References m_customFields, and m_symbolLoadMutex.
|
overridevirtual |
Retrieves a list of (custom) field names that should be shown by default for this library in the symbol chooser.
This list should be a subset of the result returned by GetAvailableSymbolFields().
The preference for which fields to hide and show for a given library is stored on a per-library basis in a user's preferences (or in the project local settings for a project- local library). The set of fields returned by GetDefaultSymbolFields() will be used if this preference is missing.
| aNames | will be filled with the custom field names that should be shown by default |
Reimplemented from SCH_IO.
Definition at line 230 of file sch_io_database.cpp.
References m_defaultShownFields, and m_symbolLoadMutex.
|
virtualinherited |
Return an error string to the caller.
This is useful for schematic loaders that can load partial schematics where throwing an exception would be problematic such as the KiCad legacy plugin.
Reimplemented in SCH_IO_HTTP_LIB, SCH_IO_KICAD_LEGACY, and SCH_IO_KICAD_SEXPR.
Definition at line 155 of file sch_io.cpp.
References NOT_IMPLEMENTED.
|
virtualinherited |
Return the canonical symbol definitions produced by the last LoadSchematicFile().
An importer implements this so a caller can materialize a project symbol library through SYMBOL_IMPORT_RECONCILER instead of the importer writing one itself. Ownership of the returned symbols passes to the caller.
Reimplemented in SCH_IO_CADSTAR_ARCHIVE, SCH_IO_EASYEDAPRO, and SCH_IO_EASYEDAPRO_V3.
Definition at line 76 of file sch_io.cpp.
References NOT_IMPLEMENTED.
Referenced by ReconcileImportedSymbols().
|
inlineoverridevirtual |
Get the descriptor for the library container that this IO plugin operates on.
Implements IO_BASE.
Definition at line 58 of file sch_io_database.h.
References _HKI, and FILEEXT::DatabaseLibraryFileExtension.
|
inlinevirtualinherited |
Get the descriptor for the individual library elements that this IO plugin operates on.
For libraries where all the elements are in a single container (e.g. all elements in a single file), then this will return the descriptor from IO_BASE::GetLibraryDesc().
Reimplemented in PCB_IO_EASYEDA, PCB_IO_EASYEDAPRO, PCB_IO_GEDA, PCB_IO_KICAD_SEXPR, and PCB_IO_SPRINT_LAYOUT.
Definition at line 117 of file io_base.h.
References GetLibraryDesc().
Referenced by PCB_IO::CanReadFootprint().
|
overridevirtualinherited |
Append supported SCH_IO options to aListToAppenTo along with internationalized descriptions.
Options are typically appended so that a derived SCH_IO can call its base class function by the same name first, thus inheriting options declared there. (Some base class options could pertain to all Symbol*() functions in all derived SCH_IOs.) Note that since aListToAppendTo is a PROPERTIES object, all options will be unique and last guy wins.
| aListToAppendTo | holds a tuple of
In the future perhaps aListToAppendTo evolves to something capable of also holding a wxValidator for the cells in said dialog: http://forums.wxwidgets.org/viewtopic.php?t=23277&p=104180. This would require a 3 column list, and introducing wx GUI knowledge to SCH_IO, which has been avoided to date. |
Reimplemented from IO_BASE.
Reimplemented in SCH_IO_CADSTAR_ARCHIVE.
Definition at line 140 of file sch_io.cpp.
References IO_BASE::GetLibraryOptions().
|
inlineoverridevirtual |
Return the modification hash from the library cache.
Implements SCH_IO.
Definition at line 64 of file sch_io_database.h.
References m_modifyHash.
|
inlineinherited |
Return a brief hard coded name for this IO interface.
Definition at line 79 of file io_base.h.
References m_name.
Referenced by SCH_IO_EASYEDAPRO_V3::EnumerateSymbolLib(), SCH_IO_EASYEDAPRO_V3::LoadSymbol(), SCH_IO_ALTIUM::ParseAltiumSch(), and SCH_IO_ALTIUM::ParseLibFile().
|
virtualinherited |
Returns schematic file description for the SCH_IO.
Reimplemented in SCH_IO_ALTIUM, SCH_IO_CADSTAR_ARCHIVE, SCH_IO_DIPTRACE, SCH_IO_EAGLE, SCH_IO_EASYEDA, SCH_IO_EASYEDAPRO, SCH_IO_EASYEDAPRO_V3, SCH_IO_GEDA, SCH_IO_KICAD_LEGACY, SCH_IO_KICAD_SEXPR, SCH_IO_LTSPICE, SCH_IO_ORCAD, SCH_IO_PADS, and SCH_IO_PCAD.
Definition at line 41 of file sch_io.cpp.
Referenced by CanReadSchematicFile().
|
inlinevirtualinherited |
Gets a description of a sublibrary.
Has no effect if SupportsSubLibraries() returns false.
| aName | contains the name of the sublibrary for which the description is retrieved |
Reimplemented in SCH_IO_HTTP_LIB.
Definition at line 347 of file sch_io.h.
Referenced by SYMBOL_LIBRARY_ADAPTER::GetSubLibraries().
|
overridevirtual |
Retrieves a list of sub-libraries in this library.
Some types of symbol library support sub-libraries, which are a single-level organizational hierarchy that is implementation-defined per plugin. Most of KiCad ignores sub-libraries and treats the hierarchy between library and symbol as flat, but the sub-libraries are used for sorting and grouping symbols in the symbol chooser.
Has no effect if SupportsSubLibraries() returns false.
| aNames | will be filled with a list of sub-libraries within this symbol library |
Reimplemented from SCH_IO.
Definition at line 203 of file sch_io_database.cpp.
References ensureSettings(), m_settings, and DATABASE_LIB_TABLE::name.
|
inlineoverridevirtual |
Return true if the library at aLibraryPath is writable.
The system libraries are typically read only because of where they are installed..
| aLibraryPath | is a locator for the "library", usually a directory, file, or URL containing several footprints. |
| IO_ERROR | if no library at aLibraryPath exists. |
Reimplemented from IO_BASE.
Definition at line 89 of file sch_io_database.h.
|
inlinevirtualinherited |
Work-around for lack of dynamic_cast across compile units on Mac.
Reimplemented in PCB_IO.
Definition at line 84 of file io_base.h.
Referenced by FOOTPRINT_LIBRARY_ADAPTER::pcbplugin().
|
virtualinherited |
Load information from some input file format that this SCH_IO implementation knows about, into either a new SCH_SHEET or an existing one.
This may be used to load an entire new SCH_SHEET, or to augment an existing one if aAppendToMe is not NULL.
| aFileName | is the name of the file to use as input and may be foreign in nature or native in nature. |
| aKiway | is the KIWAY object used to access the symbol libraries loaded by the project. |
| aAppendToMe | is an existing SCH_SHEET to append to, but if NULL then this means "do not append, rather load anew". |
| aProperties | is an associative array that can be used to tell the loader how to load the file, because it can take any number of additional named arguments that the plugin is known to support. These are tuning parameters for the import or load. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL. |
| IO_ERROR | if there is a problem loading, and its contents should say what went wrong, using line number and character offsets of the input file if possible. |
Reimplemented in SCH_IO_ALTIUM, SCH_IO_CADSTAR_ARCHIVE, SCH_IO_DIPTRACE, SCH_IO_EAGLE, SCH_IO_EASYEDA, SCH_IO_EASYEDAPRO, SCH_IO_EASYEDAPRO_V3, SCH_IO_GEDA, SCH_IO_KICAD_LEGACY, SCH_IO_KICAD_SEXPR, SCH_IO_LTSPICE, SCH_IO_ORCAD, SCH_IO_PADS, and SCH_IO_PCAD.
Definition at line 69 of file sch_io.cpp.
References NOT_IMPLEMENTED.
Referenced by SCH::readSchematicFromFile().
|
overridevirtual |
Load a LIB_SYMBOL object having aPartName from the aLibraryPath containing a library format that this SCH_IO knows about.
| aLibraryPath | is a locator for the "library", usually a directory, file, or URL containing several symbols. |
| aPartName | is the name of the LIB_SYMBOL to load. |
| aProperties | is an associative array that can be used to tell the loader implementation to do something special, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL. |
| IO_ERROR | if the library cannot be found or read. No exception is thrown in the case where aAliasName cannot be found. |
Reimplemented from SCH_IO.
Definition at line 114 of file sch_io_database.cpp.
References cacheLib(), LIB_SYMBOL::Duplicate(), ensureConnection(), ensureSettings(), loadSymbolFromRow(), m_adapter, m_cacheMutex, m_conn, m_lastError, m_nameToSymbolcache, m_sanitizedNameMap, m_settings, DATABASE_LIB_TABLE::name, result, table, THROW_IO_ERROR, and traceDatabase.
Referenced by BOOST_AUTO_TEST_CASE().
|
private |
Definition at line 713 of file sch_io_database.cpp.
References _, boolFromAny(), DATABASE_FIELD_MAPPING::column, MAPPABLE_SYMBOL_PROPERTIES::description, SCH_ITEM::Duplicate(), MAPPABLE_SYMBOL_PROPERTIES::exclude_from_board, MAPPABLE_SYMBOL_PROPERTIES::exclude_from_bom, MAPPABLE_SYMBOL_PROPERTIES::exclude_from_sim, DATABASE_LIB_TABLE::fields, MAPPABLE_SYMBOL_PROPERTIES::footprint_filters, DATABASE_LIB_TABLE::footprints_col, SCH_FIELD::GetId(), LIB_SYMBOL::GetName(), SCH_FIELD::GetName(), IGNORE_PARENT_GROUP, DATABASE_FIELD_MAPPING::inherit_properties, SCH_FIELD::IsMandatory(), MAPPABLE_SYMBOL_PROPERTIES::keywords, m_adapter, m_customFields, m_defaultShownFields, m_inProgressLoads, m_symbolLoadMutex, MakeLegacyPinMap(), MANDATORY_FIELDS, DATABASE_LIB_TABLE::name, DATABASE_FIELD_MAPPING::name_wx, LIB_ID::Parse(), ParseAssociatedFootprints(), ParseLegacyPinAssignments(), ParsePinMapSet(), DATABASE_LIB_TABLE::pins_col, DATABASE_LIB_TABLE::properties, IO_BASE::Report(), RPT_SEVERITY_ERROR, SCH_FIELD_T, SCH_FIELD::SetAutoAdded(), SCH_ITEM::SetBodyStyle(), SCH_FIELD::SetName(), SCH_FIELD::SetNameShown(), SCH_FIELD::SetOrdinal(), EDA_ITEM::SetParent(), LIB_ID::SetSubLibraryName(), SCH_FIELD::SetText(), EDA_TEXT::SetVisible(), DATABASE_FIELD_MAPPING::show_name, strValue(), DATABASE_LIB_TABLE::symbols_col, traceDatabase, USER, DATABASE_FIELD_MAPPING::visible_in_chooser, and DATABASE_FIELD_MAPPING::visible_on_add.
Referenced by SCH_IO_DATABASE_CYCLE_DETECTION_FIXTURE::Invoke(), SCH_IO_DATABASE_CYCLE_DETECTION_FIXTURE::InvokeWithCycle(), LoadSymbol(), and materializeCache().
|
private |
Definition at line 296 of file sch_io_database.cpp.
References UTF8::c_str(), LIB_ID::FixIllegalChars(), loadSymbolFromRow(), m_settings, name, result, and table.
Referenced by backgroundRefreshWorker(), and cacheLib().
|
virtualinherited |
Definition at line 124 of file io_base.cpp.
References m_reporter.
Referenced by PCB_IO_IPC2581::addShape(), SCH_IO_EASYEDAPRO_V3::EnumerateSymbolLib(), PCB_IO_ODBPP::ExportODB(), PCB_IO_IPC2581::generateBOMSection(), PCB_IO_IPC2581::generateComponents(), PCB_IO_IPC2581::generateLayerSetDrill(), PCB_IO_IPC2581::generateLayerSetNet(), PCB_IO_IPC2581::generateProfile(), PCB_IO::ImportFootprint(), PCB_IO_DIPTRACE::loadBoard(), PCB_IO_EASYEDAPRO_V3::loadBoard(), SCH_IO_EAGLE::loadInstance(), SCH_IO_EAGLE::loadLibrary(), PCB_IO_KICAD_LEGACY::loadPAD(), PCB_IO_EAGLE::loadPolygon(), SCH_IO_EASYEDAPRO_V3::LoadSchematicFile(), SCH_IO_DATABASE::loadSymbolFromRow(), PCB_IO_KICAD_LEGACY::loadZONE_CONTAINER(), PCB_IO_EAGLE::packageCircle(), PCB_IO_EAGLE::packagePad(), PCB_IO_EAGLE::packagePolygon(), PCB_IO_EAGLE::packageRectangle(), PCB_IO_EAGLE::packageText(), and PCB_IO_EAGLE::packageWire().
|
virtualinherited |
Reimplemented in SCH_IO_KICAD_LEGACY, and SCH_IO_KICAD_SEXPR.
Definition at line 63 of file sch_io.cpp.
References NOT_IMPLEMENTED.
|
virtualinherited |
Write aSchematic to a storage file in a format that this SCH_IO implementation knows about, or it can be used to write a portion of aSchematic to a special kind of export file.
| aFileName | is the name of a file to save to on disk. |
| aSheet | is the class SCH_SHEET in memory document tree from which to extract information when writing to aFileName. The caller continues to own the SCHEMATIC, and the plugin should refrain from modifying the SCHEMATIC if possible. |
| aSchematic | is the SCHEMATIC object used to access any schematic-wide or project information needed to save the document. |
| aProperties | is an associative array that can be used to tell the saver how to save the file, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL. Set the #PropSaveCurrentSheetOnly property to only save the current sheet. Otherwise, all hierarchical sheets are saved. |
| IO_ERROR | if there is a problem saving or exporting. |
Reimplemented in SCH_IO_KICAD_LEGACY, and SCH_IO_KICAD_SEXPR.
Definition at line 82 of file sch_io.cpp.
References NOT_IMPLEMENTED.
|
virtualinherited |
Write aSymbol to an existing library located at aLibraryPath.
If a LIB_SYMBOL by the same name already exists or there are any conflicting alias names, the new LIB_SYMBOL will silently overwrite any existing aliases and/or part because libraries cannot have duplicate alias names. It is the responsibility of the caller to check the library for conflicts before saving.
| aLibraryPath | is a locator for the "library", usually a directory, file, or URL containing several symbols. |
| aSymbol | is what to store in the library. Ownership is transferred to the plugin, which may retain or destroy the symbol: the caller must not use it after this call. |
| aProperties | is an associative array that can be used to tell the saver how to save the symbol, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL. |
| IO_ERROR | if there is a problem saving. |
Reimplemented in SCH_IO_HTTP_LIB, SCH_IO_KICAD_LEGACY, and SCH_IO_KICAD_SEXPR.
Definition at line 124 of file sch_io.cpp.
References NOT_IMPLEMENTED.
Referenced by LIB_BUFFER::SaveBuffer().
|
inlineoverridevirtual |
Some library plugins need to interface with other loaded libraries.
To do this, they receive a reference to the project-specific manager adapter.
Reimplemented from SCH_IO.
Definition at line 91 of file sch_io_database.h.
References m_adapter.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().
|
inlinevirtualinherited |
Set an optional progress reporter.
Reimplemented in SCH_IO_CADSTAR_ARCHIVE.
Definition at line 94 of file io_base.h.
References m_progressReporter.
Referenced by PCB_CONTROL::AppendBoard().
|
inlinevirtualinherited |
Set an optional reporter for warnings/errors.
Reimplemented in SCH_IO_CADSTAR_ARCHIVE.
Definition at line 89 of file io_base.h.
References m_reporter.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), KI_TEST::LoadBoardWithCapture(), SCH_IO_GEDA::loadDeferredSheets(), and SCH_IO_GEDA::LoadSchematicFile().
|
inline |
Definition at line 100 of file sch_io_database.h.
References m_settings.
Referenced by BOOST_AUTO_TEST_CASE().
|
private |
Definition at line 409 of file sch_io_database.cpp.
References backgroundRefreshWorker(), m_refreshRunning, m_refreshThread, and traceDatabase.
Referenced by cacheLib().
|
private |
Definition at line 419 of file sch_io_database.cpp.
References m_refreshCV, m_refreshRunning, and m_refreshThread.
Referenced by ~SCH_IO_DATABASE().
|
inlineoverridevirtual |
Reimplemented from IO_BASE.
Definition at line 96 of file sch_io_database.h.
|
inlineoverridevirtual |
Reimplemented from SCH_IO.
Definition at line 80 of file sch_io_database.h.
| bool SCH_IO_DATABASE::TestConnection | ( | wxString * | aErrorMsg = nullptr | ) |
Definition at line 238 of file sch_io_database.cpp.
References connect(), m_conn, and m_lastError.
|
friend |
Definition at line 51 of file sch_io_database.h.
References SCH_IO_DATABASE_CYCLE_DETECTION_FIXTURE.
Referenced by SCH_IO_DATABASE_CYCLE_DETECTION_FIXTURE.
|
private |
Definition at line 127 of file sch_io_database.h.
Referenced by computeSignature(), EnumerateSymbolLib(), LoadSymbol(), loadSymbolFromRow(), SCH_IO_DATABASE(), and SetLibraryManagerAdapter().
|
private |
Definition at line 168 of file sch_io_database.h.
Referenced by backgroundRefreshWorker(), cacheLib(), connect(), EnumerateSymbolLib(), and LoadSymbol().
|
private |
True once the LIB_SYMBOL cache has been materialized at least once.
Definition at line 144 of file sch_io_database.h.
Referenced by backgroundRefreshWorker(), and cacheLib().
|
private |
Signature of the raw database rows at last materialization; used to skip rebuilding the LIB_SYMBOL cache when a re-query returns identical data.
Definition at line 150 of file sch_io_database.h.
Referenced by backgroundRefreshWorker(), cacheLib(), and SCH_IO_DATABASE().
|
private |
Definition at line 141 of file sch_io_database.h.
Referenced by backgroundRefreshWorker(), cacheLib(), and SCH_IO_DATABASE().
|
private |
Generally will be null if no valid connection is established.
Definition at line 132 of file sch_io_database.h.
Referenced by backgroundRefreshWorker(), cacheLib(), connect(), ensureConnection(), ensureSettings(), EnumerateSymbolLib(), LoadSymbol(), SCH_IO_DATABASE(), and TestConnection().
|
private |
Definition at line 134 of file sch_io_database.h.
Referenced by GetAvailableSymbolFields(), and loadSymbolFromRow().
|
private |
Definition at line 136 of file sch_io_database.h.
Referenced by GetDefaultSymbolFields(), and loadSymbolFromRow().
|
private |
Re-entrancy guard for cacheLib(), tripped when a self-referential load routes back through the adapter into LoadSymbol mid-build.
Definition at line 158 of file sch_io_database.h.
Referenced by cacheLib().
|
private |
LIB_IDs whose resolution is in flight, used to break self-referential cycles where a row's Symbols column points back into the same database library (issue #24249).
Definition at line 154 of file sch_io_database.h.
Referenced by SCH_IO_DATABASE_CYCLE_DETECTION_FIXTURE::InProgressSize(), SCH_IO_DATABASE_CYCLE_DETECTION_FIXTURE::InvokeWithCycle(), SCH_IO_DATABASE_CYCLE_DETECTION_FIXTURE::IsInProgressEmpty(), and loadSymbolFromRow().
|
private |
Definition at line 171 of file sch_io_database.h.
Referenced by connect(), ensureConnection(), EnumerateSymbolLib(), LoadSymbol(), and TestConnection().
|
private |
Definition at line 146 of file sch_io_database.h.
Referenced by backgroundRefreshWorker(), cacheLib(), and GetModifyHash().
|
protectedinherited |
Name of the IO loader.
Definition at line 235 of file io_base.h.
Referenced by PCB_IO_IPC2581::generateBOMSection(), GetName(), and IO_BASE().
|
private |
Definition at line 138 of file sch_io_database.h.
Referenced by backgroundRefreshWorker(), cacheLib(), EnumerateSymbolLib(), and LoadSymbol().
|
protectedinherited |
Progress reporter to track the progress of the operation, may be nullptr.
Definition at line 241 of file io_base.h.
Referenced by AdvanceProgressPhase(), SCH_IO_KICAD_LEGACY::checkpoint(), SCH_IO_CADSTAR_ARCHIVE::ensureLoadedLibrary(), SCH_IO_EAGLE::ensureLoadedLibrary(), PCB_IO_ODBPP::ExportODB(), PCB_IO_IPC2581::generateComponents(), PCB_IO_IPC2581::generatePhyNetGroup(), IO_BASE(), PCB_IO_ALTIUM_CIRCUIT_MAKER::loadBoard(), PCB_IO_ALTIUM_CIRCUIT_STUDIO::loadBoard(), PCB_IO_ALTIUM_DESIGNER::loadBoard(), PCB_IO_CADSTAR_ARCHIVE::loadBoard(), PCB_IO_DIPTRACE::loadBoard(), PCB_IO_EASYEDA::loadBoard(), PCB_IO_EASYEDAPRO::loadBoard(), PCB_IO_EASYEDAPRO_V3::loadBoard(), PCB_IO_FABMASTER::loadBoard(), PCB_IO_KICAD_SEXPR::loadBoard(), PCB_IO_PADS::loadBoard(), PCB_IO_PADS_BINARY::loadBoard(), PCB_IO_SOLIDWORKS::loadBoard(), PCB_IO_ALLEGRO::LoadBoardFromData(), SCH_IO_KICAD_LEGACY::loadFile(), SCH_IO_KICAD_SEXPR::loadFile(), SCH_IO_ORCAD::loadOlbSymbols(), SCH_IO_CADSTAR_ARCHIVE::LoadSchematicFile(), SCH_IO_DIPTRACE::LoadSchematicFile(), SCH_IO_EAGLE::LoadSchematicFile(), SCH_IO_LTSPICE::LoadSchematicFile(), SCH_IO_ORCAD::LoadSchematicFile(), SCH_IO_PADS::LoadSchematicFile(), SCH_IO_ALTIUM::ParseAltiumSch(), PCB_IO_IPC2581::reportPhase(), PCB_IO_IPC2581::SaveBoard(), SetProgressReporter(), SCH_IO_CADSTAR_ARCHIVE::SetProgressReporter(), and PCB_IO_IPC2581::tickProgress().
|
private |
Definition at line 166 of file sch_io_database.h.
Referenced by backgroundRefreshWorker(), and stopBackgroundRefresh().
|
private |
Definition at line 167 of file sch_io_database.h.
Referenced by backgroundRefreshWorker().
|
private |
Definition at line 165 of file sch_io_database.h.
Referenced by backgroundRefreshWorker(), cacheLib(), startBackgroundRefresh(), and stopBackgroundRefresh().
|
private |
Definition at line 164 of file sch_io_database.h.
Referenced by startBackgroundRefresh(), and stopBackgroundRefresh().
|
protectedinherited |
Reporter to log errors/warnings to, may be nullptr.
Definition at line 238 of file io_base.h.
Referenced by PCB_IO_CADSTAR_ARCHIVE::ensureLoadedLibrary(), SCH_IO_CADSTAR_ARCHIVE::ensureLoadedLibrary(), SCH_IO_GEDA::flushPendingComponent(), PCB_IO_ALTIUM_DESIGNER::FootprintLoad(), SCH_IO_GEDA::getOrLoadSymbol(), SCH_IO_GEDA::importHierarchicalSheet(), IO_BASE(), SCH_IO_PADS::loadBinarySchematicFile(), PCB_IO_ALTIUM_CIRCUIT_MAKER::loadBoard(), PCB_IO_ALTIUM_CIRCUIT_STUDIO::loadBoard(), PCB_IO_ALTIUM_DESIGNER::loadBoard(), PCB_IO_AUTOTRAX::loadBoard(), PCB_IO_CADSTAR_ARCHIVE::loadBoard(), PCB_IO_FABMASTER::loadBoard(), PCB_IO_PADS::loadBoard(), PCB_IO_PADS_BINARY::loadBoard(), PCB_IO_PCAD::loadBoard(), PCB_IO_SOLIDWORKS::loadBoard(), PCB_IO_ALLEGRO::LoadBoardFromData(), PCB_IO_PADS::loadCopperShapes(), PCB_IO_PADS_BINARY::loadCopperShapes(), SCH_IO_GEDA::loadDeferredSheets(), PCB_IO_PADS::loadFootprints(), PCB_IO_PADS_BINARY::loadFootprints(), SCH_IO_ORCAD::loadOlbSymbols(), SCH_IO_ALTIUM::LoadSchematicFile(), SCH_IO_CADSTAR_ARCHIVE::LoadSchematicFile(), SCH_IO_DIPTRACE::LoadSchematicFile(), SCH_IO_GEDA::LoadSchematicFile(), SCH_IO_LTSPICE::LoadSchematicFile(), SCH_IO_ORCAD::LoadSchematicFile(), SCH_IO_PADS::LoadSchematicFile(), PCB_IO_PADS::loadTracksAndVias(), PCB_IO_PADS_BINARY::loadTracksAndVias(), PCB_IO_PADS::loadZones(), PCB_IO_PADS_BINARY::loadZones(), SCH_IO_ALTIUM::ParseLibFile(), SCH_IO_ALTIUM::ParsePowerPort(), SCH_IO_PCAD::populateScreen(), Report(), SCH_IO_ALTIUM::SCH_IO_ALTIUM(), SCH_IO_CADSTAR_ARCHIVE::SCH_IO_CADSTAR_ARCHIVE(), SCH_IO_DIPTRACE::SCH_IO_DIPTRACE(), SCH_IO_EASYEDA::SCH_IO_EASYEDA(), SCH_IO_LTSPICE::SCH_IO_LTSPICE(), SCH_IO_ORCAD::SCH_IO_ORCAD(), SetReporter(), and SCH_IO_CADSTAR_ARCHIVE::SetReporter().
|
private |
Definition at line 139 of file sch_io_database.h.
Referenced by backgroundRefreshWorker(), cacheLib(), and LoadSymbol().
|
private |
Definition at line 129 of file sch_io_database.h.
Referenced by backgroundRefreshWorker(), cacheLib(), connect(), ensureConnection(), ensureSettings(), GetSubLibraryNames(), LoadSymbol(), materializeCache(), SCH_IO_DATABASE(), and Settings().
|
private |
Definition at line 169 of file sch_io_database.h.
Referenced by GetAvailableSymbolFields(), GetDefaultSymbolFields(), and loadSymbolFromRow().