From b453d4d8e292ae5327b590db1d3159a605f5ec31 Mon Sep 17 00:00:00 2001 From: Sven Czarnian Date: Thu, 19 Aug 2021 08:21:08 +0200 Subject: [PATCH] add a function to check if a block is initialized --- include/aman/com/AircraftReporter.h | 7 +++++++ src/com/AircraftReporter.cpp | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/include/aman/com/AircraftReporter.h b/include/aman/com/AircraftReporter.h index 55d83b2..6ebea6b 100644 --- a/include/aman/com/AircraftReporter.h +++ b/include/aman/com/AircraftReporter.h @@ -12,6 +12,8 @@ #include +#include "protobuf/AircraftReport.pb.h" + namespace aman { /** * @brief Defines the aircraft reporter class which sends aircraft information to the backend @@ -50,6 +52,11 @@ namespace aman { * @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 diff --git a/src/com/AircraftReporter.cpp b/src/com/AircraftReporter.cpp index 2299cae..d18682f 100644 --- a/src/com/AircraftReporter.cpp +++ b/src/com/AircraftReporter.cpp @@ -57,6 +57,10 @@ bool AircraftReporter::deinitialize() { return true; } +bool AircraftReporter::initialized() const noexcept { + return nullptr != this->m_socket; +} + bool AircraftReporter::send(const aman::AircraftReport& report) { bool retval = false;