refs #863 Moved nested status classes to namespace scope.

This commit is contained in:
Mathew Sutcliffe
2017-01-17 23:04:45 +00:00
parent b8fc62a2a4
commit 1c2533f5d2
9 changed files with 73 additions and 71 deletions

View File

@@ -35,7 +35,7 @@ namespace BlackMisc
BlackMisc::Aviation::CAircraftSituation IInterpolator::getInterpolatedSituation(
qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetup &setup,
const CInterpolationHints &hints, InterpolationStatus &status) const
const CInterpolationHints &hints, CInterpolationStatus &status) const
{
status.reset();
@@ -45,7 +45,7 @@ namespace BlackMisc
}
CAircraftParts IInterpolator::getInterpolatedParts(const CCallsign &callsign, const CAircraftPartsList &parts, qint64 currentTimeMsSinceEpoch,
const CInterpolationAndRenderingSetup &setup, IInterpolator::PartsStatus &partsStatus, bool log) const
const CInterpolationAndRenderingSetup &setup, CPartsStatus &partsStatus, bool log) const
{
Q_UNUSED(setup);
partsStatus.reset();
@@ -109,7 +109,7 @@ namespace BlackMisc
}
CAircraftParts IInterpolator::getInterpolatedParts(const CCallsign &callsign, qint64 currentTimeMsSinceEpoch,
const CInterpolationAndRenderingSetup &setup, IInterpolator::PartsStatus &partsStatus, bool log) const
const CInterpolationAndRenderingSetup &setup, CPartsStatus &partsStatus, bool log) const
{
partsStatus.reset();
return this->getInterpolatedParts(callsign, this->m_aircraftParts, currentTimeMsSinceEpoch, setup, partsStatus, log);
@@ -398,23 +398,23 @@ namespace BlackMisc
return QString("%1 %2 %3").arg(msSinceEpochToTime(t1), msSinceEpochToTime(t2), msSinceEpochToTime(t3));
}
bool IInterpolator::InterpolationStatus::allTrue() const
bool CInterpolationStatus::allTrue() const
{
return m_interpolationSucceeded && m_changedPosition;
}
void IInterpolator::InterpolationStatus::reset()
void CInterpolationStatus::reset()
{
m_changedPosition = false;
m_interpolationSucceeded = false;
}
bool IInterpolator::PartsStatus::allTrue() const
bool CPartsStatus::allTrue() const
{
return m_supportsParts;
}
void IInterpolator::PartsStatus::reset()
void CPartsStatus::reset()
{
m_supportsParts = false;
}

View File

