mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:55:33 +08:00
Upfront of refs #369
* consolidated ICoordinateGeodetic (e.g. fixed nested properties) * shifted common functionality for objects/containers with callsign into interface * shifted common functionality for objects/containers with geo position into interface * shifted common functionality for objects/containers with timestamp into interface * updated corresponding value objects / specialized lists * adjusted all places where renamed functions are used
This commit is contained in:
@@ -47,64 +47,6 @@ namespace BlackMisc
|
||||
registerMetaValueType<CSimulatedAircraftList>();
|
||||
}
|
||||
|
||||
/*
|
||||
* Find by callsign
|
||||
*/
|
||||
CSimulatedAircraftList CSimulatedAircraftList::findByCallsign(const CCallsign &callsign) const
|
||||
{
|
||||
return this->findBy(&CSimulatedAircraft::getCallsign, callsign);
|
||||
}
|
||||
|
||||
/*
|
||||
* Find by callsigns
|
||||
*/
|
||||
CSimulatedAircraftList CSimulatedAircraftList::findByCallsigns(const CCallsignList &callsigns) const
|
||||
{
|
||||
return this->findBy(Predicates::MemberIsAnyOf(&CSimulatedAircraft::getCallsign, callsigns));
|
||||
}
|
||||
|
||||
/*
|
||||
* Find by callsign
|
||||
*/
|
||||
CSimulatedAircraft CSimulatedAircraftList::findFirstByCallsign(const CCallsign &callsign, const CSimulatedAircraft &ifNotFound) const
|
||||
{
|
||||
return this->findByCallsign(callsign).frontOrDefault(ifNotFound);
|
||||
}
|
||||
|
||||
/*
|
||||
* Contains callsign?
|
||||
*/
|
||||
bool CSimulatedAircraftList::containsCallsign(const CCallsign &callsign) const
|
||||
{
|
||||
return this->contains(&CSimulatedAircraft::getCallsign, callsign);
|
||||
}
|
||||
|
||||
int CSimulatedAircraftList::incrementalUpdateOrAdd(const CSimulatedAircraft &toChangeAircraft, const CPropertyIndexVariantMap &changedValues)
|
||||
{
|
||||
int c;
|
||||
const CCallsign cs = toChangeAircraft.getCallsign();
|
||||
if (this->containsCallsign(cs))
|
||||
{
|
||||
if (changedValues.isEmpty()) { return 0; }
|
||||
c = this->applyIf(&CSimulatedAircraft::getCallsign, cs, changedValues);
|
||||
}
|
||||
else
|
||||
{
|
||||
c = 1;
|
||||
if (changedValues.isEmpty())
|
||||
{
|
||||
this->push_back(toChangeAircraft);
|
||||
}
|
||||
else
|
||||
{
|
||||
CSimulatedAircraft addAircraft(toChangeAircraft);
|
||||
addAircraft.apply(changedValues);
|
||||
this->push_back(addAircraft);
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
/*
|
||||
* All pilots
|
||||
*/
|
||||
@@ -113,16 +55,5 @@ namespace BlackMisc
|
||||
return this->findBy(Predicates::MemberValid(&CSimulatedAircraft::getPilot)).transform(Predicates::MemberTransform(&CSimulatedAircraft::getPilot));
|
||||
}
|
||||
|
||||
/*
|
||||
* Aircrafts within range
|
||||
*/
|
||||
CSimulatedAircraftList CSimulatedAircraftList::findWithinRange(const BlackMisc::Geo::ICoordinateGeodetic &coordinate, const PhysicalQuantities::CLength &range) const
|
||||
{
|
||||
return this->findBy([&](const CSimulatedAircraft & aircraft)
|
||||
{
|
||||
return BlackMisc::Geo::greatCircleDistance(aircraft, coordinate) <= range;
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
#define BLACKMISC_SIMULATEDNAIRCRAFTLIST_H
|
||||
|
||||
#include "blackmisc/simulation/simulatedaircraft.h"
|
||||
#include "blackmisc/avcallsignlist.h"
|
||||
#include "blackmisc/avcallsignobjectlist.h"
|
||||
#include "blackmisc/geoobjectlist.h"
|
||||
#include "blackmisc/nwuserlist.h"
|
||||
#include "blackmisc/collection.h"
|
||||
#include "blackmisc/sequence.h"
|
||||
@@ -26,7 +27,10 @@ namespace BlackMisc
|
||||
namespace Simulation
|
||||
{
|
||||
//! Value object encapsulating a list of aircraft.
|
||||
class CSimulatedAircraftList : public CSequence<CSimulatedAircraft>
|
||||
class CSimulatedAircraftList :
|
||||
public BlackMisc::CSequence<CSimulatedAircraft>,
|
||||
public BlackMisc::Aviation::ICallsignObjectList<CSimulatedAircraft, CSimulatedAircraftList>,
|
||||
public BlackMisc::Geo::IGeoObjectList<CSimulatedAircraft, CSimulatedAircraftList>
|
||||
{
|
||||
public:
|
||||
//! Default constructor.
|
||||
@@ -35,32 +39,9 @@ namespace BlackMisc
|
||||
//! Construct from a base class object.
|
||||
CSimulatedAircraftList(const CSequence<CSimulatedAircraft> &other);
|
||||
|
||||
//! Find 0..n stations by callsign
|
||||
CSimulatedAircraftList findByCallsign(const BlackMisc::Aviation::CCallsign &callsign) const;
|
||||
|
||||
//! Find 0..n aircraft matching any of a set of callsigns
|
||||
CSimulatedAircraftList findByCallsigns(const BlackMisc::Aviation::CCallsignList &callsigns) const;
|
||||
|
||||
//! Find the first aircraft by callsign, if none return given one
|
||||
CSimulatedAircraft findFirstByCallsign(const BlackMisc::Aviation::CCallsign &callsign, const CSimulatedAircraft &ifNotFound = CSimulatedAircraft()) const;
|
||||
|
||||
//! Contains callsign?
|
||||
bool containsCallsign(const BlackMisc::Aviation::CCallsign &callsign) const;
|
||||
|
||||
//! Incremental update or add aircraft
|
||||
int incrementalUpdateOrAdd(const BlackMisc::Simulation::CSimulatedAircraft &toChangeAircraft, const BlackMisc::CPropertyIndexVariantMap &changedValues);
|
||||
|
||||
//! All pilots (with valid data)
|
||||
BlackMisc::Network::CUserList getPilots() const;
|
||||
|
||||
/*!
|
||||
* Find 0..n stations within range of given coordinate
|
||||
* \param coordinate other position
|
||||
* \param range within range of other position
|
||||
* \return
|
||||
*/
|
||||
CSimulatedAircraftList findWithinRange(const BlackMisc::Geo::ICoordinateGeodetic &coordinate, const BlackMisc::PhysicalQuantities::CLength &range) const;
|
||||
|
||||
//! \copydoc CValueObject::toQVariant
|
||||
virtual QVariant toQVariant() const override { return QVariant::fromValue(*this); }
|
||||
|
||||
@@ -69,6 +50,14 @@ namespace BlackMisc
|
||||
|
||||
//! Register metadata
|
||||
static void registerMetadata();
|
||||
|
||||
protected:
|
||||
//! Myself
|
||||
virtual const CSimulatedAircraftList &getContainer() const { return *this; }
|
||||
|
||||
//! Myself
|
||||
virtual CSimulatedAircraftList &getContainer() { return *this; }
|
||||
|
||||
};
|
||||
|
||||
} //namespace
|
||||
|
||||
Reference in New Issue
Block a user