mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 06:35:52 +08:00
Ref T280, using the QHash<CCallsign, T> definitions to unify use cases
This commit is contained in:
@@ -28,9 +28,9 @@ namespace BlackMisc
|
||||
|
||||
void CClientProvider::setClients(const CClientList &clients)
|
||||
{
|
||||
const QMap<CCallsign, CClient> map = clients.asMap();
|
||||
const CClientPerCallsign perCallsign(clients.asCallsignHash());
|
||||
QWriteLocker l(&m_lockClient);
|
||||
m_clients = map;
|
||||
m_clients = perCallsign;
|
||||
}
|
||||
|
||||
void CClientProvider::clearClients()
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace BlackMisc
|
||||
//! @}
|
||||
|
||||
private:
|
||||
QMap<BlackMisc::Aviation::CCallsign, BlackMisc::Network::CClient> m_clients;
|
||||
CClientPerCallsign m_clients;
|
||||
mutable QReadWriteLock m_lockClient; //!< lock clients: m_clients
|
||||
};
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "blackmisc/aviation/aircraftpartslist.h"
|
||||
#include "blackmisc/aviation/aircraftsituationlist.h"
|
||||
#include "blackmisc/aviation/aircraftsituationchange.h"
|
||||
#include "blackmisc/aviation/percallsign.h"
|
||||
#include "blackmisc/aviation/callsignset.h"
|
||||
#include "blackmisc/provider.h"
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
@@ -50,12 +51,6 @@ namespace BlackMisc
|
||||
static constexpr int MaxPartsAgePerCallsignSecs = 60; //!< How many seconds to keep parts for interpolation
|
||||
static constexpr int DefaultOffsetTimeMs = 6000; //!< \fixme copied from CNetworkVatlib::c_positionTimeOffsetMsec
|
||||
|
||||
//! Situations per callsign
|
||||
using CSituationsPerCallsign = QHash<Aviation::CCallsign, Aviation::CAircraftSituationList>;
|
||||
|
||||
//! Parts per callsign
|
||||
using CPartsPerCallsign = QHash<Aviation::CCallsign, Aviation::CAircraftPartsList>;
|
||||
|
||||
//! All remote aircraft
|
||||
//! \threadsafe
|
||||
virtual CSimulatedAircraftList getAircraftInRange() const = 0;
|
||||
@@ -378,19 +373,18 @@ namespace BlackMisc
|
||||
Aviation::CAircraftSituation testAddAltitudeOffsetToSituation(const Aviation::CAircraftSituation &situation) const;
|
||||
|
||||
private:
|
||||
// hashs, because not sorted by key but keeping order
|
||||
CSituationsPerCallsign m_situationsByCallsign; //!< situations, for performance reasons per callsign, thread safe access required
|
||||
CPartsPerCallsign m_partsByCallsign; //!< parts, for performance reasons per callsign, thread safe access required
|
||||
Aviation::CCallsignSet m_aircraftWithParts; //!< aircraft supporting parts, thread safe access required
|
||||
Aviation::CAircraftSituationListPerCallsign m_situationsByCallsign; //!< situations, for performance reasons per callsign, thread safe access required
|
||||
Aviation::CAircraftPartsListPerCallsign m_partsByCallsign; //!< parts, for performance reasons per callsign, thread safe access required
|
||||
Aviation::CCallsignSet m_aircraftWithParts; //!< aircraft supporting parts, thread safe access required
|
||||
int m_situationsAdded = 0; //!< total number of situations added, thread safe access required
|
||||
int m_partsAdded = 0; //!< total number of parts added, thread safe access required
|
||||
|
||||
CSimulatedAircraftList m_aircraftInRange; //!< aircraft, thread safe access required
|
||||
QMap<Aviation::CCallsign, CStatusMessageList> m_reverseLookupMessages;
|
||||
QMap<Aviation::CCallsign, CStatusMessageList> m_aircraftPartsHistory; //!< JSON aircraft parts history
|
||||
QMap<Aviation::CCallsign, qint64> m_situationsLastModified;
|
||||
QMap<Aviation::CCallsign, qint64> m_partsLastModified;
|
||||
QMap<Aviation::CCallsign, PhysicalQuantities::CLength> m_testOffset;
|
||||
Aviation::CStatusMessageListPerCallsign m_reverseLookupMessages; //!< reverse lookup messages
|
||||
Aviation::CStatusMessageListPerCallsign m_aircraftPartsHistory; //!< status messages for parts history
|
||||
Aviation::CTimestampPerCallsign m_situationsLastModified; //!< when situations last modified
|
||||
Aviation::CTimestampPerCallsign m_partsLastModified; //!< when parts last modified
|
||||
QHash<Aviation::CCallsign, PhysicalQuantities::CLength> m_testOffset;
|
||||
|
||||
bool m_enableReverseLookupMsgs = false; //!< shall we log. information about the matching process
|
||||
bool m_enableAircraftPartsHistory = true; //!< shall we keep a history of aircraft parts
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace BlackMisc
|
||||
CElevationPlane ISimulationEnvironmentProvider::findClosestElevationWithinRange(const ICoordinateGeodetic &reference, const CLength &range) const
|
||||
{
|
||||
// for single point we use a slightly optimized version
|
||||
const bool singlePoint = (range <= CElevationPlane::singlePointRadius());
|
||||
const bool singlePoint = (&range == &CElevationPlane::singlePointRadius() || range <= CElevationPlane::singlePointRadius());
|
||||
const CCoordinateGeodetic coordinate = singlePoint ?
|
||||
this->getElevationCoordinates().findFirstWithinRangeOrDefault(reference, CElevationPlane::singlePointRadius()) :
|
||||
this->getElevationCoordinates().findClosestWithinRange(reference, range);
|
||||
|
||||
Reference in New Issue
Block a user