@@ -30,6 +30,8 @@ namespace BlackMisc
namespace Simulation
{
class CInterpolationHints;
struct CInterpolationStatus;
struct CPartsStatus;
//! Interpolator, calculation inbetween positions
class BLACKMISC_EXPORT IInterpolator : public QObject
@@ -40,74 +42,27 @@ namespace BlackMisc
//! Log category
static QString getLogCategory() { return "swift.interpolator"; }
//! Status of interpolation
struct BLACKMISC_EXPORT InterpolationStatus // does not link without export/allTrue, reset
{
public:
//! Did interpolation succeed?
bool didInterpolationSucceed() const { return m_interpolationSucceeded; }
//! Set succeeded
void setInterpolationSucceeded(bool succeeded) { m_interpolationSucceeded = succeeded; }
//! Changed position?
bool hasChangedPosition() const { return m_changedPosition; }
//! Set as changed
void setChangedPosition(bool changed) { m_changedPosition = changed; }
//! all OK
bool allTrue() const;
//! Reset to default values
void reset();
private:
bool m_changedPosition = false; //!< position was changed
bool m_interpolationSucceeded = false; //!< interpolation succeeded (means enough values, etc.)
};
//! Status regarding parts
struct BLACKMISC_EXPORT PartsStatus // does not link without export/allTrue, resetx
{
public:
//! all OK
bool allTrue() const;
//! Supporting parts
bool isSupportingParts() const { return m_supportsParts; }
//! Set support flag
void setSupportsParts(bool supports) { m_supportsParts = supports; }
//! Reset to default values
void reset();
private:
bool m_supportsParts = false; //!< supports parts for given callsign
};
//! Current interpolated situation
virtual BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation(
const BlackMisc::Aviation::CCallsign &callsign, qint64 currentTimeSinceEpoc,
const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints, InterpolationStatus &status) const;
const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints, CInterpolationStatus &status) const;
//! Current interpolated situation, to be implemented by subclass
virtual BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation(
const BlackMisc::Aviation::CCallsign &callsign,
const BlackMisc::Aviation::CAircraftSituationList &situations, qint64 currentTimeSinceEpoc,
const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints, InterpolationStatus &status) const = 0;
const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints, CInterpolationStatus &status) const = 0;
//! Parts before given offset time (aka pending parts)
virtual BlackMisc::Aviation::CAircraftParts getInterpolatedParts(
const Aviation::CCallsign &callsign,
const BlackMisc::Aviation::CAircraftPartsList &parts, qint64 cutoffTime,
const CInterpolationAndRenderingSetup &setup, PartsStatus &partsStatus, bool log = false) const;
const CInterpolationAndRenderingSetup &setup, CPartsStatus &partsStatus, bool log = false) const;
//! Parts before given offset time (aka pending parts)
virtual BlackMisc::Aviation::CAircraftParts getInterpolatedParts(
const BlackMisc::Aviation::CCallsign &callsign, qint64 cutoffTime,
const CInterpolationAndRenderingSetup &setup, PartsStatus &partsStatus, bool log = false) const;
const CInterpolationAndRenderingSetup &setup, CPartsStatus &partsStatus, bool log = false) const;
//! Add a new aircraft situation
void addAircraftSituation(const BlackMisc::Aviation::CAircraftSituation &situation);
@@ -208,6 +163,53 @@ namespace BlackMisc
mutable QList<PartsLog> m_partsLogs; //!< logs of parts
mutable QList<InterpolationLog> m_interpolationLogs; //!< logs of interpolation
};
//! Status of interpolation
struct BLACKMISC_EXPORT CInterpolationStatus
{
public:
//! Did interpolation succeed?
bool didInterpolationSucceed() const { return m_interpolationSucceeded; }
//! Set succeeded
void setInterpolationSucceeded(bool succeeded) { m_interpolationSucceeded = succeeded; }
//! Changed position?
bool hasChangedPosition() const { return m_changedPosition; }
//! Set as changed
void setChangedPosition(bool changed) { m_changedPosition = changed; }
//! all OK
bool allTrue() const;
//! Reset to default values
void reset();
private:
bool m_changedPosition = false; //!< position was changed
bool m_interpolationSucceeded = false; //!< interpolation succeeded (means enough values, etc.)
};
//! Status regarding parts
struct BLACKMISC_EXPORT CPartsStatus
{
public:
//! all OK
bool allTrue() const;
//! Supporting parts
bool isSupportingParts() const { return m_supportsParts; }
//! Set support flag
void setSupportsParts(bool supports) { m_supportsParts = supports; }
//! Reset to default values
void reset();
private:
bool m_supportsParts = false; //!< supports parts for given callsign
};
} // namespace
} // namespace
#endif // guard

View File

@@ -41,7 +41,7 @@ namespace BlackMisc
namespace Simulation
{
CAircraftSituation CInterpolatorLinear::getInterpolatedSituation(const CCallsign &callsign, const CAircraftSituationList &situations, qint64 currentTimeMsSinceEpoc,
const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints, InterpolationStatus &status) const
const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints, CInterpolationStatus &status) const
{
status.reset();

View File

@@ -41,7 +41,7 @@ namespace BlackMisc
virtual BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation(
const BlackMisc::Aviation::CCallsign &callsign,
const BlackMisc::Aviation::CAircraftSituationList &situations, qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetup &setup,
const BlackMisc::Simulation::CInterpolationHints &hints, InterpolationStatus &status) const override;
const BlackMisc::Simulation::CInterpolationHints &hints, CInterpolationStatus &status) const override;
//! Log category
static QString getLogCategory() { return "swift.interpolatorlinear"; }