Formatting, doxygen, typo aircrafts (to aircraft),

removed some debug output, {} in if statements
This commit is contained in:
Klaus Basan
2014-12-15 00:52:58 +01:00
parent ca19ee8053
commit 366769a6b8
43 changed files with 189 additions and 163 deletions

View File

@@ -90,7 +90,7 @@ namespace BlackCore
CUser user = station.getController();
users.push_back(user);
}
foreach(CAircraft aircraft, this->m_aircraftsInRange)
foreach(CAircraft aircraft, this->m_aircraftInRange)
{
CUser user = aircraft.getPilot();
users.push_back(user);
@@ -112,8 +112,8 @@ namespace BlackCore
users.push_back(ownAircraft.getPilot());
}
// do aircrafts first, this will handle most callsigns
foreach(CAircraft aircraft, this->m_aircraftsInRange)
// do aircraft first, this will handle most callsigns
foreach(CAircraft aircraft, this->m_aircraftInRange)
{
if (searchList.isEmpty()) break;
CCallsign callsign = aircraft.getCallsign();
@@ -210,7 +210,7 @@ namespace BlackCore
{
if (!this->m_network->isConnected()) return;
foreach(CAircraft aircraft, this->m_aircraftsInRange)
foreach(CAircraft aircraft, this->m_aircraftInRange)
{
this->m_network->sendFrequencyQuery(aircraft.getCallsign());
this->m_network->sendIcaoCodesQuery(aircraft.getCallsign());
@@ -244,7 +244,7 @@ namespace BlackCore
this->m_atcStationsBooked.applyIf(&CAtcStation::getCallsign, callsign, vm);
vm = CPropertyIndexVariantMap({CAircraft::IndexPilot, CUser::IndexRealName}, realname);
this->m_aircraftsInRange.applyIf(&CAircraft::getCallsign, callsign, vm);
this->m_aircraftInRange.applyIf(&CAircraft::getCallsign, callsign, vm);
// Client
vm = CPropertyIndexVariantMap({CClient::IndexUser, CUser::IndexRealName}, realname);
@@ -347,13 +347,14 @@ namespace BlackCore
m_atcStationsOnline.clear();
}
void CAirspaceMonitor::removeAllAircrafts()
void CAirspaceMonitor::removeAllAircraft()
{
m_aircraftWatchdog.removeAll();
for(CAircraft aircraft : m_aircraftsInRange)
for (CAircraft aircraft : m_aircraftInRange)
{
emit removedAircraft(aircraft.getCallsign());
m_aircraftsInRange.clear();
}
m_aircraftInRange.clear();
}
void CAirspaceMonitor::removeAllOtherClients()
@@ -521,20 +522,20 @@ namespace BlackCore
if (!icaoData.hasAircraftDesignator())
{
// empty so far, try to fetch from data file
qDebug() << "Empty ICAO info for " << callsign << icaoData;
CLogMessage(this).debug() << "Empty ICAO info for %1 %2" << callsign << icaoData;
CAircraftIcao icaoDataDataFile = this->m_vatsimDataFileReader->getIcaoInfo(callsign);
if (!icaoDataDataFile.hasAircraftDesignator()) return; // give up!
vm = CPropertyIndexVariantMap(CAircraft::IndexIcao, icaoData.toCVariant());
}
int changed = this->m_aircraftsInRange.applyIf(&CAircraft::getCallsign, callsign, vm, true);
if (changed > 0) {emit this->changedAircraftsInRange();}
int changed = this->m_aircraftInRange.applyIf(&CAircraft::getCallsign, callsign, vm, true);
if (changed > 0) { emit this->changedAircraftInRange(); }
}
void CAirspaceMonitor::ps_aircraftUpdateReceived(const CCallsign &callsign, const CAircraftSituation &situation, const CTransponder &transponder)
{
Q_ASSERT(BlackCore::isCurrentThreadCreatingThread(this));
CAircraftList list = this->m_aircraftsInRange.findByCallsign(callsign);
CAircraftList list = this->m_aircraftInRange.findByCallsign(callsign);
if (list.isEmpty())
{
// new aircraft
@@ -544,7 +545,7 @@ namespace BlackCore
aircraft.setTransponder(transponder);
aircraft.setCalculcatedDistanceToPosition(this->m_ownAircraft.getPosition()); // distance from myself
this->m_vatsimDataFileReader->updateWithVatsimDataFileData(aircraft);
this->m_aircraftsInRange.push_back(aircraft);
this->m_aircraftInRange.push_back(aircraft);
// and new client, there is a chance it has been created by
// custom packet first
@@ -579,22 +580,22 @@ namespace BlackCore
vm.addValue(CAircraft::IndexDistance, distance);
// here I expect always a changed value
this->m_aircraftsInRange.applyIf(&CAircraft::getCallsign, callsign, vm, false);
this->m_aircraftInRange.applyIf(&CAircraft::getCallsign, callsign, vm, false);
this->m_aircraftWatchdog.resetCallsign(callsign);
emit this->changedAircraftSituation(callsign, situation);
}
emit this->changedAircraftsInRange();
emit this->changedAircraftInRange();
}
void CAirspaceMonitor::ps_pilotDisconnected(const CCallsign &callsign)
{
Q_ASSERT(BlackCore::isCurrentThreadCreatingThread(this));
bool contains = this->m_aircraftsInRange.contains(&CAircraft::getCallsign, callsign);
bool contains = this->m_aircraftInRange.contains(&CAircraft::getCallsign, callsign);
this->m_aircraftWatchdog.removeCallsign(callsign);
if (contains)
{
this->m_aircraftsInRange.removeIf(&CAircraft::getCallsign, callsign);
this->m_aircraftInRange.removeIf(&CAircraft::getCallsign, callsign);
this->m_otherClients.removeIf(&CClient::getCallsign, callsign);
emit this->removedAircraft(callsign);
}
@@ -606,8 +607,8 @@ namespace BlackCore
// update
CPropertyIndexVariantMap vm({CAircraft::IndexCom1System, CComSystem::IndexActiveFrequency}, frequency.toCVariant());
int changed = this->m_aircraftsInRange.applyIf(&CAircraft::getCallsign, callsign, vm, true);
if (changed > 0) { emit this->changedAircraftsInRange(); }
int changed = this->m_aircraftInRange.applyIf(&CAircraft::getCallsign, callsign, vm, true);
if (changed > 0) { emit this->changedAircraftInRange(); }
}
} // namespace

