-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontroller.hpp
More file actions
43 lines (34 loc) · 1.15 KB
/
Copy pathcontroller.hpp
File metadata and controls
43 lines (34 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef CONTROLLER_H
#define CONTROLLER_H 1
#include <boost/asio/io_context.hpp>
#include <memory>
#include <semaphore>
#include <string>
#include <thread>
#include "client.hpp"
#include "graph.hpp"
#include "json.hpp"
class Controller {
public:
Controller();
~Controller();
bool start(const std::string host, const std::string port);
void loop();
boost::asio::io_context &get_io_context() { return m_io_context; }
std::shared_ptr<nDPIsrvd_client> &get_client() { return m_client; }
std::shared_ptr<nDPIsrvd_graph> &get_graphics() { return m_graphics; }
friend void client_thread(Controller *_this, const std::string host,
const std::string port);
friend void graph_thread(Controller *_this);
private:
static void client_thread(Controller *_this, const std::string host,
const std::string port);
static void graph_thread(Controller *_this);
std::binary_semaphore m_client_sem, m_graph_sem;
private:
std::thread m_client_thread, m_graph_thread;
boost::asio::io_context m_io_context;
std::shared_ptr<nDPIsrvd_client> m_client;
std::shared_ptr<nDPIsrvd_graph> m_graphics;
};
#endif