AircraftReporter.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * @brief Defines the aircraft reporter module to communicate with the backend
  3. * @file aman/com/AircraftReporter.h
  4. * @author Sven Czarnian <devel@svcz.de>
  5. * @copyright Copyright 2021 Sven Czarnian
  6. * @license This project is published under the GNU General Public License v3 (GPLv3)
  7. */
  8. #pragma once
  9. #include <zmq.hpp>
  10. #include <aman/types/Communication.h>
  11. namespace aman {
  12. /**
  13. * @brief Defines the base class for all file formats
  14. * @ingroup format
  15. *
  16. * The base class provides error information, etc.
  17. */
  18. class AircraftReporter {
  19. private:
  20. std::unique_ptr<zmq::socket_t> m_socket;
  21. AircraftReporter() noexcept;
  22. template <typename T>
  23. bool setSocketKey(const std::string& key, T entry) {
  24. try {
  25. this->m_socket->set(entry, key);
  26. return true;
  27. }
  28. catch (std::exception&) {
  29. return false;
  30. }
  31. }
  32. public:
  33. AircraftReporter(const AircraftReporter&) = delete;
  34. AircraftReporter(AircraftReporter&&) = delete;
  35. AircraftReporter& operator=(const AircraftReporter&) = delete;
  36. AircraftReporter& operator=(AircraftReporter&&) = delete;
  37. bool initialize(const Communication& configuration);
  38. bool deinitialize();
  39. bool send(zmq::message_t& message);
  40. static AircraftReporter& instance();
  41. bool send(const aman::AircraftReport& report);
  42. };
  43. }