KiCad PCB EDA Suite
|
#include <api_handler_sch.h>
Public Member Functions | |
API_HANDLER_SCH (SCH_EDIT_FRAME *aFrame) | |
API_RESULT | Handle (ApiRequest &aMsg) |
Attempt to handle the given API request, if a handler exists in this class for the message. | |
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 | |
std::unique_ptr< COMMIT > | createCommit () override |
Override this to create an appropriate COMMIT subclass for the frame in question. | |
kiapi::common::types::DocumentType | thisDocumentType () const override |
Override this to specify which document type this editor handles. | |
bool | validateDocumentInternal (const DocumentSpecifier &aDocument) const override |
HANDLER_RESULT< std::unique_ptr< EDA_ITEM > > | createItemForType (KICAD_T aType, EDA_ITEM *aContainer) |
HANDLER_RESULT< types::ItemRequestStatus > | handleCreateUpdateItemsInternal (bool aCreate, const std::string &aClientName, const types::ItemHeader &aHeader, const google::protobuf::RepeatedPtrField< google::protobuf::Any > &aItems, std::function< void(commands::ItemStatus, google::protobuf::Any)> aItemHandler) override |
void | deleteItemsInternal (std::map< KIID, ItemDeletionStatus > &aItemsToDelete, const std::string &aClientName) override |
std::optional< EDA_ITEM * > | getItemFromDocument (const DocumentSpecifier &aDocument, const KIID &aId) override |
HANDLER_RESULT< std::optional< KIID > > | validateItemHeaderDocument (const kiapi::common::types::ItemHeader &aHeader) |
If the header is valid, returns the item container. | |
HANDLER_RESULT< bool > | validateDocument (const DocumentSpecifier &aDocument) |
virtual std::optional< ApiResponseStatus > | checkForBusy () |
Checks if the editor can accept commands. | |
HANDLER_RESULT< commands::BeginCommitResponse > | handleBeginCommit (const HANDLER_CONTEXT< commands::BeginCommit > &aCtx) |
HANDLER_RESULT< commands::EndCommitResponse > | handleEndCommit (const HANDLER_CONTEXT< commands::EndCommit > &aCtx) |
COMMIT * | getCurrentCommit (const std::string &aClientName) |
virtual void | pushCurrentCommit (const std::string &aClientName, const wxString &aMessage) |
HANDLER_RESULT< commands::CreateItemsResponse > | handleCreateItems (const HANDLER_CONTEXT< commands::CreateItems > &aCtx) |
HANDLER_RESULT< commands::UpdateItemsResponse > | handleUpdateItems (const HANDLER_CONTEXT< commands::UpdateItems > &aCtx) |
HANDLER_RESULT< commands::DeleteItemsResponse > | handleDeleteItems (const HANDLER_CONTEXT< commands::DeleteItems > &aCtx) |
HANDLER_RESULT< commands::HitTestResponse > | handleHitTest (const HANDLER_CONTEXT< commands::HitTest > &aCtx) |
template<class RequestType , class ResponseType , class HandlerType > | |
void | registerHandler (HANDLER_RESULT< ResponseType >(HandlerType::*aHandler)(const HANDLER_CONTEXT< RequestType > &)) |
Registers an API command handler for the given message types. | |
Protected Attributes | |
std::map< std::string, std::pair< KIID, std::unique_ptr< COMMIT > > > | m_commits |
std::set< std::string > | m_activeClients |
std::map< std::string, REQUEST_HANDLER > | m_handlers |
Maps type name (without the URL prefix) to a handler method. | |
Static Protected Attributes | |
static const wxString | m_defaultCommitMessage = _( "Modification from API" ) |
Private Member Functions | |
HANDLER_RESULT< commands::GetOpenDocumentsResponse > | handleGetOpenDocuments (const HANDLER_CONTEXT< commands::GetOpenDocuments > &aCtx) |
template<typename MessageType > | |
bool | tryUnpack (ApiRequest &aRequest, ApiResponse &aReply, MessageType &aDest) |
Private Attributes | |
SCH_EDIT_FRAME * | m_frame |
Definition at line 35 of file api_handler_sch.h.
|
protectedinherited |
A handler for outer messages (envelopes) that will unpack to inner messages and call a specific handler function.
Definition at line 76 of file api_handler.h.
API_HANDLER_SCH::API_HANDLER_SCH | ( | SCH_EDIT_FRAME * | aFrame | ) |
Definition at line 37 of file api_handler_sch.cpp.
References handleGetOpenDocuments().
|
protectedvirtualinherited |
Checks if the editor can accept commands.
Definition at line 205 of file api_handler_editor.cpp.
References EDA_BASE_FRAME::CanAcceptApiCommands(), and API_HANDLER_EDITOR::m_frame.
Referenced by API_HANDLER_EDITOR::handleBeginCommit(), API_HANDLER_EDITOR::handleCreateItems(), API_HANDLER_EDITOR::handleDeleteItems(), API_HANDLER_EDITOR::handleEndCommit(), API_HANDLER_PCB::handleGetBoundingBox(), API_HANDLER_PCB::handleGetGraphicsDefaults(), API_HANDLER_PCB::handleGetItems(), API_HANDLER_PCB::handleGetNets(), API_HANDLER_PCB::handleGetStackup(), API_HANDLER_EDITOR::handleHitTest(), API_HANDLER_PCB::handleInteractiveMoveItems(), API_HANDLER_PCB::handleParseAndCreateItemsFromString(), API_HANDLER_PCB::handleRefillZones(), API_HANDLER_PCB::handleRunAction(), API_HANDLER_PCB::handleSetActiveLayer(), API_HANDLER_PCB::handleSetVisibleLayers(), and API_HANDLER_EDITOR::handleUpdateItems().
|
overrideprotectedvirtual |
Override this to create an appropriate COMMIT subclass for the frame in question.
Implements API_HANDLER_EDITOR.
Definition at line 46 of file api_handler_sch.cpp.
References m_frame.
|
protected |
Definition at line 88 of file api_handler_sch.cpp.
References CreateItemForType(), EDA_ITEM::GetFriendlyName(), SCH_PIN_T, and SCH_SYMBOL_T.
Referenced by handleCreateUpdateItemsInternal().
|
overrideprotectedvirtual |
Implements API_HANDLER_EDITOR.
Definition at line 285 of file api_handler_sch.cpp.
|
protectedinherited |
Definition at line 129 of file api_handler_editor.cpp.
References API_HANDLER_EDITOR::createCommit(), and API_HANDLER_EDITOR::m_commits.
Referenced by API_HANDLER_PCB::deleteItemsInternal(), handleCreateUpdateItemsInternal(), API_HANDLER_PCB::handleCreateUpdateItemsInternal(), and API_HANDLER_PCB::handleInteractiveMoveItems().
|
overrideprotectedvirtual |
Implements API_HANDLER_EDITOR.
Definition at line 292 of file api_handler_sch.cpp.
References API_HANDLER_EDITOR::validateDocument().
|
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 API_HANDLER::m_handlers.
|
protectedinherited |
Definition at line 43 of file api_handler_editor.cpp.
References API_HANDLER_EDITOR::checkForBusy(), HANDLER_CONTEXT< RequestMessageType >::ClientName, API_HANDLER_EDITOR::createCommit(), API_HANDLER_EDITOR::m_activeClients, and API_HANDLER_EDITOR::m_commits.
Referenced by API_HANDLER_EDITOR::API_HANDLER_EDITOR().
|
protectedinherited |
Definition at line 219 of file api_handler_editor.cpp.
References API_HANDLER_EDITOR::checkForBusy(), HANDLER_CONTEXT< RequestMessageType >::ClientName, API_HANDLER_EDITOR::handleCreateUpdateItemsInternal(), and HANDLER_CONTEXT< RequestMessageType >::Request.
Referenced by API_HANDLER_EDITOR::API_HANDLER_EDITOR().
|
overrideprotectedvirtual |
Implements API_HANDLER_EDITOR.
Definition at line 131 of file api_handler_sch.cpp.
References _, COMMIT::Add(), KIID::AsStdString(), EE_RTREE::begin(), createItemForType(), EE_RTREE::end(), API_HANDLER_EDITOR::getCurrentCommit(), SCH_EDIT_FRAME::GetScreen(), SCH_SCREEN::Items(), API_HANDLER_EDITOR::m_activeClients, m_frame, COMMIT::Modify(), API_HANDLER_EDITOR::pushCurrentCommit(), SERIALIZABLE::Serialize(), kiapi::common::TypeNameFromAny(), and API_HANDLER_EDITOR::validateItemHeaderDocument().
|
protectedinherited |
Definition at line 273 of file api_handler_editor.cpp.
References API_HANDLER_EDITOR::checkForBusy(), HANDLER_CONTEXT< RequestMessageType >::ClientName, API_HANDLER_EDITOR::deleteItemsInternal(), HANDLER_CONTEXT< RequestMessageType >::Request, and API_HANDLER_EDITOR::validateItemHeaderDocument().
Referenced by API_HANDLER_EDITOR::API_HANDLER_EDITOR().
|
protectedinherited |
Definition at line 72 of file api_handler_editor.cpp.
References API_HANDLER_EDITOR::checkForBusy(), HANDLER_CONTEXT< RequestMessageType >::ClientName, API_HANDLER_EDITOR::m_activeClients, API_HANDLER_EDITOR::m_commits, API_HANDLER_EDITOR::pushCurrentCommit(), and HANDLER_CONTEXT< RequestMessageType >::Request.
Referenced by API_HANDLER_EDITOR::API_HANDLER_EDITOR().
|
private |
Definition at line 64 of file api_handler_sch.cpp.
References SCH_EDIT_FRAME::GetCurrentFileName(), m_frame, and HANDLER_CONTEXT< RequestMessageType >::Request.
Referenced by API_HANDLER_SCH().
|
protectedinherited |
Definition at line 322 of file api_handler_editor.cpp.
References API_HANDLER_EDITOR::checkForBusy(), API_HANDLER_EDITOR::getItemFromDocument(), HANDLER_CONTEXT< RequestMessageType >::Request, kiapi::common::UnpackVector2(), and API_HANDLER_EDITOR::validateItemHeaderDocument().
Referenced by API_HANDLER_EDITOR::API_HANDLER_EDITOR().
|
protectedinherited |
Definition at line 246 of file api_handler_editor.cpp.
References API_HANDLER_EDITOR::checkForBusy(), HANDLER_CONTEXT< RequestMessageType >::ClientName, API_HANDLER_EDITOR::handleCreateUpdateItemsInternal(), and HANDLER_CONTEXT< RequestMessageType >::Request.
Referenced by API_HANDLER_EDITOR::API_HANDLER_EDITOR().
|
protectedvirtualinherited |
Reimplemented in API_HANDLER_PCB.
Definition at line 141 of file api_handler_editor.cpp.
References API_HANDLER_EDITOR::m_activeClients, API_HANDLER_EDITOR::m_commits, and API_HANDLER::m_defaultCommitMessage.
Referenced by handleCreateUpdateItemsInternal(), API_HANDLER_EDITOR::handleEndCommit(), and API_HANDLER_PCB::pushCurrentCommit().
|
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 |
Definition at line 93 of file api_handler.h.
References HANDLER_CONTEXT< RequestMessageType >::ClientName, and HANDLER_CONTEXT< RequestMessageType >::Request.
|
inlineoverrideprotectedvirtual |
Override this to specify which document type this editor handles.
Implements API_HANDLER_EDITOR.
Definition at line 43 of file api_handler_sch.h.
|
inlineprivateinherited |
Definition at line 136 of file api_handler.h.
|
protectedinherited |
Definition at line 155 of file api_handler_editor.cpp.
References API_HANDLER_EDITOR::validateDocumentInternal().
Referenced by getItemFromDocument(), API_HANDLER_PCB::getItemFromDocument(), API_HANDLER_PCB::handleExpandTextVariables(), API_HANDLER_PCB::handleGetActiveLayer(), API_HANDLER_PCB::handleGetGraphicsDefaults(), API_HANDLER_PCB::handleGetNets(), API_HANDLER_PCB::handleGetPadShapeAsPolygon(), API_HANDLER_PCB::handleGetStackup(), API_HANDLER_PCB::handleGetTitleBlockInfo(), API_HANDLER_PCB::handleGetVisibleLayers(), API_HANDLER_PCB::handleInteractiveMoveItems(), API_HANDLER_PCB::handleParseAndCreateItemsFromString(), API_HANDLER_PCB::handleRefillZones(), API_HANDLER_PCB::handleSaveDocumentToString(), API_HANDLER_PCB::handleSetActiveLayer(), API_HANDLER_PCB::handleSetVisibleLayers(), and API_HANDLER_EDITOR::validateItemHeaderDocument().
|
overrideprotectedvirtual |
Implements API_HANDLER_EDITOR.
Definition at line 52 of file api_handler_sch.cpp.
|
protectedinherited |
If the header is valid, returns the item container.
Definition at line 170 of file api_handler_editor.cpp.
References API_HANDLER_EDITOR::thisDocumentType(), API_HANDLER_EDITOR::validateDocument(), and API_HANDLER_EDITOR::validateDocumentInternal().
Referenced by handleCreateUpdateItemsInternal(), API_HANDLER_PCB::handleCreateUpdateItemsInternal(), API_HANDLER_EDITOR::handleDeleteItems(), API_HANDLER_PCB::handleGetBoundingBox(), API_HANDLER_PCB::handleGetItems(), and API_HANDLER_EDITOR::handleHitTest().
|
protectedinherited |
Definition at line 110 of file api_handler_editor.h.
Referenced by API_HANDLER_PCB::deleteItemsInternal(), API_HANDLER_EDITOR::handleBeginCommit(), handleCreateUpdateItemsInternal(), API_HANDLER_PCB::handleCreateUpdateItemsInternal(), API_HANDLER_EDITOR::handleEndCommit(), and API_HANDLER_EDITOR::pushCurrentCommit().
|
protectedinherited |
Definition at line 108 of file api_handler_editor.h.
Referenced by API_HANDLER_EDITOR::getCurrentCommit(), API_HANDLER_EDITOR::handleBeginCommit(), API_HANDLER_EDITOR::handleEndCommit(), and API_HANDLER_EDITOR::pushCurrentCommit().
|
staticprotectedinherited |
Definition at line 131 of file api_handler.h.
Referenced by API_HANDLER_EDITOR::pushCurrentCommit().
|
private |
Definition at line 70 of file api_handler_sch.h.
Referenced by createCommit(), handleCreateUpdateItemsInternal(), and handleGetOpenDocuments().
|
protectedinherited |
Maps type name (without the URL prefix) to a handler method.
Definition at line 129 of file api_handler.h.
Referenced by API_HANDLER::Handle().