refs #306, refs #282 Thread safety of readers

In the same step:
* renaming private slots ps_xy
* doxygen
* removed outdated debug messages
This commit is contained in:
Klaus Basan
2014-07-27 02:55:16 +02:00
parent 2cf690d4fe
commit 3cf42b218a
8 changed files with 138 additions and 72 deletions

View File

@@ -4,12 +4,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "airspace_monitor.h" #include "airspace_monitor.h"
#include "blackcore/blackcorefreefunctions.h"
#include "blackmisc/project.h" #include "blackmisc/project.h"
#include "blackmisc/indexvariantmap.h" #include "blackmisc/indexvariantmap.h"
// KB_REMOVE with debug log message
#include <QThread>
namespace BlackCore namespace BlackCore
{ {
@@ -22,24 +20,24 @@ namespace BlackCore
CAirspaceMonitor::CAirspaceMonitor(QObject *parent, INetwork *network, CVatsimBookingReader *bookings, CVatsimDataFileReader *dataFile) CAirspaceMonitor::CAirspaceMonitor(QObject *parent, INetwork *network, CVatsimBookingReader *bookings, CVatsimDataFileReader *dataFile)
: QObject(parent), m_network(network), m_vatsimBookingReader(bookings), m_vatsimDataFileReader(dataFile) : QObject(parent), m_network(network), m_vatsimBookingReader(bookings), m_vatsimDataFileReader(dataFile)
{ {
this->connect(this->m_network, &INetwork::atcPositionUpdate, this, &CAirspaceMonitor::atcPositionUpdate); this->connect(this->m_network, &INetwork::atcPositionUpdate, this, &CAirspaceMonitor::ps_atcPositionUpdate);
this->connect(this->m_network, &INetwork::atisReplyReceived, this, &CAirspaceMonitor::atisReceived); this->connect(this->m_network, &INetwork::atisReplyReceived, this, &CAirspaceMonitor::ps_atisReceived);
this->connect(this->m_network, &INetwork::atisVoiceRoomReplyReceived, this, &CAirspaceMonitor::atisVoiceRoomReceived); this->connect(this->m_network, &INetwork::atisVoiceRoomReplyReceived, this, &CAirspaceMonitor::ps_atisVoiceRoomReceived);
this->connect(this->m_network, &INetwork::atisLogoffTimeReplyReceived, this, &CAirspaceMonitor::atisLogoffTimeReceived); this->connect(this->m_network, &INetwork::atisLogoffTimeReplyReceived, this, &CAirspaceMonitor::ps_atisLogoffTimeReceived);
this->connect(this->m_network, &INetwork::metarReplyReceived, this, &CAirspaceMonitor::metarReceived); this->connect(this->m_network, &INetwork::metarReplyReceived, this, &CAirspaceMonitor::ps_metarReceived);
this->connect(this->m_network, &INetwork::flightPlanReplyReceived, this, &CAirspaceMonitor::flightplanReceived); this->connect(this->m_network, &INetwork::flightPlanReplyReceived, this, &CAirspaceMonitor::ps_flightplanReceived);
this->connect(this->m_network, &INetwork::realNameReplyReceived, this, &CAirspaceMonitor::realNameReplyReceived); this->connect(this->m_network, &INetwork::realNameReplyReceived, this, &CAirspaceMonitor::ps_realNameReplyReceived);
this->connect(this->m_network, &INetwork::icaoCodesReplyReceived, this, &CAirspaceMonitor::icaoCodesReceived); this->connect(this->m_network, &INetwork::icaoCodesReplyReceived, this, &CAirspaceMonitor::ps_icaoCodesReceived);
this->connect(this->m_network, &INetwork::pilotDisconnected, this, &CAirspaceMonitor::pilotDisconnected); this->connect(this->m_network, &INetwork::pilotDisconnected, this, &CAirspaceMonitor::ps_pilotDisconnected);
this->connect(this->m_network, &INetwork::atcDisconnected, this, &CAirspaceMonitor::atcControllerDisconnected); this->connect(this->m_network, &INetwork::atcDisconnected, this, &CAirspaceMonitor::ps_atcControllerDisconnected);
this->connect(this->m_network, &INetwork::aircraftPositionUpdate, this, &CAirspaceMonitor::aircraftUpdateReceived); this->connect(this->m_network, &INetwork::aircraftPositionUpdate, this, &CAirspaceMonitor::ps_aircraftUpdateReceived);
this->connect(this->m_network, &INetwork::frequencyReplyReceived, this, &CAirspaceMonitor::frequencyReceived); this->connect(this->m_network, &INetwork::frequencyReplyReceived, this, &CAirspaceMonitor::ps_frequencyReceived);
this->connect(this->m_network, &INetwork::capabilitiesReplyReceived, this, &CAirspaceMonitor::capabilitiesReplyReceived); this->connect(this->m_network, &INetwork::capabilitiesReplyReceived, this, &CAirspaceMonitor::ps_capabilitiesReplyReceived);
this->connect(this->m_network, &INetwork::fsipirCustomPacketReceived, this, &CAirspaceMonitor::fsipirCustomPacketReceived); this->connect(this->m_network, &INetwork::fsipirCustomPacketReceived, this, &CAirspaceMonitor::ps_fsipirCustomPacketReceived);
this->connect(this->m_network, &INetwork::serverReplyReceived, this, &CAirspaceMonitor::serverReplyReceived); this->connect(this->m_network, &INetwork::serverReplyReceived, this, &CAirspaceMonitor::ps_serverReplyReceived);
// AutoConnection: this should also avoid race conditions by updating the bookings // AutoConnection: this should also avoid race conditions by updating the bookings
this->connect(this->m_vatsimBookingReader, &CVatsimBookingReader::dataRead, this, &CAirspaceMonitor::receivedBookings); this->connect(this->m_vatsimBookingReader, &CVatsimBookingReader::dataRead, this, &CAirspaceMonitor::ps_receivedBookings);
} }
CFlightPlan CAirspaceMonitor::loadFlightPlanFromNetwork(const CCallsign &callsign) CFlightPlan CAirspaceMonitor::loadFlightPlanFromNetwork(const CCallsign &callsign)
@@ -215,7 +213,7 @@ namespace BlackCore
} }
} }
void CAirspaceMonitor::realNameReplyReceived(const CCallsign &callsign, const QString &realname) void CAirspaceMonitor::ps_realNameReplyReceived(const CCallsign &callsign, const QString &realname)
{ {
if (realname.isEmpty()) return; if (realname.isEmpty()) return;
CIndexVariantMap vm(CAtcStation::IndexControllerRealName, realname); CIndexVariantMap vm(CAtcStation::IndexControllerRealName, realname);
@@ -229,7 +227,7 @@ namespace BlackCore
this->m_otherClients.applyIf(&CClient::getCallsign, callsign, vm); this->m_otherClients.applyIf(&CClient::getCallsign, callsign, vm);
} }
void CAirspaceMonitor::capabilitiesReplyReceived(const BlackMisc::Aviation::CCallsign &callsign, quint32 flags) void CAirspaceMonitor::ps_capabilitiesReplyReceived(const BlackMisc::Aviation::CCallsign &callsign, quint32 flags)
{ {
if (callsign.isEmpty()) return; if (callsign.isEmpty()) return;
CIndexVariantMap capabilities; CIndexVariantMap capabilities;
@@ -240,7 +238,7 @@ namespace BlackCore
this->m_otherClients.applyIf(&CClient::getCallsign, callsign, vm); this->m_otherClients.applyIf(&CClient::getCallsign, callsign, vm);
} }
void CAirspaceMonitor::fsipirCustomPacketReceived(const CCallsign &callsign, const QString &, const QString &, const QString &, const QString &model) void CAirspaceMonitor::ps_fsipirCustomPacketReceived(const CCallsign &callsign, const QString &, const QString &, const QString &, const QString &model)
{ {
if (callsign.isEmpty() || model.isEmpty()) return; if (callsign.isEmpty() || model.isEmpty()) return;
@@ -256,14 +254,14 @@ namespace BlackCore
this->sendFsipiCustomPacket(callsign); // response this->sendFsipiCustomPacket(callsign); // response
} }
void CAirspaceMonitor::serverReplyReceived(const CCallsign &callsign, const QString &server) void CAirspaceMonitor::ps_serverReplyReceived(const CCallsign &callsign, const QString &server)
{ {
if (callsign.isEmpty() || server.isEmpty()) return; if (callsign.isEmpty() || server.isEmpty()) return;
CIndexVariantMap vm(CClient::IndexServer, QVariant(server)); CIndexVariantMap vm(CClient::IndexServer, QVariant(server));
this->m_otherClients.applyIf(&CClient::getCallsign, callsign, vm); this->m_otherClients.applyIf(&CClient::getCallsign, callsign, vm);
} }
void CAirspaceMonitor::metarReceived(const QString &metarMessage) void CAirspaceMonitor::ps_metarReceived(const QString &metarMessage)
{ {
if (metarMessage.length() < 10) return; // invalid if (metarMessage.length() < 10) return; // invalid
const QString icaoCode = metarMessage.left(4).toUpper(); const QString icaoCode = metarMessage.left(4).toUpper();
@@ -280,7 +278,7 @@ namespace BlackCore
if (this->m_atcStationsBooked.contains(&CAtcStation::getCallsign, callsignTower)) emit this->changedAtcStationsBooked(); if (this->m_atcStationsBooked.contains(&CAtcStation::getCallsign, callsignTower)) emit this->changedAtcStationsBooked();
} }
void CAirspaceMonitor::flightplanReceived(const CCallsign &callsign, const CFlightPlan &flightPlan) void CAirspaceMonitor::ps_flightplanReceived(const CCallsign &callsign, const CFlightPlan &flightPlan)
{ {
CFlightPlan plan(flightPlan); CFlightPlan plan(flightPlan);
plan.setWhenLastSentOrLoaded(QDateTime::currentDateTimeUtc()); plan.setWhenLastSentOrLoaded(QDateTime::currentDateTimeUtc());
@@ -305,8 +303,9 @@ namespace BlackCore
this->m_network->sendFsipirCustomPacket(recipientCallsign, icao.getAirlineDesignator(), icao.getAircraftDesignator(), icao.getAircraftCombinedType(), modelString); this->m_network->sendFsipirCustomPacket(recipientCallsign, icao.getAirlineDesignator(), icao.getAircraftDesignator(), icao.getAircraftCombinedType(), modelString);
} }
void CAirspaceMonitor::receivedBookings(const CAtcStationList &bookedStations) void CAirspaceMonitor::ps_receivedBookings(const CAtcStationList &bookedStations)
{ {
Q_ASSERT(BlackCore::isCurrentThreadCreatingThread(this));
this->m_atcStationsBooked.clear(); this->m_atcStationsBooked.clear();
foreach(CAtcStation bookedStation, bookedStations) foreach(CAtcStation bookedStation, bookedStations)
{ {
@@ -319,8 +318,9 @@ namespace BlackCore
} }
} }
void CAirspaceMonitor::atcPositionUpdate(const CCallsign &callsign, const BlackMisc::PhysicalQuantities::CFrequency &frequency, const CCoordinateGeodetic &position, const BlackMisc::PhysicalQuantities::CLength &range) void CAirspaceMonitor::ps_atcPositionUpdate(const CCallsign &callsign, const BlackMisc::PhysicalQuantities::CFrequency &frequency, const CCoordinateGeodetic &position, const BlackMisc::PhysicalQuantities::CLength &range)
{ {
Q_ASSERT(BlackCore::isCurrentThreadCreatingThread(this));
CAtcStationList stationsWithCallsign = this->m_atcStationsOnline.findByCallsign(callsign); CAtcStationList stationsWithCallsign = this->m_atcStationsOnline.findByCallsign(callsign);
if (stationsWithCallsign.isEmpty()) if (stationsWithCallsign.isEmpty())
{ {
@@ -358,8 +358,9 @@ namespace BlackCore
} }
} }
void CAirspaceMonitor::atcControllerDisconnected(const CCallsign &callsign) void CAirspaceMonitor::ps_atcControllerDisconnected(const CCallsign &callsign)
{ {
Q_ASSERT(BlackCore::isCurrentThreadCreatingThread(this));
if (this->m_atcStationsOnline.contains(&CAtcStation::getCallsign, callsign)) if (this->m_atcStationsOnline.contains(&CAtcStation::getCallsign, callsign))
{ {
CAtcStation removeStation = this->m_atcStationsOnline.findByCallsign(callsign).front(); CAtcStation removeStation = this->m_atcStationsOnline.findByCallsign(callsign).front();
@@ -372,8 +373,9 @@ namespace BlackCore
this->m_atcStationsBooked.applyIf(&CAtcStation::getCallsign, callsign, CIndexVariantMap(CAtcStation::IndexIsOnline, QVariant(false))); this->m_atcStationsBooked.applyIf(&CAtcStation::getCallsign, callsign, CIndexVariantMap(CAtcStation::IndexIsOnline, QVariant(false)));
} }
void CAirspaceMonitor::atisReceived(const CCallsign &callsign, const CInformationMessage &atisMessage) void CAirspaceMonitor::ps_atisReceived(const CCallsign &callsign, const CInformationMessage &atisMessage)
{ {
Q_ASSERT(BlackCore::isCurrentThreadCreatingThread(this));
if (callsign.isEmpty()) return; if (callsign.isEmpty()) return;
CIndexVariantMap vm(CAtcStation::IndexAtis, atisMessage.toQVariant()); CIndexVariantMap vm(CAtcStation::IndexAtis, atisMessage.toQVariant());
this->m_atcStationsOnline.applyIf(&CAtcStation::getCallsign, callsign, vm); this->m_atcStationsOnline.applyIf(&CAtcStation::getCallsign, callsign, vm);
@@ -382,8 +384,9 @@ namespace BlackCore
if (this->m_atcStationsBooked.contains(&CAtcStation::getCallsign, callsign)) emit this->changedAtcStationsBooked(); if (this->m_atcStationsBooked.contains(&CAtcStation::getCallsign, callsign)) emit this->changedAtcStationsBooked();
} }
void CAirspaceMonitor::atisVoiceRoomReceived(const CCallsign &callsign, const QString &url) void CAirspaceMonitor::ps_atisVoiceRoomReceived(const CCallsign &callsign, const QString &url)
{ {
Q_ASSERT(BlackCore::isCurrentThreadCreatingThread(this));
QString trimmedUrl = url.trimmed(); QString trimmedUrl = url.trimmed();
CIndexVariantMap vm(CAtcStation::IndexVoiceRoomUrl, trimmedUrl); CIndexVariantMap vm(CAtcStation::IndexVoiceRoomUrl, trimmedUrl);
if (this->m_atcStationsBooked.contains(&CAtcStation::getCallsign, callsign)) if (this->m_atcStationsBooked.contains(&CAtcStation::getCallsign, callsign))
@@ -402,8 +405,9 @@ namespace BlackCore
this->m_otherClients.applyIf(&CClient::getCallsign, callsign, vm); this->m_otherClients.applyIf(&CClient::getCallsign, callsign, vm);
} }
void CAirspaceMonitor::atisLogoffTimeReceived(const CCallsign &callsign, const QString &zuluTime) void CAirspaceMonitor::ps_atisLogoffTimeReceived(const CCallsign &callsign, const QString &zuluTime)
{ {
Q_ASSERT(BlackCore::isCurrentThreadCreatingThread(this));
if (zuluTime.length() == 4) if (zuluTime.length() == 4)
{ {
// Logic to set logoff time // Logic to set logoff time
@@ -422,8 +426,10 @@ namespace BlackCore
} }
} }
void CAirspaceMonitor::icaoCodesReceived(const CCallsign &callsign, const CAircraftIcao &icaoData) void CAirspaceMonitor::ps_icaoCodesReceived(const CCallsign &callsign, const CAircraftIcao &icaoData)
{ {
Q_ASSERT(BlackCore::isCurrentThreadCreatingThread(this));
// update // update
CIndexVariantMap vm(CAircraft::IndexIcao, icaoData.toQVariant()); CIndexVariantMap vm(CAircraft::IndexIcao, icaoData.toQVariant());
if (!icaoData.hasAircraftDesignator()) if (!icaoData.hasAircraftDesignator())
@@ -438,8 +444,10 @@ namespace BlackCore
emit this->changedAircraftsInRange(); emit this->changedAircraftsInRange();
} }
void CAirspaceMonitor::aircraftUpdateReceived(const CCallsign &callsign, const CAircraftSituation &situation, const CTransponder &transponder) 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_aircraftsInRange.findByCallsign(callsign);
if (list.isEmpty()) if (list.isEmpty())
{ {
@@ -487,14 +495,18 @@ namespace BlackCore
emit changedAircraftSituation(callsign, situation); emit changedAircraftSituation(callsign, situation);
} }
void CAirspaceMonitor::pilotDisconnected(const CCallsign &callsign) void CAirspaceMonitor::ps_pilotDisconnected(const CCallsign &callsign)
{ {
Q_ASSERT(BlackCore::isCurrentThreadCreatingThread(this));
this->m_aircraftsInRange.removeIf(&CAircraft::getCallsign, callsign); this->m_aircraftsInRange.removeIf(&CAircraft::getCallsign, callsign);
this->m_otherClients.removeIf(&CClient::getCallsign, callsign); this->m_otherClients.removeIf(&CClient::getCallsign, callsign);
} }
void CAirspaceMonitor::frequencyReceived(const CCallsign &callsign, const CFrequency &frequency) void CAirspaceMonitor::ps_frequencyReceived(const CCallsign &callsign, const CFrequency &frequency)
{ {
Q_ASSERT(BlackCore::isCurrentThreadCreatingThread(this));
// update // update
CIndexVariantMap vm(CAircraft::IndexFrequencyCom1, frequency.toQVariant()); CIndexVariantMap vm(CAircraft::IndexFrequencyCom1, frequency.toQVariant());
this->m_aircraftsInRange.applyIf(BlackMisc::Predicates::MemberEqual(&CAircraft::getCallsign, callsign), vm); this->m_aircraftsInRange.applyIf(BlackMisc::Predicates::MemberEqual(&CAircraft::getCallsign, callsign), vm);

View File

@@ -127,22 +127,22 @@ namespace BlackCore
QStringList createFsipiCustomPacketData() const; QStringList createFsipiCustomPacketData() const;
private slots: private slots:
void realNameReplyReceived(const BlackMisc::Aviation::CCallsign &callsign, const QString &realname); void ps_realNameReplyReceived(const BlackMisc::Aviation::CCallsign &callsign, const QString &realname);
void capabilitiesReplyReceived(const BlackMisc::Aviation::CCallsign &callsign, quint32 flags); void ps_capabilitiesReplyReceived(const BlackMisc::Aviation::CCallsign &callsign, quint32 flags);
void fsipirCustomPacketReceived(const BlackMisc::Aviation::CCallsign &callsign, const QString &, const QString &, const QString &, const QString &model); void ps_fsipirCustomPacketReceived(const BlackMisc::Aviation::CCallsign &callsign, const QString &, const QString &, const QString &, const QString &model);
void serverReplyReceived(const BlackMisc::Aviation::CCallsign &callsign, const QString &server); void ps_serverReplyReceived(const BlackMisc::Aviation::CCallsign &callsign, const QString &server);
void metarReceived(const QString &metarMessage); void ps_metarReceived(const QString &metarMessage);
void flightplanReceived(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CFlightPlan &flightPlan); void ps_flightplanReceived(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CFlightPlan &flightPlan);
void receivedBookings(const BlackMisc::Aviation::CAtcStationList &bookedStations); void ps_receivedBookings(const BlackMisc::Aviation::CAtcStationList &bookedStations);
void atcPositionUpdate(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::PhysicalQuantities::CFrequency &frequency, const BlackMisc::Geo::CCoordinateGeodetic &position, const BlackMisc::PhysicalQuantities::CLength &range); void ps_atcPositionUpdate(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::PhysicalQuantities::CFrequency &frequency, const BlackMisc::Geo::CCoordinateGeodetic &position, const BlackMisc::PhysicalQuantities::CLength &range);
void atcControllerDisconnected(const BlackMisc::Aviation::CCallsign &callsign); void ps_atcControllerDisconnected(const BlackMisc::Aviation::CCallsign &callsign);
void atisReceived(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CInformationMessage &atisMessage); void ps_atisReceived(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CInformationMessage &atisMessage);
void atisVoiceRoomReceived(const BlackMisc::Aviation::CCallsign &callsign, const QString &url); void ps_atisVoiceRoomReceived(const BlackMisc::Aviation::CCallsign &callsign, const QString &url);
void atisLogoffTimeReceived(const BlackMisc::Aviation::CCallsign &callsign, const QString &zuluTime); void ps_atisLogoffTimeReceived(const BlackMisc::Aviation::CCallsign &callsign, const QString &zuluTime);
void icaoCodesReceived(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftIcao &icaoData); void ps_icaoCodesReceived(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftIcao &icaoData);
void aircraftUpdateReceived(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftSituation &situation, const BlackMisc::Aviation::CTransponder &transponder); void ps_aircraftUpdateReceived(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftSituation &situation, const BlackMisc::Aviation::CTransponder &transponder);
void pilotDisconnected(const BlackMisc::Aviation::CCallsign &callsign); void ps_pilotDisconnected(const BlackMisc::Aviation::CCallsign &callsign);
void frequencyReceived(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::PhysicalQuantities::CFrequency &frequency); void ps_frequencyReceived(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::PhysicalQuantities::CFrequency &frequency);
}; };
} // namespace } // namespace

View File

@@ -6,6 +6,7 @@
#include "blackcorefreefunctions.h" #include "blackcorefreefunctions.h"
#include "voice.h" #include "voice.h"
#include "simulator.h" #include "simulator.h"
#include <QThread>
namespace BlackCore namespace BlackCore
{ {
@@ -20,4 +21,11 @@ namespace BlackCore
qRegisterMetaType<IVoice::ConnectionStatus>("ConnectionStatus"); qRegisterMetaType<IVoice::ConnectionStatus>("ConnectionStatus");
} }
bool isCurrentThreadCreatingThread(QObject *toBeTested)
{
if (!toBeTested) return false;
if (!toBeTested->thread()) return false;
return (QThread::currentThreadId() == toBeTested->thread()->currentThreadId());
}
} // namespace } // namespace

