#ifndef GERMANAIRLINESVA_GACONNECTOR_PATHSEGMENT_H #define GERMANAIRLINESVA_GACONNECTOR_PATHSEGMENT_H #include #include #include /* * Length in bytes: 20 * * UINT16 | UINT16 | DOUBLE | DOUBLE | * ---------+-------------+----------+-----------+ * ALTITUDE | GROUNDSPEED | LATITUDE | LONGITUDE | */ class PathSegment { private: std::uint16_t altitude = 0; std::uint16_t groundSpeed = 0; double latitude = 0; double longitude = 0; std::vector file; public: PathSegment() = default; PathSegment(std::uint16_t altitude, std::uint16_t groundSpeed, double latitude, double longitude) { this->altitude = altitude; this->groundSpeed = groundSpeed; this->latitude = latitude; this->longitude = longitude; file = std::vector(20, 0); std::uint8_t *bufPtr = file.data(); memcpy(bufPtr, &this->altitude, sizeof(this->altitude)); bufPtr += sizeof(this->altitude); memcpy(bufPtr, &this->groundSpeed, sizeof(this->groundSpeed)); bufPtr += sizeof(this->groundSpeed); memcpy(bufPtr, &this->latitude, sizeof(this->latitude)); bufPtr += sizeof(this->latitude); memcpy(bufPtr, &this->longitude, sizeof(this->longitude)); } std::uint8_t *getBinaryData() { return file.data(); } std::size_t getBinaryLength() { return file.size(); } friend bool operator==(const PathSegment &lhs, const PathSegment &rhs) { return lhs.altitude == rhs.altitude && lhs.groundSpeed == rhs.groundSpeed && lhs.latitude == rhs.latitude && lhs.longitude == rhs.longitude; } friend bool operator!=(const PathSegment &lhs, const PathSegment &rhs) { return !(lhs == rhs); } }; #endif