View File

@@ -62,7 +62,7 @@ namespace BlackCore
BlackMisc::Aviation::CAtcStationList getAtcStationsBooked() const { return m_atcStationsBooked; }
//! Returns the current aircraft in range
BlackMisc::Aviation::CAircraftList getAircraftInRange() const { return m_aircraftsInRange; }
BlackMisc::Aviation::CAircraftList getAircraftInRange() const { return m_aircraftInRange; }
//! Returns the closest ATC station operating on the given frequency, if any
BlackMisc::Aviation::CAtcStation getAtcStationForComUnit(const BlackMisc::Aviation::CComSystem &comSystem);
@@ -86,8 +86,8 @@ namespace BlackCore
//! Connection status of an ATC station was changed
void changedAtcStationOnlineConnectionStatus(const BlackMisc::Aviation::CAtcStation &station, bool isConnected);
//! Aircrafts were changed
void changedAircraftsInRange();
//! Aircraft were changed
void changedAircraftInRange();
//! A new aircraft appeared
void addedAircraft(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftSituation &initialSituation);
@@ -98,8 +98,6 @@ namespace BlackCore
//! An aircraft disappeared
void removedAircraft(const BlackMisc::Aviation::CCallsign &callsign);
//! Sent a status message
void statusMessage(const BlackMisc::CStatusMessage &msg);
public slots:
//! Own aircraft updated
@@ -113,7 +111,7 @@ namespace BlackCore
void clear()
{
removeAllAtcStations();
removeAllAircrafts();
removeAllAircraft();
removeAllOtherClients();
m_metarCache.clear();
m_flightPlanCache.clear();
@@ -122,7 +120,7 @@ namespace BlackCore
private:
BlackMisc::Aviation::CAtcStationList m_atcStationsOnline;
BlackMisc::Aviation::CAtcStationList m_atcStationsBooked;
BlackMisc::Aviation::CAircraftList m_aircraftsInRange;
BlackMisc::Aviation::CAircraftList m_aircraftInRange;
BlackMisc::Network::CClientList m_otherClients;
QMap<BlackMisc::Aviation::CAirportIcao, BlackMisc::Aviation::CInformationMessage> m_metarCache;
QMap<BlackMisc::Aviation::CCallsign, BlackMisc::Aviation::CFlightPlan> m_flightPlanCache;
@@ -145,7 +143,7 @@ namespace BlackCore
void addVoiceCapabilitiesFromDataFile(BlackMisc::CPropertyIndexVariantMap &vm, const BlackMisc::Aviation::CCallsign &callsign);
void removeAllAtcStations();
void removeAllAircrafts();
void removeAllAircraft();
void removeAllOtherClients();
private slots:

View File

@@ -116,8 +116,6 @@ namespace BlackCore
//! Change settings
void changeSettings(uint typeValue);
private:
mutable QReadWriteLock m_lock; //!< thread safety
};
}

