mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 07:15:35 +08:00
refs #369, revised atc station and client list
* function to get only stations with valid callsign * use ICallsignObjectList in client list * removeByCallsign
This commit is contained in:
@@ -17,21 +17,12 @@ namespace BlackMisc
|
||||
{
|
||||
namespace Aviation
|
||||
{
|
||||
/*
|
||||
* Empty constructor
|
||||
*/
|
||||
CAtcStationList::CAtcStationList() { }
|
||||
|
||||
/*
|
||||
* Construct from base class object
|
||||
*/
|
||||
CAtcStationList::CAtcStationList(const CSequence<CAtcStation> &other) :
|
||||
CSequence<CAtcStation>(other)
|
||||
{ }
|
||||
|
||||
/*
|
||||
* Register metadata
|
||||
*/
|
||||
void CAtcStationList::registerMetadata()
|
||||
{
|
||||
qRegisterMetaType<BlackMisc::CSequence<CAtcStation>>();
|
||||
@@ -43,9 +34,6 @@ namespace BlackMisc
|
||||
registerMetaValueType<CAtcStationList>();
|
||||
}
|
||||
|
||||
/*
|
||||
* Find if on frequency of COM unit
|
||||
*/
|
||||
CAtcStationList CAtcStationList::findIfComUnitTunedIn25KHz(const CComSystem &comUnit) const
|
||||
{
|
||||
return this->findBy([&](const CAtcStation & atcStation)
|
||||
@@ -54,17 +42,16 @@ namespace BlackMisc
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* All controllers
|
||||
*/
|
||||
CAtcStationList CAtcStationList::stationsWithValidVoiceRoom() const
|
||||
{
|
||||
return this->findBy(&CAtcStation::hasValidVoiceRoom, true);
|
||||
}
|
||||
|
||||
CUserList CAtcStationList::getControllers() const
|
||||
{
|
||||
return this->findBy(Predicates::MemberValid(&CAtcStation::getController)).transform(Predicates::MemberTransform(&CAtcStation::getController));
|
||||
}
|
||||
|
||||
/*
|
||||
* Merge with booking, both (online/booking will be updated)
|
||||
*/
|
||||
int CAtcStationList::mergeWithBooking(CAtcStation &bookedAtcStation)
|
||||
{
|
||||
int c = 0;
|
||||
@@ -150,9 +137,6 @@ namespace BlackMisc
|
||||
return c;
|
||||
}
|
||||
|
||||
/*
|
||||
* Merge with VATSIM data file
|
||||
*/
|
||||
bool CAtcStationList::updateFromVatsimDataFileStation(CAtcStation &stationToBeUpdated) const
|
||||
{
|
||||
if (this->isEmpty()) return false;
|
||||
|
||||
@@ -42,6 +42,10 @@ namespace BlackMisc
|
||||
//! Find 0..n stations tune in frequency of COM unit (with 25kHt channel spacing
|
||||
CAtcStationList findIfComUnitTunedIn25KHz(const BlackMisc::Aviation::CComSystem &comUnit) const;
|
||||
|
||||
//! Find 0..n stations with valid voice room
|
||||
//! \sa CAtcStation::hasValid
|
||||
CAtcStationList stationsWithValidVoiceRoom() const;
|
||||
|
||||
//! All controllers (with valid data)
|
||||
BlackMisc::Network::CUserList getControllers() const;
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "blackmisc/avatcstationlist.h"
|
||||
#include "blackmisc/avaircraftlist.h"
|
||||
#include "blackmisc/avaircraftsituationlist.h"
|
||||
#include "blackmisc/nwclientlist.h"
|
||||
#include "blackmisc/simulation/simulatedaircraftlist.h"
|
||||
|
||||
namespace BlackMisc
|
||||
@@ -71,6 +72,12 @@ namespace BlackMisc
|
||||
return r;
|
||||
}
|
||||
|
||||
template <class OBJ, class CONTAINER>
|
||||
int ICallsignObjectList<OBJ, CONTAINER>::removeByCallsign(const CCallsign &callsign)
|
||||
{
|
||||
return this->getContainer().removeIf(&OBJ::getCallsign, callsign);
|
||||
}
|
||||
|
||||
template <class OBJ, class CONTAINER>
|
||||
QMap<QString, int> ICallsignObjectList<OBJ, CONTAINER>::getSuffixes() const
|
||||
{
|
||||
@@ -124,6 +131,7 @@ namespace BlackMisc
|
||||
template class ICallsignObjectList<BlackMisc::Aviation::CAircraft, BlackMisc::Aviation::CAircraftList>;
|
||||
template class ICallsignObjectList<BlackMisc::Aviation::CAircraftSituation, BlackMisc::Aviation::CAircraftSituationList>;
|
||||
template class ICallsignObjectList<BlackMisc::Simulation::CSimulatedAircraft, BlackMisc::Simulation::CSimulatedAircraftList>;
|
||||
template class ICallsignObjectList<BlackMisc::Network::CClient, BlackMisc::Network::CClientList>;
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -51,6 +51,9 @@ namespace BlackMisc
|
||||
//! All with given suffix, empty suffixes ignored
|
||||
CONTAINER findBySuffix(const QString &suffix) const;
|
||||
|
||||
//! Remove all objects with callsign
|
||||
int removeByCallsign(const CCallsign &callsign);
|
||||
|
||||
//! All suffixes with their respective count
|
||||
QMap<QString, int> getSuffixes() const;
|
||||
|
||||
|
||||
@@ -41,21 +41,5 @@ namespace BlackMisc
|
||||
registerMetaValueType<CClientList>();
|
||||
}
|
||||
|
||||
/*
|
||||
* Find by callsign
|
||||
*/
|
||||
CClientList CClientList::findByCallsign(const CCallsign &callsign) const
|
||||
{
|
||||
return findBy(&CClient::getCallsign, callsign);
|
||||
}
|
||||
|
||||
/*
|
||||
* Find by callsign
|
||||
*/
|
||||
CClient CClientList::findFirstByCallsign(const CCallsign &callsign, const CClient &ifNotFound) const
|
||||
{
|
||||
return this->findByCallsign(callsign).frontOrDefault(ifNotFound);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -15,7 +15,9 @@
|
||||
#include "nwclient.h"
|
||||
#include "sequence.h"
|
||||
#include "collection.h"
|
||||
#include "blackmisc/avcallsignobjectlist.h"
|
||||
#include "blackmisc/avcallsign.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
@@ -25,7 +27,9 @@ namespace BlackMisc
|
||||
namespace Network
|
||||
{
|
||||
//! Value object encapsulating a list of voice rooms.
|
||||
class CClientList : public CSequence<CClient>
|
||||
class CClientList :
|
||||
public CSequence<CClient>,
|
||||
public BlackMisc::Aviation::ICallsignObjectList<BlackMisc::Network::CClient, BlackMisc::Network::CClientList>
|
||||
{
|
||||
public:
|
||||
//! Default constructor.
|
||||
@@ -40,11 +44,12 @@ namespace BlackMisc
|
||||
//! Register metadata
|
||||
static void registerMetadata();
|
||||
|
||||
//! Find by callsign
|
||||
CClientList findByCallsign(const BlackMisc::Aviation::CCallsign &callsign) const;
|
||||
protected:
|
||||
//! Myself
|
||||
virtual const CClientList &getContainer() const { return *this; }
|
||||
|
||||
//! First by callsign
|
||||
CClient findFirstByCallsign(const BlackMisc::Aviation::CCallsign &callsign, const CClient &ifNotFound = CClient()) const;
|
||||
//! Myself
|
||||
virtual CClientList &getContainer() { return *this; }
|
||||
};
|
||||
|
||||
} //namespace
|
||||
|
||||
Reference in New Issue
Block a user