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:
Klaus Basan
2015-01-27 03:27:01 +01:00
parent ea68170202
commit ce86c902b5
45 changed files with 1257 additions and 790 deletions

View File

@@ -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