View File

@@ -6,13 +6,17 @@
#ifndef BLACKCORE_FREEFUNCTIONS_H #ifndef BLACKCORE_FREEFUNCTIONS_H
#define BLACKCORE_FREEFUNCTIONS_H #define BLACKCORE_FREEFUNCTIONS_H
#include <QObject>
namespace BlackCore namespace BlackCore
{ {
/*! //! Register all relevant metadata in BlackCore
* Register all relevant metadata in BlackCore
*/
void registerMetadata(); void registerMetadata();
//! Is the current thread the one created the object
//! \remarks can be used as ASSERT check for threaded objects
bool isCurrentThreadCreatingThread(QObject *toBeTested);
} // BlackCore } // BlackCore
#endif // guard #endif // guard

View File

@@ -1,3 +1,12 @@
/* 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.
*/
#include "blackmisc/sequence.h" #include "blackmisc/sequence.h"
#include "blackmisc/avatcstation.h" #include "blackmisc/avatcstation.h"
#include "blackmisc/nwuser.h" #include "blackmisc/nwuser.h"

View File

@@ -1,7 +1,11 @@
/* Copyright (C) 2013 VATSIM Community / authors /* Copyright (C) 2013
* This Source Code Form is subject to the terms of the Mozilla Public * swift Project Community / Contributors
* 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/. */ * 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.
*/
#ifndef BLACKCORE_VATSIMBOOKINGREADER_H #ifndef BLACKCORE_VATSIMBOOKINGREADER_H
#define BLACKCORE_VATSIMBOOKINGREADER_H #define BLACKCORE_VATSIMBOOKINGREADER_H

View File

@@ -1,3 +1,12 @@
/* 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.
*/
#include "blackmisc/sequence.h" #include "blackmisc/sequence.h"
#include "blackmisc/avatcstation.h" #include "blackmisc/avatcstation.h"
#include "blackmisc/nwuser.h" #include "blackmisc/nwuser.h"
@@ -42,19 +51,19 @@ namespace BlackCore
this->setPendingNetworkReply(r); this->setPendingNetworkReply(r);
} }
const CAircraftList &CVatsimDataFileReader::getAircrafts() CAircraftList CVatsimDataFileReader::getAircrafts() const
{ {
QReadLocker rl(&this->m_lock); QReadLocker rl(&this->m_lock);
return this->m_aircrafts; return this->m_aircrafts;
} }
const CAtcStationList &CVatsimDataFileReader::getAtcStations() CAtcStationList CVatsimDataFileReader::getAtcStations() const
{ {
QReadLocker rl(&this->m_lock); QReadLocker rl(&this->m_lock);
return this->m_atcStations; return this->m_atcStations;
} }
const CServerList &CVatsimDataFileReader::getVoiceServers() CServerList CVatsimDataFileReader::getVoiceServers() const
{ {
QReadLocker rl(&this->m_lock); QReadLocker rl(&this->m_lock);
return this->m_voiceServers; return this->m_voiceServers;
@@ -78,6 +87,11 @@ namespace BlackCore
return aircraft.getIcaoInfo(); return aircraft.getIcaoInfo();
} }
void CVatsimDataFileReader::updateWithVatsimDataFileData(CAircraft &aircraftToBeUdpated) const
{
this->getAircrafts().updateWithVatsimDataFileData(aircraftToBeUdpated);
}
CUserList CVatsimDataFileReader::getControllersForCallsign(const CCallsign &callsign) CUserList CVatsimDataFileReader::getControllersForCallsign(const CCallsign &callsign)
{ {
CCallsignList callsigns; CCallsignList callsigns;

View File

@@ -1,13 +1,17 @@
/* Copyright (C) 2013 VATSIM Community / authors /* Copyright (C) 2013
* This Source Code Form is subject to the terms of the Mozilla Public * swift Project Community / Contributors
* 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/. */ * 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
#ifndef BLACKCORE_VATSIMDATAFILEREADER_H #ifndef BLACKCORE_VATSIMDATAFILEREADER_H
#define BLACKCORE_VATSIMDATAFILEREADER_H #define BLACKCORE_VATSIMDATAFILEREADER_H
//! \file
#include "blackmisc/threadedreader.h" #include "blackmisc/threadedreader.h"
#include "blackmisc/avatcstationlist.h" #include "blackmisc/avatcstationlist.h"
#include "blackmisc/avaircraftlist.h" #include "blackmisc/avaircraftlist.h"
@@ -37,37 +41,48 @@ namespace BlackCore
void read(); void read();
//! Get aircrafts //! Get aircrafts
const BlackMisc::Aviation::CAircraftList &getAircrafts(); //! \threadsafe
BlackMisc::Aviation::CAircraftList getAircrafts() const;
//! Get aircrafts //! Get aircrafts
const BlackMisc::Aviation::CAtcStationList &getAtcStations(); //! \threadsafe
BlackMisc::Aviation::CAtcStationList getAtcStations() const;
//! Get all voice servers //! Get all voice servers
const BlackMisc::Network::CServerList &getVoiceServers(); //! \threadsafe
BlackMisc::Network::CServerList getVoiceServers() const;
//! Users for callsign(s) //! Users for callsign(s)
//! \threadsafe
BlackMisc::Network::CUserList getUsersForCallsigns(const BlackMisc::Aviation::CCallsignList &callsigns); BlackMisc::Network::CUserList getUsersForCallsigns(const BlackMisc::Aviation::CCallsignList &callsigns);
//! User for callsign //! User for callsign
//! \threadsafe
BlackMisc::Network::CUserList getUsersForCallsign(const BlackMisc::Aviation::CCallsign &callsign); BlackMisc::Network::CUserList getUsersForCallsign(const BlackMisc::Aviation::CCallsign &callsign);
//! Controllers for callsigns //! Controllers for callsigns
//! \threadsafe
BlackMisc::Network::CUserList getControllersForCallsigns(const BlackMisc::Aviation::CCallsignList &callsigns); BlackMisc::Network::CUserList getControllersForCallsigns(const BlackMisc::Aviation::CCallsignList &callsigns);
//! Controllers for callsign //! Controllers for callsign
//! \threadsafe
BlackMisc::Network::CUserList getControllersForCallsign(const BlackMisc::Aviation::CCallsign &callsign); BlackMisc::Network::CUserList getControllersForCallsign(const BlackMisc::Aviation::CCallsign &callsign);
//! Users for callsigns //! Users for callsigns
//! \threadsafe
BlackMisc::Network::CUserList getPilotsForCallsigns(const BlackMisc::Aviation::CCallsignList &callsigns); BlackMisc::Network::CUserList getPilotsForCallsigns(const BlackMisc::Aviation::CCallsignList &callsigns);
//! Users for callsign //! Users for callsign
//! \threadsafe
BlackMisc::Network::CUserList getPilotsForCallsign(const BlackMisc::Aviation::CCallsign &callsign); BlackMisc::Network::CUserList getPilotsForCallsign(const BlackMisc::Aviation::CCallsign &callsign);
//! ICAO info for callsign //! ICAO info for callsign
//! \threadsafe
BlackMisc::Aviation::CAircraftIcao getIcaoInfo(const BlackMisc::Aviation::CCallsign &callsign); BlackMisc::Aviation::CAircraftIcao getIcaoInfo(const BlackMisc::Aviation::CCallsign &callsign);
//! Update with VATSIM aircraft data from data file //! Update aircraft with VATSIM aircraft data from data file
void updateWithVatsimDataFileData(BlackMisc::Aviation::CAircraft &aircraftToBeUdpated) const { this->m_aircrafts.updateWithVatsimDataFileData(aircraftToBeUdpated); } //! \threadsafe
void updateWithVatsimDataFileData(BlackMisc::Aviation::CAircraft &aircraftToBeUdpated) const;
private slots: private slots:
//! Data have been read //! Data have been read