1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- /*
- * @brief Defines the aircraft reporter module to communicate with the backend
- * @file aman/com/AircraftReporter.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)
- */
- #pragma once
- #include <zmq.hpp>
- #include <aman/types/Communication.h>
- #pragma warning(push, 0)
- #include "protobuf/AircraftReport.pb.h"
- #pragma warning(pop)
- namespace aman {
- /**
- * @brief Defines the aircraft reporter class which sends aircraft information to the backend
- * @ingroup com
- */
- class AircraftReporter {
- private:
- std::unique_ptr<zmq::socket_t> m_socket;
- AircraftReporter() noexcept;
- template <typename T>
- bool setSocketKey(const std::string& key, T entry) {
- try {
- this->m_socket->set(entry, key);
- return true;
- }
- catch (std::exception&) {
- return false;
- }
- }
- public:
- AircraftReporter(const AircraftReporter&) = delete;
- AircraftReporter(AircraftReporter&&) = delete;
- AircraftReporter& operator=(const AircraftReporter&) = delete;
- AircraftReporter& operator=(AircraftReporter&&) = delete;
- /**
- * @brief Initializes the aircraft reporter
- * @param[in] configuration The current AMAM communication configuration
- * @return True if the initialization is done, else false
- */
- bool initialize(const Communication& configuration);
- /**
- * @brief Terminates the reporter connection
- */
- bool deinitialize();
- /**
- * @brief Checks if the reporter is initialized
- * @return True if it is initialized, else false
- */
- bool initialized() const noexcept;
- /**
- * @brief Sends a new message to the backend
- * @param[in] report The new aircraft report
- * @return True if the report is sent, else false
- */
- bool send(aman::AircraftReport& report);
- /**
- * @brief Returns the reporter instance
- * @return The system-wide instance
- */
- static AircraftReporter& instance() noexcept;
- };
- }
|