KiCad PCB EDA Suite
Loading...
Searching...
No Matches
design_block_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) 2024 Mike Williams <[email protected]>
5 * Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24#ifndef DESIGN_BLOCK_IO_H
25#define DESIGN_BLOCK_IO_H
26
27#include <kicommon.h>
28#include <io/io_base.h>
29#include <io/io_mgr.h>
30
31class DESIGN_BLOCK;
32class DESIGN_BLOCK_IO;
33class wxArrayString;
34
36{
37public:
39 {
40 DESIGN_BLOCK_FILE_UNKNOWN = 0,
42
43 FILE_TYPE_NONE
44 };
45
46 static const wxString ShowType( DESIGN_BLOCK_FILE_T aFileType );
47 static DESIGN_BLOCK_IO* FindPlugin( DESIGN_BLOCK_FILE_T aFileType );
48 static DESIGN_BLOCK_FILE_T EnumFromStr( const wxString& aFileType );
49 static DESIGN_BLOCK_FILE_T GuessPluginTypeFromLibPath( const wxString& aLibPath, int aCtl = 0 );
53 static bool ConvertLibrary( std::map<std::string, UTF8>* aOldFileProps,
54 const wxString& aOldFilePath, const wxString& aNewFilePath );
55};
56
57
59{
60public:
61 DESIGN_BLOCK_IO() : IO_BASE( wxS( "KiCad" ) ) {}
62
63 const IO_BASE::IO_FILE_DESC GetLibraryDesc() const override;
64 long long GetLibraryTimestamp( const wxString& aLibraryPath ) const;
65
66 void DesignBlockEnumerate( wxArrayString& aDesignBlockNames, const wxString& aLibraryPath,
67 bool aBestEfforts,
68 const std::map<std::string, UTF8>* aProperties = nullptr );
69
70 const DESIGN_BLOCK*
71 GetEnumeratedDesignBlock( const wxString& aLibraryPath, const wxString& aDesignBlockName,
72 const std::map<std::string, UTF8>* aProperties = nullptr )
73 {
74 return DesignBlockLoad( aLibraryPath, aDesignBlockName, false, aProperties );
75 }
76
77 bool DesignBlockExists( const wxString& aLibraryPath, const wxString& aDesignBlockName,
78 const std::map<std::string, UTF8>* aProperties = nullptr )
79 {
80 return DesignBlockLoad( aLibraryPath, aDesignBlockName, true, aProperties ) != nullptr;
81 }
82
83 DESIGN_BLOCK* ImportDesignBlock( const wxString& aDesignBlockPath,
84 wxString& aDesignBlockNameOut,
85 const std::map<std::string, UTF8>* aProperties = nullptr )
86 {
87 return nullptr;
88 }
89
90 void CreateLibrary( const wxString& aLibraryPath,
91 const std::map<std::string, UTF8>* aProperties = nullptr ) override;
92
93 virtual bool DeleteLibrary( const wxString& aLibraryPath,
94 const std::map<std::string, UTF8>* aProperties = nullptr ) override;
95
96
97 bool IsLibraryWritable( const wxString& aLibraryPath ) override;
98
99 DESIGN_BLOCK* DesignBlockLoad( const wxString& aLibraryPath, const wxString& aDesignBlockName,
100 bool aKeepUUID = false,
101 const std::map<std::string, UTF8>* aProperties = nullptr );
102
103 void DesignBlockSave( const wxString& aLibraryPath, const DESIGN_BLOCK* aDesignBlock,
104 const std::map<std::string, UTF8>* aProperties = nullptr );
105
106 void DesignBlockDelete( const wxString& aLibraryPath, const wxString& aDesignBlockName,
107 const std::map<std::string, UTF8>* aProperties = nullptr );
108
109 virtual void PrefetchLib( const wxString& aLibraryPath,
110 const std::map<std::string, UTF8>* aProperties = nullptr )
111 {
112 }
113};
114
115#endif
@ KICAD_SEXP
S-expression KiCad file format.
bool DesignBlockExists(const wxString &aLibraryPath, const wxString &aDesignBlockName, const std::map< std::string, UTF8 > *aProperties=nullptr)
virtual void PrefetchLib(const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr)
const DESIGN_BLOCK * GetEnumeratedDesignBlock(const wxString &aLibraryPath, const wxString &aDesignBlockName, const std::map< std::string, UTF8 > *aProperties=nullptr)
DESIGN_BLOCK * ImportDesignBlock(const wxString &aDesignBlockPath, wxString &aDesignBlockNameOut, const std::map< std::string, UTF8 > *aProperties=nullptr)
Definition: io_mgr.h:37
#define KICOMMON_API
Definition: kicommon.h:28
Container that describes file type info.
Definition: io_base.h:43