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. bool m_initialized;
  21. zmq::socket_t m_socket;
  22. AircraftReporter() noexcept;
  23. template <typename T>
  24. bool setSocketKey(const std::string& key, T entry) {
  25. try {
  26. this->m_socket.set(entry, key);
  27. return true;
  28. }
  29. catch (std::exception&) {
  30. return false;
  31. }
  32. }
  33. public:
  34. AircraftReporter(const AircraftReporter&) = delete;
  35. AircraftReporter(AircraftReporter&&) = delete;
  36. AircraftReporter& operator=(const AircraftReporter&) = delete;
  37. AircraftReporter& operator=(AircraftReporter&&) = delete;
  38. bool initialize(const Communication& configuration);
  39. bool deinitialize();
  40. bool send(zmq::message_t& message);
  41. static AircraftReporter& instance();
  42. };
  43. }