View File

@@ -81,10 +81,10 @@ namespace BlackCore
void changedAtcStationsBookedDigest();
//! Aircraft list has been changed
void changedAircraftsInRange();
void changedAircraftInRange();
//! Digest signal changedAircraftsInRange()
void changedAircraftsInRangeDigest();
//! Digest signal changedAircraftInRange()
void changedAircraftInRangeDigest();
//! Aircraft situation update
void changedAircraftSituation(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftSituation &situation);
@@ -128,7 +128,7 @@ namespace BlackCore
virtual const BlackMisc::Aviation::CAtcStationList getAtcStationsBooked() const = 0 ;
//! Aircraft list
virtual const BlackMisc::Aviation::CAircraftList getAircraftsInRange() const = 0;
virtual const BlackMisc::Aviation::CAircraftList getAircraftInRange() const = 0;
//! Get all users
virtual BlackMisc::Network::CUserList getUsers() const = 0;

View File

@@ -53,8 +53,8 @@ namespace BlackCore
return BlackMisc::Aviation::CAtcStationList();
}
//! \copydoc IContextNetwork::getAircraftsInRange()
virtual const BlackMisc::Aviation::CAircraftList getAircraftsInRange() const override
//! \copydoc IContextNetwork::getAircraftInRange()
virtual const BlackMisc::Aviation::CAircraftList getAircraftInRange() const override
{
logEmptyContextWarning(Q_FUNC_INFO);
return BlackMisc::Aviation::CAircraftList();

View File

@@ -74,7 +74,7 @@ namespace BlackCore
connect(this->m_airspace, &CAirspaceMonitor::changedAtcStationsOnline, this, &CContextNetwork::changedAtcStationsOnline);
connect(this->m_airspace, &CAirspaceMonitor::changedAtcStationsBooked, this, &CContextNetwork::changedAtcStationsBooked);
connect(this->m_airspace, &CAirspaceMonitor::changedAtcStationOnlineConnectionStatus, this, &CContextNetwork::changedAtcStationOnlineConnectionStatus);
connect(this->m_airspace, &CAirspaceMonitor::changedAircraftsInRange, this, &CContextNetwork::changedAircraftsInRange);
connect(this->m_airspace, &CAirspaceMonitor::changedAircraftInRange, this, &CContextNetwork::changedAircraftInRange);
connect(this->m_airspace, &CAirspaceMonitor::changedAircraftSituation, this, &CContextNetwork::changedAircraftSituation);
connect(this->getIContextOwnAircraft(), &IContextOwnAircraft::changedAircraft, this->m_airspace, &CAirspaceMonitor::setOwnAircraft);
connect(this->getIContextSimulator(), &IContextSimulator::ownAircraftModelChanged, this->m_airspace, &CAirspaceMonitor::setOwnAircraftModel);

View File

@@ -67,8 +67,8 @@ namespace BlackCore
return this->m_airspace->getAtcStationsBooked();
}
//! \copydoc IContextNetwork::getAircraftsInRange()
virtual const BlackMisc::Aviation::CAircraftList getAircraftsInRange() const override
//! \copydoc IContextNetwork::getAircraftInRange()
virtual const BlackMisc::Aviation::CAircraftList getAircraftInRange() const override
{
BlackMisc::CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO;
return this->m_airspace->getAircraftInRange();
@@ -163,7 +163,7 @@ namespace BlackCore
BlackMisc::CDigestSignal m_dsAtcStationsBookedChanged { this, &IContextNetwork::changedAtcStationsBooked, &IContextNetwork::changedAtcStationsBookedDigest, 750, 2 };
BlackMisc::CDigestSignal m_dsAtcStationsOnlineChanged { this, &IContextNetwork::changedAtcStationsOnline, &IContextNetwork::changedAtcStationsOnlineDigest, 750, 4 };
BlackMisc::CDigestSignal m_dsAircraftsInRangeChanged { this, &IContextNetwork::changedAircraftsInRange, &IContextNetwork::changedAircraftsInRangeDigest, 750, 4 };
BlackMisc::CDigestSignal m_dsAircraftsInRangeChanged { this, &IContextNetwork::changedAircraftInRange, &IContextNetwork::changedAircraftInRangeDigest, 750, 4 };
// for reading XML and VATSIM data files
CVatsimBookingReader *m_vatsimBookingReader = nullptr;

View File

@@ -44,13 +44,13 @@ namespace BlackCore
"changedAtcStationsOnlineDigest", this, SIGNAL(changedAtcStationsOnlineDigest()));
Q_ASSERT(s);
s = connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(),
"changedAircraftsInRange", this, SIGNAL(changedAircraftsInRange()));
"changedAircraftInRange", this, SIGNAL(changedAircraftInRange()));
Q_ASSERT(s);
s = connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(),
"changedAtcStationOnlineConnectionStatus", this, SIGNAL(changedAtcStationOnlineConnectionStatus(BlackMisc::Aviation::CAtcStation, bool)));
Q_ASSERT(s);
s = connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(),
"changedAircraftsInRangeDigest", this, SIGNAL(changedAircraftsInRangeDigest()));
"changedAircraftInRangeDigest", this, SIGNAL(changedAircraftInRangeDigest()));
Q_ASSERT(s);
s = connection.connect(serviceName, IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(),
"connectionTerminated", this, SIGNAL(connectionTerminated()));
@@ -82,9 +82,9 @@ namespace BlackCore
return this->m_dBusInterface->callDBusRet<BlackMisc::Aviation::CAtcStationList>(QLatin1Literal("getAtcStationsBooked"));
}
const BlackMisc::Aviation::CAircraftList CContextNetworkProxy::getAircraftsInRange() const
const BlackMisc::Aviation::CAircraftList CContextNetworkProxy::getAircraftInRange() const
{
return this->m_dBusInterface->callDBusRet<BlackMisc::Aviation::CAircraftList>(QLatin1Literal("getAircraftsInRange"));
return this->m_dBusInterface->callDBusRet<BlackMisc::Aviation::CAircraftList>(QLatin1Literal("getAircraftInRange"));
}
BlackMisc::Network::CUserList CContextNetworkProxy::getUsers() const

