-
Notifications
You must be signed in to change notification settings - Fork 0
/
ImagingServer.hpp
60 lines (48 loc) · 1.61 KB
/
ImagingServer.hpp
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef __IMAGINGSERVER_HPP_
#define __IMAGINGSERVER_HPP_
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <unistd.h>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <thread>
#include <mutex>
#include <map>
#include "loguru.hpp"
#include "settings.hpp"
#include "AbstractBroadcastNode.hpp"
#include "common.hpp"
#include "ImageChunkPacket.hpp"
#include "ImageBuilder.hpp"
#include "database_utils/DbUtils.hpp"
#define INPUT_FILE(x) PATH_IMG #x TYPE_IMG // TODO rm
class ImagingServer : public AbstractBroadcastNode<ImageChunkPacket> {
private:
// self information and settings
const uint32_t _image_reception_timeout=IMAGE_RECEPTION_TIMEOUT;
const uint32_t _image_reception_check=IMAGE_TIMEOUT_CHECK_PERIOD;
mutable std::mutex _mutex_image_map;
std::map<Position, Image> _image_map;
mutable std::mutex _mutex_building_image_map;
std::map<Position, ImageBuilder> _building_image_map;
// threads
std::thread _thread_check_timeout_imgs;
void _tr_check_timeout_imgs();
ImageChunkPacket _produce_packet() override;
void _process_packet(const ImageChunkPacket&) override;
void _send_image();
bool _to_be_ignored(const ImageChunkPacket&) const override;
public:
ImagingServer(unsigned short port, uint8_t nodeID);
ImagingServer(const ImagingServer&) = delete;
ImagingServer(ImagingServer&&) = delete;
ImagingServer& operator=(const ImagingServer&) = delete;
ImagingServer& operator=(const ImagingServer&&) = delete;
~ImagingServer();
void start() override;
void join() override;
};
#endif