KiCad PCB EDA Suite
Loading...
Searching...
No Matches
api_client.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 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef KICAD_API_CLIENT_H
21#define KICAD_API_CLIENT_H
22
23#include <string>
24#include <nng/nng.h>
25#include <nng/protocol/reqrep0/req.h>
26#include <wx/string.h>
27
28#include <google/protobuf/message.h>
29
30#include <kicommon.h>
31#include <api/common/envelope.pb.h>
32
33
35{
36public:
37 explicit KICAD_API_CLIENT( int aTimeoutMs = 1000, bool aBlock = true );
39
40 bool Connect( const wxString& aSocketUrl );
41 void Disconnect();
42
43 bool IsConnected() const { return m_isOpen && m_isConnected; }
44
53 bool Send( const google::protobuf::Message& aRequest, kiapi::common::ApiResponse& aResponse,
54 const std::string& aClientName = "kicad" );
55
56 const wxString& GetLastError() const { return m_lastError; }
57
58private:
59 nng_socket m_socket;
62 wxString m_lastError;
63 bool m_block;
64};
65
66
67#endif // KICAD_API_CLIENT_H
KICAD_API_CLIENT(int aTimeoutMs=1000, bool aBlock=true)
const wxString & GetLastError() const
Definition api_client.h:56
wxString m_lastError
Definition api_client.h:62
bool Connect(const wxString &aSocketUrl)
nng_socket m_socket
Definition api_client.h:59
bool IsConnected() const
Definition api_client.h:43
#define KICOMMON_API
Definition kicommon.h:27