|
KiCad PCB EDA Suite
|
#include <api_handler_fp_libraries.h>
Public Member Functions | |
| API_HANDLER_FP_LIBRARIES () | |
| void | SetKiway (KIWAY *aKiway) |
| void | SetLibraryHandlerRegistrar (std::function< void(KIFACE *)> aRegistrar) |
| Set a callback to register the handler on the API server in headless mode. | |
| API_RESULT | Handle (ApiRequest &aMsg) |
| Attempt to handle the given API request, if a handler exists in this class for the message. | |
| bool | CanHandle (const std::string &aTypeName) const |
| bool | AllowsDuringTask (const std::string &aTypeName) const |
| virtual void | onNetSettingsChanged () |
| Called on all registered handlers after project net settings (netclasses or netclass assignments) have been changed via the API. | |
| void | requestNetSettingsNotification () |
| bool | clearNetSettingsNotification () |
| Returns true if the notification had been requested at the time of the call. | |
| void | setApiServer (KICAD_API_SERVER *aServer) |
| Set by KICAD_API_SERVER::RegisterHandler; null when the handler is not registered. | |
| KICAD_API_SERVER * | apiServer () const |
Protected Types | |
| typedef std::function< HANDLER_RESULT< ApiResponse >(ApiRequest &)> | REQUEST_HANDLER |
| A handler for outer messages (envelopes) that will unpack to inner messages and call a specific handler function. | |
Protected Member Functions | |
| LIBRARY_MANAGER_ADAPTER * | adapterForProject (PROJECT &aProject) const override |
| bool | packLibraryItem (const LIB_ID &aId, google::protobuf::Any &aOutput) 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 loaded (or cannot be enumerated). | |
| HANDLER_RESULT< kiapi::common::commands::LibraryItemsResponse > | handleGetLibraryItems (const HANDLER_CONTEXT< kiapi::common::commands::GetLibraryItems > &aCtx) |
| HANDLER_RESULT< kiapi::common::commands::LibraryStatusResponse > | handleGetLibraryStatuses (const HANDLER_CONTEXT< kiapi::common::commands::GetLibraryStatuses > &aCtx) |
| HANDLER_RESULT< kiapi::common::types::LibraryCommandStatus > | handleReloadLibrary (const HANDLER_CONTEXT< kiapi::common::commands::ReloadLibrary > &aCtx) |
| HANDLER_RESULT< kiapi::common::types::LibraryCommandStatus > | handleLoadAllLibraries (const HANDLER_CONTEXT< kiapi::common::commands::LoadAllLibraries > &aCtx) |
| kiapi::common::types::LibraryCommandStatus | loadAllLibraries () |
| Starts a background load of all libraries of this handler's type. | |
| HANDLER_RESULT< kiapi::common::commands::GetItemsResponse > | handleGetItemsFromLibrary (const HANDLER_CONTEXT< kiapi::common::commands::GetItemsFromLibrary > &aCtx) |
| LIBRARY_TABLE_TYPE | libraryType () const |
| template<class RequestType, class ResponseType, class HandlerType> | |
| void | registerHandler (HANDLER_RESULT< ResponseType >(HandlerType::*aHandler)(const HANDLER_CONTEXT< RequestType > &), bool aAllowedDuringTask=false) |
| Registers an API command handler for the given message types. | |
Protected Attributes | |
| std::map< std::string, HANDLER_ENTRY > | m_handlers |
| Maps type name (without the URL prefix) to a handler method. | |
| bool | m_notifyNetSettings = false |
| KICAD_API_SERVER * | m_apiServer = nullptr |
Static Protected Attributes | |
| static const wxString | m_defaultCommitMessage = _( "Modification from API" ) |
Private Member Functions | |
| template<typename MessageType> | |
| bool | tryUnpack (ApiRequest &aRequest, ApiResponse &aReply, MessageType &aDest) |
Private Attributes | |
| LIBRARY_TABLE_TYPE | m_type |
| KIWAY * | m_kiway = nullptr |
| Used to lazily load kifaces for LoadAllLibraries in headless; null in GUI mode. | |
| std::function< void(KIFACE *)> | m_handlerRegisterCallback |
| Invoked with a lazily-loaded KIFACE so its handlers can be registered on the server. | |
Definition at line 27 of file api_handler_fp_libraries.h.
|
protectedinherited |
A handler for outer messages (envelopes) that will unpack to inner messages and call a specific handler function.
Definition at line 112 of file api_handler.h.
|
inline |
Definition at line 30 of file api_handler_fp_libraries.h.
References API_HANDLER_LIBRARIES::API_HANDLER_LIBRARIES().
|
overrideprotectedvirtual |
Reimplemented from API_HANDLER_LIBRARIES.
Definition at line 32 of file api_handler_fp_libraries.cpp.
References PROJECT_PCB::FootprintLibAdapter().
Referenced by packLibraryItem().
|
inlineinherited |
Definition at line 81 of file api_handler.h.
References m_handlers.
Referenced by BOOST_AUTO_TEST_CASE().
|
inlineinherited |
Definition at line 105 of file api_handler.h.
References m_apiServer.
Referenced by API_HANDLER_PCB::handleSaveDocumentAs(), and API_HANDLER_SCH::handleSaveDocumentAs().
|
inlineinherited |
Definition at line 73 of file api_handler.h.
References m_handlers.
Referenced by BOOST_AUTO_TEST_CASE().
|
inlineinherited |
Returns true if the notification had been requested at the time of the call.
Definition at line 96 of file api_handler.h.
References m_notifyNetSettings.
|
overrideprotectedvirtual |
Returns the names of all entries in the given library, or an empty vector if the library is not loaded (or cannot be enumerated).
Reimplemented from API_HANDLER_LIBRARIES.
Definition at line 38 of file api_handler_fp_libraries.cpp.
|
inherited |
Attempt to handle the given API request, if a handler exists in this class for the message.
| aMsg | is a request to attempt to handle |
Definition at line 30 of file api_handler.cpp.
References m_handlers.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().
|
protectedinherited |
Definition at line 444 of file api_handler_libraries.cpp.
References adapterForProject(), SETTINGS_MANAGER::GetProjectForPath(), PGM_BASE::GetSettingsManager(), LIBRARY_MANAGER_ADAPTER::LoadLibraryEntry(), m_type, packLibraryItem(), Pgm(), SETTINGS_MANAGER::Prj(), project, HANDLER_CONTEXT< RequestMessageType >::Request, and ToProtoEnum().
Referenced by API_HANDLER_LIBRARIES().
|
protectedinherited |
Definition at line 81 of file api_handler_libraries.cpp.
References adapterForProject(), getItemNames(), PGM_BASE::GetSettingsManager(), LIBRARY_MANAGER_ADAPTER::LoadLibraryEntry(), m_type, Pgm(), SETTINGS_MANAGER::Prj(), project, HANDLER_CONTEXT< RequestMessageType >::Request, LIBRARY_MANAGER_ADAPTER::Rows(), and ToProtoEnum().
Referenced by API_HANDLER_LIBRARIES().
|
protectedinherited |
Definition at line 169 of file api_handler_libraries.cpp.
References LIBRARY_MANAGER::Adapter(), DESIGN_BLOCK, FOOTPRINT, FromProtoEnum(), PGM_BASE::GetLibraryManager(), LIBRARY_MANAGER_ADAPTER::GetLibraryStatus(), packLibraryStatusEntry(), Pgm(), HANDLER_CONTEXT< RequestMessageType >::Request, LIBRARY_MANAGER::Rows(), SYMBOL, and UNINITIALIZED.
Referenced by API_HANDLER_LIBRARIES().
|
protectedinherited |
Definition at line 324 of file api_handler_libraries.cpp.
References DESIGN_BLOCK, KIWAY::FACE_PCB, KIWAY::FACE_SCH, FOOTPRINT, FromProtoEnum(), KIWAY::KiFACE(), kiface(), KIWAY::KIWAY_FACE_COUNT, loadAllLibraries(), m_handlerRegisterCallback, m_kiway, Pgm(), HANDLER_CONTEXT< RequestMessageType >::Request, and SYMBOL.
Referenced by API_HANDLER_LIBRARIES().
|
protectedinherited |
Definition at line 238 of file api_handler_libraries.cpp.
References LIBRARY_MANAGER::Adapter(), FromProtoEnum(), PGM_BASE::GetLibraryManager(), LIBRARY_MANAGER::GetRow(), GLOBAL, Pgm(), PROJECT, LIBRARY_MANAGER::ReloadLibraryEntry(), HANDLER_CONTEXT< RequestMessageType >::Request, and LIBRARY_MANAGER::Rows().
Referenced by API_HANDLER_LIBRARIES().
|
inlineprotectedinherited |
Definition at line 83 of file api_handler_libraries.h.
References m_type.
|
protectedinherited |
Starts a background load of all libraries of this handler's type.
Definition at line 425 of file api_handler_libraries.cpp.
References adapterForProject(), LIBRARY_MANAGER_ADAPTER::AsyncLoad(), Pgm(), and Prj().
Referenced by handleLoadAllLibraries().
|
inlinevirtualinherited |
Called on all registered handlers after project net settings (netclasses or netclass assignments) have been changed via the API.
Reimplemented in API_HANDLER_PCB, and API_HANDLER_SCH.
Definition at line 91 of file api_handler.h.
|
overrideprotectedvirtual |
Reimplemented from API_HANDLER_LIBRARIES.
Definition at line 45 of file api_handler_fp_libraries.cpp.
References adapterForProject(), LIB_ID::GetUniStringLibId(), FOOTPRINT_LIBRARY_ADAPTER::LoadFootprint(), Pgm(), and Prj().
|
inlineprotectedinherited |
Registers an API command handler for the given message types.
When an API request matching the given type comes in, the handler will be called and its response will be packed into an envelope for sending back to the API client.
If the given message does not unpack into the request type, an envelope is returned with status AS_BAD_REQUEST, which probably indicates corruption in the message.
| RequestType | is a protobuf message type containing a command |
| ResponseType | is a protobuf message type containing a command response |
| HandlerType | is the implied type of the API_HANDLER subclass |
| aHandler | is the handler function for the given request and response types |
| aAllowedDuringTask | marks the command as safe to serve while an async task is running |
Definition at line 136 of file api_handler.h.
References HANDLER_CONTEXT< RequestMessageType >::ClientName, m_handlers, HANDLER_CONTEXT< RequestMessageType >::Request, and tryUnpack().
Referenced by API_HANDLER_BOARD::API_HANDLER_BOARD(), API_HANDLER_COMMON::API_HANDLER_COMMON(), API_HANDLER_EDITOR::API_HANDLER_EDITOR(), API_HANDLER_FOOTPRINT::API_HANDLER_FOOTPRINT(), API_HANDLER_LIBRARIES::API_HANDLER_LIBRARIES(), API_HANDLER_PCB::API_HANDLER_PCB(), API_HANDLER_SCH::API_HANDLER_SCH(), and API_HANDLER_SYMBOL::API_HANDLER_SYMBOL().
|
inlineinherited |
Definition at line 93 of file api_handler.h.
References m_notifyNetSettings.
Referenced by API_HANDLER_COMMON::handleSetNetClassAssignments(), and API_HANDLER_COMMON::handleSetNetClasses().
|
inlineinherited |
Set by KICAD_API_SERVER::RegisterHandler; null when the handler is not registered.
Definition at line 104 of file api_handler.h.
References m_apiServer.
Referenced by KICAD_API_SERVER::DeregisterHandler(), and KICAD_API_SERVER::RegisterHandler().
|
inlineinherited |
Definition at line 53 of file api_handler_libraries.h.
References m_kiway.
Referenced by CLI::API_SERVER_COMMAND::doPerform().
|
inlineinherited |
Set a callback to register the handler on the API server in headless mode.
Definition at line 56 of file api_handler_libraries.h.
References m_handlerRegisterCallback.
Referenced by CLI::API_SERVER_COMMAND::doPerform().
|
inlineprivateinherited |
Definition at line 192 of file api_handler.h.
Referenced by registerHandler().
|
protectedinherited |
Definition at line 185 of file api_handler.h.
Referenced by apiServer(), and setApiServer().
|
staticprotectedinherited |
Definition at line 187 of file api_handler.h.
Referenced by API_HANDLER_EDITOR::pushCurrentCommit().
|
privateinherited |
Invoked with a lazily-loaded KIFACE so its handlers can be registered on the server.
Definition at line 100 of file api_handler_libraries.h.
Referenced by handleLoadAllLibraries(), and SetLibraryHandlerRegistrar().
|
protectedinherited |
Maps type name (without the URL prefix) to a handler method.
Definition at line 181 of file api_handler.h.
Referenced by AllowsDuringTask(), CanHandle(), Handle(), and registerHandler().
|
privateinherited |
Used to lazily load kifaces for LoadAllLibraries in headless; null in GUI mode.
Definition at line 97 of file api_handler_libraries.h.
Referenced by handleLoadAllLibraries(), and SetKiway().
|
protectedinherited |
Definition at line 183 of file api_handler.h.
Referenced by clearNetSettingsNotification(), and requestNetSettingsNotification().
|
privateinherited |
Definition at line 94 of file api_handler_libraries.h.
Referenced by API_HANDLER_LIBRARIES(), handleGetItemsFromLibrary(), handleGetLibraryItems(), and libraryType().