rename the sequence receiver

This commit is contained in:
Sven Czarnian
2021-11-13 23:01:12 +01:00
parent 8b1292c95a
commit a3ef28ae39
4 changed files with 59 additions and 39 deletions

View File

@@ -1,6 +1,6 @@
/*
* @brief Defines the aircraft scheduling notifier module to receive plans from the backend
* @file aman/com/AircraftScheduler.h
* @file aman/com/BackendReceiver.h
* @author Sven Czarnian <devel@svcz.de>
* @copyright Copyright 2021 Sven Czarnian
* @license This project is published under the GNU General Public License v3 (GPLv3)
@@ -9,12 +9,13 @@
#pragma once
#include <thread>
#include <memory>
#include <zmq.hpp>
#include <aman/types/Communication.h>
#pragma warning(push, 0)
#include "protobuf/AircraftSchedule.pb.h"
#include "protobuf/Communication.pb.h"
#pragma warning(pop)
namespace aman {
@@ -22,13 +23,15 @@ namespace aman {
* @brief Defines the aircraft scheduling notification class to receive scheduling sequences
* @ingroup com
*/
class AircraftScheduler {
class BackendReceiver {
private:
std::unique_ptr<zmq::socket_t> m_socket;
std::thread m_receiverThread;
std::atomic_bool m_stopReceiver;
std::unique_ptr<zmq::socket_t> m_socket;
std::thread m_receiverThread;
std::atomic_bool m_stopReceiver;
std::list<std::shared_ptr<aman::AircraftSequence>> m_sequences;
std::mutex m_sequencesLock;
AircraftScheduler() noexcept;
BackendReceiver() noexcept;
template <typename T>
bool setSocketKey(const std::string& key, T entry) {
@@ -40,13 +43,14 @@ namespace aman {
return false;
}
}
void receiveSequence();
void run();
public:
AircraftScheduler(const AircraftScheduler&) = delete;
AircraftScheduler(AircraftScheduler&&) = delete;
AircraftScheduler& operator=(const AircraftScheduler&) = delete;
AircraftScheduler& operator=(AircraftScheduler&&) = delete;
BackendReceiver(const BackendReceiver&) = delete;
BackendReceiver(BackendReceiver&&) = delete;
BackendReceiver& operator=(const BackendReceiver&) = delete;
BackendReceiver& operator=(BackendReceiver&&) = delete;
/**
* @brief Initializes the aircraft scheduler
@@ -64,14 +68,14 @@ namespace aman {
*/
bool initialized() const noexcept;
/**
* @brief Receives a new scheduling message
* @return The new scheduling message or a nullptr
* @brief Returns the current sequence of the receiver queue
* @return The sequence queue
*/
std::unique_ptr<aman::AircraftSchedule> receive();
std::shared_ptr<aman::AircraftSequence> receive();
/**
* @brief Returns the scheduling instance
* @return The system-wide instance
*/
static AircraftScheduler& instance() noexcept;
static BackendReceiver& instance() noexcept;
};
}