KiCad PCB EDA Suite
Loading...
Searching...
No Matches
api_handler_sch_libraries.cpp
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
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
22
24#include <pgm_base.h>
25#include <project_sch.h>
27#include <lib_symbol.h>
28
29
34
35
37 const wxString& aNickname ) const
38{
39 return static_cast<SYMBOL_LIBRARY_ADAPTER&>( aAdapter ).GetSymbolNames( aNickname );
40}
41
42
43bool API_HANDLER_SCH_LIBRARIES::packLibraryItem( const LIB_ID& aId, google::protobuf::Any& aOutput ) const
44{
45 SYMBOL_LIBRARY_ADAPTER* adapter =
46 static_cast<SYMBOL_LIBRARY_ADAPTER*>( adapterForProject( Pgm().GetSettingsManager().Prj() ) );
47
48 LIB_SYMBOL* libSymbol = adapter->LoadSymbol( aId );
49
50 if( !libSymbol )
51 return false;
52
53 libSymbol->Serialize( aOutput );
54 return true;
55}
LIBRARY_MANAGER_ADAPTER * adapterForProject(PROJECT &aProject) const override
std::vector< wxString > getItemNames(LIBRARY_MANAGER_ADAPTER &aAdapter, const wxString &aNickname) const override
Returns the names of all entries in the given library, or an empty vector if the library is not loade...
bool packLibraryItem(const LIB_ID &aId, google::protobuf::Any &aOutput) const override
The interface used by the classes that actually can load IO plugins for the different parts of KiCad ...
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:45
Define a library symbol object.
Definition lib_symbol.h:119
void Serialize(kiapi::schematic::types::SchematicSymbol &aOutput, bool aSkipPins=false) const
static SYMBOL_LIBRARY_ADAPTER * SymbolLibAdapter(PROJECT *aProject)
Accessor for project symbol library manager adapter.
Container for project specific data.
Definition project.h:63
An interface to the global shared library manager that is schematic-specific and linked to one projec...
LIB_SYMBOL * LoadSymbol(const wxString &aNickname, const wxString &aName)
Load a LIB_SYMBOL having aName from the library given by aNickname.
PROJECT & Prj()
Definition kicad.cpp:727
PGM_BASE & Pgm()
The global program "get" accessor.
see class PGM_BASE