View File

@@ -62,8 +62,8 @@ namespace BlackCore
//! \copydoc IContextNetwork::getAtcStationsBooked()
virtual const BlackMisc::Aviation::CAtcStationList getAtcStationsBooked() const override;
//! \copydoc IContextNetwork::getAircraftsInRange()
virtual const BlackMisc::Aviation::CAircraftList getAircraftsInRange() const override;
//! \copydoc IContextNetwork::getAircraftInRange()
virtual const BlackMisc::Aviation::CAircraftList getAircraftInRange() const override;
//! \copydoc IContextNetwork::connectToNetwork
virtual BlackMisc::CStatusMessage connectToNetwork(const BlackMisc::Network::CServer &server, uint mode) override;

View File

@@ -11,41 +11,29 @@
namespace BlackCore
{
//! \brief Interpolator, calculation inbetween positions
//! Interpolator, calculation inbetween positions
class IInterpolator
{
public:
//! \brief Default constructor
//! Default constructor
IInterpolator() {}
//! \brief Virtual destructor
//! Virtual destructor
virtual ~IInterpolator() {}
//! \brief Init object
//! Init object
virtual void initialize() = 0;
/*!
* \brief Add new aircraft situation
* \param situation
*/
//! Add new aircraft situation
virtual void addAircraftSituation(const BlackMisc::Aviation::CAircraftSituation &situation) = 0;
/*!
* \brief Do we have enough situations to start calculating?
* \return
*/
//! Do we have enough situations to start calculating?
virtual bool hasEnoughAircraftSituations() const = 0;
/*!
* \brief Get current aircraft situation
* \return
*/
//! Get current aircraft situation
virtual BlackMisc::Aviation::CAircraftSituation getCurrentSituation() = 0;
/*!
* \brief Get timestamp of the last received aircraft situation
* \return
*/
//! Get timestamp of the last received aircraft situation
virtual const QDateTime &getTimeOfLastReceivedSituation() const = 0;
};

View File

@@ -1,11 +1,13 @@
/* Copyright (C) 2013 VATSIM Community / authors
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* Copyright (C) 2013
* swift Project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
/*!
\file
*/
//! \file
#ifndef BLACKCORE_NETWORK_H
#define BLACKCORE_NETWORK_H

View File

@@ -49,7 +49,6 @@ namespace BlackCore
virtual bool isConnected() const = 0;
//! Can we connect?
//! \todo currently some code in XPlane implementation prevents to make the function const, can we fix this
virtual bool canConnect() const = 0;
//! Is time synchronization on?

View File

@@ -52,10 +52,10 @@ namespace BlackCore
this->setPendingNetworkReply(r);
}
CAircraftList CVatsimDataFileReader::getAircrafts() const
CAircraftList CVatsimDataFileReader::getAircraft() const
{
QReadLocker rl(&this->m_lock);
return this->m_aircrafts;
return this->m_aircraft;
}
CAtcStationList CVatsimDataFileReader::getAtcStations() const
@@ -78,7 +78,7 @@ namespace BlackCore
CUserList CVatsimDataFileReader::getPilotsForCallsigns(const CCallsignList &callsigns)
{
return this->getAircrafts().findByCallsigns(callsigns).transform(Predicates::MemberTransform(&CAircraft::getPilot));
return this->getAircraft().findByCallsigns(callsigns).transform(Predicates::MemberTransform(&CAircraft::getPilot));
}
CUserList CVatsimDataFileReader::getPilotsForCallsign(const CCallsign &callsign)
@@ -90,7 +90,7 @@ namespace BlackCore
CAircraftIcao CVatsimDataFileReader::getIcaoInfo(const CCallsign &callsign)
{
CAircraft aircraft = this->getAircrafts().findFirstByCallsign(callsign);
CAircraft aircraft = this->getAircraft().findFirstByCallsign(callsign);
return aircraft.getIcaoInfo();
}
@@ -109,7 +109,7 @@ namespace BlackCore
void CVatsimDataFileReader::updateWithVatsimDataFileData(CAircraft &aircraftToBeUdpated) const
{
this->getAircrafts().updateWithVatsimDataFileData(aircraftToBeUdpated);
this->getAircraft().updateWithVatsimDataFileData(aircraftToBeUdpated);
}
CUserList CVatsimDataFileReader::getControllersForCallsign(const CCallsign &callsign)
@@ -188,7 +188,7 @@ namespace BlackCore
CServerList voiceServers;
CServerList fsdServers;
CAtcStationList atcStations;
CAircraftList aircrafts;
CAircraftList aircraft;
QMap<CCallsign, CVoiceCapabilities> voiceCapabilities;
QDateTime updateTimestampFromFile;
@@ -259,7 +259,7 @@ namespace BlackCore
double groundspeed = clientPartsMap["groundspeed"].toDouble();
CAircraftSituation situation(position, altitude);
situation.setGroundspeed(CSpeed(groundspeed, CSpeedUnit::kts()));
CAircraft aircraft(user.getCallsign().getStringAsSet(), user, situation);
CAircraft currentAircraft(user.getCallsign().getStringAsSet(), user, situation);
QString icaoCode = clientPartsMap["planned_aircraft"];
if (!icaoCode.isEmpty())
@@ -270,7 +270,7 @@ namespace BlackCore
icaoCode = icaoCode.replace(reg, "").trimmed().toUpper();
if (CAircraftIcao::isValidDesignator(icaoCode))
{
aircraft.setIcaoInfo(CAircraftIcao(icaoCode));
currentAircraft.setIcaoInfo(CAircraftIcao(icaoCode));
}
else
{
@@ -278,7 +278,7 @@ namespace BlackCore
}
}
aircrafts.push_back(aircraft);
aircraft.push_back(currentAircraft);
}
else if (clientType.startsWith('a'))
{
@@ -340,7 +340,7 @@ namespace BlackCore
{
QWriteLocker wl(&this->m_lock);
this->setUpdateTimestamp(updateTimestampFromFile);
this->m_aircrafts = aircrafts;
this->m_aircraft = aircraft;
this->m_atcStations = atcStations;
this->m_voiceServers = voiceServers;
this->m_fsdServers = fsdServers;

View File

@@ -43,7 +43,7 @@ namespace BlackCore
//! Get aircrafts
//! \threadsafe
BlackMisc::Aviation::CAircraftList getAircrafts() const;
BlackMisc::Aviation::CAircraftList getAircraft() const;
//! Get aircrafts
//! \threadsafe
@@ -104,7 +104,7 @@ namespace BlackCore
BlackMisc::Network::CServerList m_voiceServers;
BlackMisc::Network::CServerList m_fsdServers;
BlackMisc::Aviation::CAtcStationList m_atcStations;
BlackMisc::Aviation::CAircraftList m_aircrafts;
BlackMisc::Aviation::CAircraftList m_aircraft;
QMap<BlackMisc::Aviation::CCallsign, BlackMisc::Network::CVoiceCapabilities> m_voiceCapabilities;
//! Split line and assign values to their corresponding attribute names