FERS 0.1.0
The Flexible Extensible Radar Simulator
Loading...
Searching...
No Matches
udp_sender.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-only
2//
3// Copyright (c) 2026-present FERS Contributors (see AUTHORS.md).
4//
5// See the GNU GPLv2 LICENSE file in the FERS project root for more information.
6
7#pragma once
8
9#include <cstddef>
10#include <cstdint>
11#include <memory>
12#include <span>
13#include <string>
14
15namespace serial::vita49
16{
18 {
19 public:
20 virtual ~DatagramSender() = default;
21 virtual void open(const std::string& host, std::uint16_t port) = 0;
22 virtual void send(std::span<const std::uint8_t> bytes) = 0;
23 virtual void close() noexcept = 0;
24 };
25
27 {
28 public:
29 UdpSender() = default;
30 ~UdpSender() override;
31
32 UdpSender(const UdpSender&) = delete;
33 UdpSender& operator=(const UdpSender&) = delete;
34 UdpSender(UdpSender&& other) noexcept;
35 UdpSender& operator=(UdpSender&& other) noexcept;
36
37 void open(const std::string& host, std::uint16_t port) override;
38 void send(std::span<const std::uint8_t> bytes) override;
39 void close() noexcept override;
40
41 private:
42 int _socket = -1;
43 std::unique_ptr<std::byte[]> _address;
44 std::size_t _address_size = 0;
45 };
46}
virtual void close() noexcept=0
virtual void open(const std::string &host, std::uint16_t port)=0
virtual ~DatagramSender()=default
virtual void send(std::span< const std::uint8_t > bytes)=0
UdpSender(const UdpSender &)=delete
UdpSender & operator=(const UdpSender &)=delete
math::Vec3 max