2023-12-15 15:48:40 +00:00
|
|
|
// Copyright (C) 2023 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
|
|
|
|
|
|
|
#ifndef LASTSTRIKEINFO_H
|
|
|
|
#define LASTSTRIKEINFO_H
|
|
|
|
|
2024-01-15 13:47:32 +00:00
|
|
|
#include <chrono>
|
|
|
|
|
2023-12-15 15:48:40 +00:00
|
|
|
|
|
|
|
struct LastStrikeInfo
|
|
|
|
{
|
|
|
|
double distance {-1};
|
2024-01-15 13:47:32 +00:00
|
|
|
std::chrono::duration<int> timestamp {0};
|
2023-12-15 15:48:40 +00:00
|
|
|
double direction {0};
|
|
|
|
|
|
|
|
LastStrikeInfo() { }
|
2024-01-15 13:47:32 +00:00
|
|
|
inline LastStrikeInfo(double distance, std::chrono::duration<int> timestamp, double direction);
|
2023-12-15 15:48:40 +00:00
|
|
|
inline LastStrikeInfo(const LastStrikeInfo &other);
|
|
|
|
|
|
|
|
bool isValid() const { return !(distance < 0.0); }
|
|
|
|
inline bool operator<(const LastStrikeInfo &other) const;
|
|
|
|
inline void operator=(const LastStrikeInfo &other);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2024-01-15 13:47:32 +00:00
|
|
|
LastStrikeInfo::LastStrikeInfo(double distance,
|
|
|
|
std::chrono::duration<int> timestamp,
|
|
|
|
double direction)
|
2023-12-15 15:48:40 +00:00
|
|
|
: distance(distance)
|
|
|
|
, timestamp(timestamp)
|
|
|
|
, direction(direction)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
LastStrikeInfo::LastStrikeInfo(const LastStrikeInfo &other)
|
|
|
|
: LastStrikeInfo(other.distance, other.timestamp, other.direction)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
bool LastStrikeInfo::operator<(const LastStrikeInfo &other) const
|
|
|
|
{
|
|
|
|
if (!other.isValid())
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (!isValid())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (distance < other.distance)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (distance > other.distance)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return timestamp > other.timestamp;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LastStrikeInfo::operator=(const LastStrikeInfo &other)
|
|
|
|
{
|
|
|
|
distance = other.distance;
|
|
|
|
timestamp = other.timestamp;
|
|
|
|
direction = other.direction;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // LASTSTRIKEINFO_H
|