KiCad PCB EDA Suite
Loading...
Searching...
No Matches
design_block_library_adapter.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 * @author Jon Evans <[email protected]>
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21
22#ifndef DESIGN_BLOCK_LIBRARY_ADAPTER_H
23#define DESIGN_BLOCK_LIBRARY_ADAPTER_H
24
25#include <kicommon.h>
26#include <lib_id.h>
28
29class DESIGN_BLOCK;
30class DESIGN_BLOCK_IO;
31class PROJECT;
32
33
35{
36public:
38
40
41 static wxString GlobalPathEnvVariableName();
42
43 void AsyncLoad() override;
44
46 std::vector<DESIGN_BLOCK*> GetDesignBlocks( const wxString& aNickname );
47
49 std::vector<wxString> GetDesignBlockNames( const wxString& aNickname );
50
64 DESIGN_BLOCK* LoadDesignBlock( const wxString& aNickname, const wxString& aDesignBlockName,
65 bool aKeepUUID = false );
66
70 bool DesignBlockExists( const wxString& aNickname, const wxString& aDesignBlockName );
71
78 // TODO(JE) library tables -- do we still need this?
79 const DESIGN_BLOCK* GetEnumeratedDesignBlock( const wxString& aNickname, const wxString& aDesignBlockName );
80
89
104 SAVE_T SaveDesignBlock( const wxString& aNickname, const DESIGN_BLOCK* aDesignBlock,
105 bool aOverwrite = true );
106
116 void DeleteDesignBlock( const wxString& aNickname, const wxString& aDesignBlockName );
117
125 bool IsDesignBlockLibWritable( const wxString& aNickname );
126
141 DESIGN_BLOCK* DesignBlockLoadWithOptionalNickname( const LIB_ID& aDesignBlockId,
142 bool aKeepUUID = false );
143
144 std::optional<LIBRARY_ERROR> LibraryError( const wxString& aNickname ) const;
145
146protected:
147
148 std::map<wxString, LIB_DATA>& globalLibs() override { return GlobalLibraries; }
149 std::map<wxString, LIB_DATA>& globalLibs() const override { return GlobalLibraries; }
150 std::mutex& globalLibsMutex() override { return GlobalLibraryMutex; }
151
153
154private:
155
157 static DESIGN_BLOCK_IO* plugin( const LIB_DATA* aRow );
158
159 // The global libraries, potentially shared between multiple different open
160 // projects, each of which has their own instance of this adapter class
161 static std::map<wxString, LIB_DATA> GlobalLibraries;
162
163 static std::mutex GlobalLibraryMutex;
164};
165
166
167
168#endif //DESIGN_BLOCK_LIBRARY_ADAPTER_H
SAVE_T
The set of return values from DesignBlockSave() below.
std::map< wxString, LIB_DATA > & globalLibs() const override
std::map< wxString, LIB_DATA > & globalLibs() override
LIBRARY_TABLE_TYPE Type() const override
The type of library table this adapter works with.
static std::map< wxString, LIB_DATA > GlobalLibraries
DESIGN_BLOCK_LIBRARY_ADAPTER(LIBRARY_MANAGER &aManager)
LIBRARY_MANAGER_ADAPTER(LIBRARY_MANAGER &aManager)
Constructs a type-specific adapter into the library manager.
virtual void AsyncLoad()=0
Loads all available libraries for this adapter type in the background.
virtual LIBRARY_RESULT< IO_BASE * > createPlugin(const LIBRARY_TABLE_ROW *row)=0
Creates a concrete plugin for the given row.
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:49
Container for project specific data.
Definition project.h:65
#define KICOMMON_API
Definition kicommon.h:28
tl::expected< ResultType, LIBRARY_ERROR > LIBRARY_RESULT
LIBRARY_TABLE_TYPE
Storage for an actual loaded library (including library content owned by the plugin)