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