mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 20:40:29 +08:00
refs #104 replaced all remaining hash-based comparisons with the multimethod compare()
This commit is contained in:
@@ -97,7 +97,7 @@ namespace BlackMisc
|
|||||||
bool CAircraft::operator ==(const CAircraft &other) const
|
bool CAircraft::operator ==(const CAircraft &other) const
|
||||||
{
|
{
|
||||||
if (this == &other) return true;
|
if (this == &other) return true;
|
||||||
return this->getValueHash() == other.getValueHash();
|
return compare(*this, other) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ namespace BlackMisc
|
|||||||
bool CAircraftIcao::operator ==(const CAircraftIcao &other) const
|
bool CAircraftIcao::operator ==(const CAircraftIcao &other) const
|
||||||
{
|
{
|
||||||
if (this == &other) return true;
|
if (this == &other) return true;
|
||||||
return this->getValueHash() == other.getValueHash();
|
return compare(*this, other) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -44,9 +44,19 @@ namespace BlackMisc
|
|||||||
/*
|
/*
|
||||||
* Compare
|
* Compare
|
||||||
*/
|
*/
|
||||||
int CAircraftSituation::compareImpl(const CValueObject &/*otherBase*/) const
|
int CAircraftSituation::compareImpl(const CValueObject &otherBase) const
|
||||||
{
|
{
|
||||||
qFatal("not implemented");
|
const auto &other = static_cast<const CAircraftSituation &>(otherBase);
|
||||||
|
|
||||||
|
int result;
|
||||||
|
if ((result = compare(this->m_position, other.m_position))) { return result; }
|
||||||
|
if ((result = compare(this->m_altitude, other.m_altitude))) { return result; }
|
||||||
|
if ((result = compare(this->m_heading, other.m_heading))) { return result; }
|
||||||
|
if ((result = compare(this->m_pitch, other.m_pitch))) { return result; }
|
||||||
|
if ((result = compare(this->m_bank, other.m_bank))) { return result; }
|
||||||
|
if ((result = compare(this->m_groundspeed, other.m_groundspeed))) { return result; }
|
||||||
|
if (this->m_timestamp < other.m_timestamp) { return -1; }
|
||||||
|
if (this->m_timestamp > other.m_timestamp) { return 1; }
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,7 +94,7 @@ namespace BlackMisc
|
|||||||
bool CAircraftSituation::operator ==(const CAircraftSituation &other) const
|
bool CAircraftSituation::operator ==(const CAircraftSituation &other) const
|
||||||
{
|
{
|
||||||
if (this == &other) return true;
|
if (this == &other) return true;
|
||||||
return this->getValueHash() == other.getValueHash();
|
return compare(*this, other) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ namespace BlackMisc
|
|||||||
bool CServer::operator ==(const CServer &other) const
|
bool CServer::operator ==(const CServer &other) const
|
||||||
{
|
{
|
||||||
if (this == &other) return true;
|
if (this == &other) return true;
|
||||||
return this->getValueHash() == other.getValueHash();
|
return compare(*this, other) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -54,6 +54,12 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
const auto &other = static_cast<const CTextMessage &>(otherBase);
|
const auto &other = static_cast<const CTextMessage &>(otherBase);
|
||||||
|
|
||||||
|
int result;
|
||||||
|
if ((result = compare(this->m_senderCallsign, other.m_senderCallsign))) { return result; }
|
||||||
|
if ((result = compare(this->m_recipientCallsign, other.m_recipientCallsign))) { return result; }
|
||||||
|
if ((result = compare(this->m_frequency, other.m_frequency))) { return result; }
|
||||||
|
if (this->m_received < other.m_received) { return -1; }
|
||||||
|
if (this->m_received > other.m_received) { return 1; }
|
||||||
return this->m_message.compare(other.m_message);
|
return this->m_message.compare(other.m_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,7 +235,7 @@ namespace BlackMisc
|
|||||||
bool CTextMessage::operator ==(const CTextMessage &other) const
|
bool CTextMessage::operator ==(const CTextMessage &other) const
|
||||||
{
|
{
|
||||||
if (this == &other) return true;
|
if (this == &other) return true;
|
||||||
return this->getValueHash() == other.getValueHash();
|
return compare(*this, other);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -55,9 +55,13 @@ namespace BlackMisc
|
|||||||
/*
|
/*
|
||||||
* Compare
|
* Compare
|
||||||
*/
|
*/
|
||||||
int CSettingsNetwork::compareImpl(const CValueObject &/*otherBase*/) const
|
int CSettingsNetwork::compareImpl(const CValueObject &otherBase) const
|
||||||
{
|
{
|
||||||
qFatal("not implemented");
|
const auto &other = static_cast<const CSettingsNetwork &>(otherBase);
|
||||||
|
|
||||||
|
int result;
|
||||||
|
if ((result = compare(this->m_trafficNetworkServerCurrent, other.m_trafficNetworkServerCurrent))) { return result; }
|
||||||
|
if ((result = compare(this->m_trafficNetworkServers, other.m_trafficNetworkServers))) { return result; }
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,7 +89,7 @@ namespace BlackMisc
|
|||||||
bool CSettingsNetwork::operator ==(const CSettingsNetwork &other) const
|
bool CSettingsNetwork::operator ==(const CSettingsNetwork &other) const
|
||||||
{
|
{
|
||||||
if (this == &other) return true;
|
if (this == &other) return true;
|
||||||
return this->getValueHash() == other.getValueHash();
|
return compare(*this, other) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user