KiCad PCB EDA Suite
Loading...
Searching...
No Matches
kinng.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 (C) 2023 Jon Evans <[email protected]>
5 * Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors.
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#ifndef KICAD_KINNG_H
22#define KICAD_KINNG_H
23
24#include <atomic>
25#include <condition_variable>
26#include <functional>
27#include <mutex>
28#include <thread>
29
30
32{
33public:
34 KINNG_REQUEST_SERVER( const std::string& aSocketUrl );
35
37
38 bool Start();
39
40 void Stop();
41
42 bool Running() const;
43
44 void SetCallback( std::function<void(std::string*)> aFunc ) { m_callback = aFunc; }
45
46 void Reply( const std::string& aReply );
47
48 const std::string& SocketPath() const { return m_socketUrl; }
49
50private:
51 void listenThread();
52
53 std::thread m_thread;
54
55 std::atomic<bool> m_shutdown;
56
57 std::string m_socketUrl;
58
59 std::function<void(std::string*)> m_callback;
60
61 std::string m_pendingReply;
62
63 std::condition_variable m_replyReady;
64
65 std::mutex m_mutex;
66};
67
68#endif //KICAD_KINNG_H
const std::string & SocketPath() const
Definition: kinng.h:48
bool Running() const
Definition: kinng.cpp:48
std::string m_socketUrl
Definition: kinng.h:57
std::string m_pendingReply
Definition: kinng.h:61
void SetCallback(std::function< void(std::string *)> aFunc)
Definition: kinng.h:44
std::mutex m_mutex
Definition: kinng.h:65
void listenThread()
Definition: kinng.cpp:85
void Reply(const std::string &aReply)
Definition: kinng.cpp:77
std::function< void(std::string *)> m_callback
Definition: kinng.h:59
std::thread m_thread
Definition: kinng.h:53
std::atomic< bool > m_shutdown
Definition: kinng.h:55
std::condition_variable m_replyReady
Definition: kinng.h:63