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
117 virtual SCH_SHEET* LoadSchematicFile( const wxString& aFileName, SCHEMATIC* aSchematic,
118 SCH_SHEET* aAppendToMe = nullptr,
119 const std::map<std::string, UTF8>* aProperties = nullptr );
120
128 virtual std::vector<LIB_SYMBOL*> GetImportedCachedLibrarySymbols();
129
155 virtual void SaveSchematicFile( const wxString& aFileName, SCH_SHEET* aSheet,
156 SCHEMATIC* aSchematic,
157 const std::map<std::string, UTF8>* aProperties = nullptr );
158
175 virtual void EnumerateSymbolLib( wxArrayString& aSymbolNameList, const wxString& aLibraryPath,
176 const std::map<std::string, UTF8>* aProperties = nullptr );
177
197 virtual void EnumerateSymbolLib( std::vector<LIB_SYMBOL*>& aSymbolList,
198 const wxString& aLibraryPath,
199 const std::map<std::string, UTF8>* aProperties = nullptr );
200
219 virtual void CheckLibrary( const wxString& aLibraryPath,
220 const std::map<std::string, UTF8>* aProperties = nullptr );
221
243 virtual LIB_SYMBOL* LoadSymbol( const wxString& aLibraryPath, const wxString& aPartName,
244 const std::map<std::string, UTF8>* aProperties = nullptr );
245
268 virtual void SaveSymbol( const wxString& aLibraryPath, std::unique_ptr<LIB_SYMBOL> aSymbol,
269 const std::map<std::string, UTF8>* aProperties = nullptr );
270
289 virtual void DeleteSymbol( const wxString& aLibraryPath, const wxString& aSymbolName,
290 const std::map<std::string, UTF8>* aProperties = nullptr );
291
316 virtual void GetLibraryOptions( std::map<std::string, UTF8>* aListToAppendTo ) const override;
317
321 virtual bool SupportsSubLibraries() const { return false; }
322
335 virtual void GetSubLibraryNames( std::vector<wxString>& aNames ) {}
336
346 virtual wxString GetSubLibraryDescription( const wxString& aName ) { return wxEmptyString; }
347
357 virtual void GetAvailableSymbolFields( std::vector<wxString>& aNames ) {}
358
371 virtual void GetDefaultSymbolFields( std::vector<wxString>& aNames )
372 {
373 return GetAvailableSymbolFields( aNames );
374 }
375
384 virtual const wxString& GetError() const;
385
391
392 //-----</PUBLIC SCH_IO API>------------------------------------------------
393
394
395 /* The compiler writes the "zero argument" constructor for a SCH_IO
396 automatically if you do not provide one. If you decide you need to
397 provide a zero argument constructor of your own design, that is allowed.
398 It must be public, and it is what the SCH_IO_MGR uses. Parameters may be
399 passed into a SCH_IO via the PROPERTIES variable for any of the public
400 API functions which take one.
401 */
402 virtual ~SCH_IO() { }
403
404protected:
405
406 SCH_IO( const wxString& aName ) : IO_BASE( aName )
407 {}
408};
409
410
411#endif // SCH_IO_H_
IO_BASE()=delete
Define a library symbol object.
Definition lib_symbol.h:114
Holds all the data relating to one schematic.
Definition schematic.h:149
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:321
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:406
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:357
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:402
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:390
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:346
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:371
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:335
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