KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_io.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2016 CERN
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * @author Wayne Stambaugh <[email protected]>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 3
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
23#ifndef SCH_IO_H_
24#define SCH_IO_H_
25
26#include <io/io_base.h>
27#include <memory>
28#include <sch_io/sch_io_mgr.h>
29#include <import_export.h>
30#include <map>
31#include <enum_vector.h>
32#include <reporter.h>
33#include <i18n_utility.h>
34#include <wx/arrstr.h>
35
37
59class SCH_IO : public IO_BASE
60{
61public:
62
63 //-----<PUBLIC SCH_IO API>-------------------------------------------------
64
68 virtual const IO_BASE::IO_FILE_DESC GetSchematicFileDesc() const;
69
74 virtual bool CanReadSchematicFile( const wxString& aFileName ) const;
75
85 virtual int GetModifyHash() const = 0;
86
87 virtual void SaveLibrary( const wxString& aFileName,
88 const std::map<std::string, UTF8>* aProperties = nullptr );
89
118 virtual SCH_SHEET* LoadSchematicFile( const wxString& aFileName, SCHEMATIC* aSchematic,
119 SCH_SHEET* aAppendToMe = nullptr,
120 const std::map<std::string, UTF8>* aProperties = nullptr );
121
129 virtual std::vector<LIB_SYMBOL*> GetImportedCachedLibrarySymbols();
130
156 virtual void SaveSchematicFile( const wxString& aFileName, SCH_SHEET* aSheet,
157 SCHEMATIC* aSchematic,
158 const std::map<std::string, UTF8>* aProperties = nullptr );
159
176 virtual void EnumerateSymbolLib( wxArrayString& aSymbolNameList, const wxString& aLibraryPath,
177 const std::map<std::string, UTF8>* aProperties = nullptr );
178
198 virtual void EnumerateSymbolLib( std::vector<LIB_SYMBOL*>& aSymbolList,
199 const wxString& aLibraryPath,
200 const std::map<std::string, UTF8>* aProperties = nullptr );
201
220 virtual void CheckLibrary( const wxString& aLibraryPath,
221 const std::map<std::string, UTF8>* aProperties = nullptr );
222
244 virtual LIB_SYMBOL* LoadSymbol( const wxString& aLibraryPath, const wxString& aPartName,
245 const std::map<std::string, UTF8>* aProperties = nullptr );
246
269 virtual void SaveSymbol( const wxString& aLibraryPath, std::unique_ptr<LIB_SYMBOL> aSymbol,
270 const std::map<std::string, UTF8>* aProperties = nullptr );
271
290 virtual void DeleteSymbol( const wxString& aLibraryPath, const wxString& aSymbolName,
291 const std::map<std::string, UTF8>* aProperties = nullptr );
292
317 virtual void GetLibraryOptions( std::map<std::string, UTF8>* aListToAppendTo ) const override;
318
322 virtual bool SupportsSubLibraries() const { return false; }
323
336 virtual void GetSubLibraryNames( std::vector<wxString>& aNames ) {}
337
347 virtual wxString GetSubLibraryDescription( const wxString& aName ) { return wxEmptyString; }
348
358 virtual void GetAvailableSymbolFields( std::vector<wxString>& aNames ) {}
359
372 virtual void GetDefaultSymbolFields( std::vector<wxString>& aNames )
373 {
374 return GetAvailableSymbolFields( aNames );
375 }
376
385 virtual const wxString& GetError() const;
386
392
393 //-----</PUBLIC SCH_IO API>------------------------------------------------
394
395
396 /* The compiler writes the "zero argument" constructor for a SCH_IO
397 automatically if you do not provide one. If you decide you need to
398 provide a zero argument constructor of your own design, that is allowed.
399 It must be public, and it is what the SCH_IO_MGR uses. Parameters may be
400 passed into a SCH_IO via the PROPERTIES variable for any of the public
401 API functions which take one.
402 */
403 virtual ~SCH_IO() { }
404
405protected:
406
407 SCH_IO( const wxString& aName ) : IO_BASE( aName )
408 {}
409};
410
411
412#endif // SCH_IO_H_
IO_BASE()=delete
Define a library symbol object.
Definition lib_symbol.h:119
Holds all the data relating to one schematic.
Definition schematic.h:148
virtual void EnumerateSymbolLib(wxArrayString &aSymbolNameList, const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr)
Populate a list of LIB_SYMBOL alias names contained within the library aLibraryPath.
Definition sch_io.cpp:90
virtual bool SupportsSubLibraries() const
Definition sch_io.h:322
virtual bool CanReadSchematicFile(const wxString &aFileName) const
Checks if this SCH_IO can read the specified schematic file.
Definition sch_io.cpp:47
virtual int GetModifyHash() const =0
Return the modification hash from the library cache.
SCH_IO(const wxString &aName)
Definition sch_io.h:407
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,...
Definition sch_io.cpp:69
virtual void GetAvailableSymbolFields(std::vector< wxString > &aNames)
Retrieves a list of (custom) field names that are present on symbols in this library.
Definition sch_io.h:358
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.
Definition sch_io.cpp:132
virtual void CheckLibrary(const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr)
Validate that the library at aLibraryPath is reachable and well-formed, without necessarily loading s...
Definition sch_io.cpp:108
virtual std::vector< LIB_SYMBOL * > GetImportedCachedLibrarySymbols()
Return the canonical symbol definitions produced by the last LoadSchematicFile().
Definition sch_io.cpp:76
virtual void SaveLibrary(const wxString &aFileName, const std::map< std::string, UTF8 > *aProperties=nullptr)
Definition sch_io.cpp:63
virtual LIB_SYMBOL * LoadSymbol(const wxString &aLibraryPath, const wxString &aPartName, const std::map< std::string, UTF8 > *aProperties=nullptr)
Load a LIB_SYMBOL object having aPartName from the aLibraryPath containing a library format that this...
Definition sch_io.cpp:116
virtual void GetLibraryOptions(std::map< std::string, UTF8 > *aListToAppendTo) const override
Append supported SCH_IO options to aListToAppenTo along with internationalized descriptions.
Definition sch_io.cpp:140
virtual ~SCH_IO()
Definition sch_io.h:403
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.
Definition sch_io.cpp:124
virtual void SetLibraryManagerAdapter(SYMBOL_LIBRARY_ADAPTER *aAdapter)
Some library plugins need to interface with other loaded libraries.
Definition sch_io.h:391
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,...
Definition sch_io.cpp:82
virtual const wxString & GetError() const
Return an error string to the caller.
Definition sch_io.cpp:155
virtual wxString GetSubLibraryDescription(const wxString &aName)
Gets a description of a sublibrary.
Definition sch_io.h:347
virtual void GetDefaultSymbolFields(std::vector< wxString > &aNames)
Retrieves a list of (custom) field names that should be shown by default for this library in the symb...
Definition sch_io.h:372
virtual const IO_BASE::IO_FILE_DESC GetSchematicFileDesc() const
Returns schematic file description for the SCH_IO.
Definition sch_io.cpp:41
virtual void GetSubLibraryNames(std::vector< wxString > &aNames)
Retrieves a list of sub-libraries in this library.
Definition sch_io.h:336
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition sch_sheet.h:48
An interface to the global shared library manager that is schematic-specific and linked to one projec...
Some functions to handle hotkeys in KiCad.
Container that describes file type info.
Definition io_base.h:43