refs #863 Simplification.

This commit is contained in:
Mathew Sutcliffe
2017-02-05 17:00:14 +00:00
parent 9c918b8799
commit c0f163589d
4 changed files with 8 additions and 45 deletions

View File

@@ -36,19 +36,7 @@ namespace BlackMisc
}
template <typename Derived>
BlackMisc::Aviation::CAircraftSituation CInterpolator<Derived>::getInterpolatedSituation(
qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetup &setup,
const CInterpolationHints &hints, CInterpolationStatus &status) const
{
status.reset();
auto currentSituation = derived()->getInterpolatedSituation(callsign, this->m_aircraftSituations, currentTimeSinceEpoc, setup, hints, status);
currentSituation.setCallsign(callsign); // make sure callsign is correct
return currentSituation;
}
template <typename Derived>
CAircraftParts CInterpolator<Derived>::getInterpolatedParts(const CCallsign &callsign, const CAircraftPartsList &parts, qint64 currentTimeMsSinceEpoch,
CAircraftParts CInterpolator<Derived>::getInterpolatedParts(const CCallsign &callsign, qint64 currentTimeMsSinceEpoch,
const CInterpolationAndRenderingSetup &setup, CPartsStatus &partsStatus, bool log) const
{
Q_UNUSED(setup);
@@ -56,9 +44,8 @@ namespace BlackMisc
if (currentTimeMsSinceEpoch < 0) { currentTimeMsSinceEpoch = QDateTime::currentMSecsSinceEpoch(); }
// find the first parts not in the correct order, keep only the parts before that one
if (parts.isEmpty()) { return {}; }
const auto end = std::is_sorted_until(parts.begin(), parts.end(), [](auto && a, auto && b) { return b.getAdjustedMSecsSinceEpoch() < a.getAdjustedMSecsSinceEpoch(); });
const auto validParts = makeRange(parts.begin(), end);
const auto end = std::is_sorted_until(m_aircraftParts.begin(), m_aircraftParts.end(), [](auto && a, auto && b) { return b.getAdjustedMSecsSinceEpoch() < a.getAdjustedMSecsSinceEpoch(); });
const auto validParts = makeRange(m_aircraftParts.begin(), end);
// stop if we don't have any parts
if (validParts.isEmpty()) { return {}; }
@@ -112,14 +99,6 @@ namespace BlackMisc
return currentParts;
}
template <typename Derived>
CAircraftParts CInterpolator<Derived>::getInterpolatedParts(const CCallsign &callsign, qint64 currentTimeMsSinceEpoch,
const CInterpolationAndRenderingSetup &setup, CPartsStatus &partsStatus, bool log) const
{
partsStatus.reset();
return this->getInterpolatedParts(callsign, this->m_aircraftParts, currentTimeMsSinceEpoch, setup, partsStatus, log);
}
template <typename Derived>
void CInterpolator<Derived>::addAircraftSituation(const CAircraftSituation &situation)
{

View File

@@ -44,12 +44,6 @@ namespace BlackMisc
//! Current interpolated situation
BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation(
const BlackMisc::Aviation::CCallsign &callsign, qint64 currentTimeSinceEpoc,
const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints, CInterpolationStatus &status) const;
//! Current interpolated situation, to be implemented by subclass
BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation(
const BlackMisc::Aviation::CCallsign &callsign,
const BlackMisc::Aviation::CAircraftSituationList &situations, qint64 currentTimeSinceEpoc,
const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints, CInterpolationStatus &status) const
{
qFatal("Not implemented");
@@ -58,13 +52,7 @@ namespace BlackMisc
//! Parts before given offset time (aka pending parts)
BlackMisc::Aviation::CAircraftParts getInterpolatedParts(
const Aviation::CCallsign &callsign,
const BlackMisc::Aviation::CAircraftPartsList &parts, qint64 cutoffTime,
const CInterpolationAndRenderingSetup &setup, CPartsStatus &partsStatus, bool log = false) const;
//! Parts before given offset time (aka pending parts)
BlackMisc::Aviation::CAircraftParts getInterpolatedParts(
const BlackMisc::Aviation::CCallsign &callsign, qint64 cutoffTime,
const Aviation::CCallsign &callsign, qint64 cutoffTime,
const CInterpolationAndRenderingSetup &setup, CPartsStatus &partsStatus, bool log = false) const;
//! Add a new aircraft situation

View File

@@ -40,7 +40,7 @@ namespace BlackMisc
{
namespace Simulation
{
CAircraftSituation CInterpolatorLinear::getInterpolatedSituation(const CCallsign &callsign, const CAircraftSituationList &situations, qint64 currentTimeMsSinceEpoc,
CAircraftSituation CInterpolatorLinear::getInterpolatedSituation(const CCallsign &callsign, qint64 currentTimeMsSinceEpoc,
const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints, CInterpolationStatus &status) const
{
status.reset();
@@ -53,8 +53,8 @@ namespace BlackMisc
// find the first situation not in the correct order, keep only the situations before that one
// any updates in wrong chronological order are discounted
const auto end = std::is_sorted_until(situations.begin(), situations.end(), [](auto && a, auto && b) { return b.getAdjustedMSecsSinceEpoch() < a.getAdjustedMSecsSinceEpoch(); });
const auto validSituations = makeRange(situations.begin(), end);
const auto end = std::is_sorted_until(m_aircraftSituations.begin(), m_aircraftSituations.end(), [](auto && a, auto && b) { return b.getAdjustedMSecsSinceEpoch() < a.getAdjustedMSecsSinceEpoch(); });
const auto validSituations = makeRange(m_aircraftSituations.begin(), end);
// find the first situation earlier than the current time
const auto pivot = std::partition_point(validSituations.begin(), validSituations.end(), [ = ](auto && s) { return s.getAdjustedMSecsSinceEpoch() > currentTimeMsSinceEpoc; });

View File

@@ -36,13 +36,9 @@ namespace BlackMisc
CInterpolator("CInterpolatorLinear", parent)
{}
// public base class signature
using CInterpolator::getInterpolatedSituation;
//! \copydoc IInterpolator::getInterpolatedSituation
BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation(
const BlackMisc::Aviation::CCallsign &callsign,
const BlackMisc::Aviation::CAircraftSituationList &situations, qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetup &setup,
const BlackMisc::Aviation::CCallsign &callsign, qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetup &setup,
const BlackMisc::Simulation::CInterpolationHints &hints, CInterpolationStatus &status) const;
//! Log category