refactor: Remove unused forward declarations

The forward-declared classes are already included directly
This commit is contained in:
Lars Toenning
2024-01-05 22:39:14 +01:00
parent 8604ddf06a
commit ab8b1c8e8c

View File

@@ -26,176 +26,169 @@
#include <QtGlobal> #include <QtGlobal>
#include <QTimer> #include <QTimer>
namespace BlackMisc namespace BlackMisc::Simulation
{ {
namespace Aviation class CInterpolationLogger;
class CInterpolatorLinear;
class CInterpolatorSpline;
//! Interpolator, calculation inbetween positions
template <typename Derived>
class CInterpolator :
protected CSimulationEnvironmentAware,
protected CInterpolationSetupAware,
protected CRemoteAircraftAware
{ {
class CAircraftSituation; public:
class CAircraftSituationChange; //! Log categories
} static const QStringList &getLogCategories();
namespace Simulation
{
class CInterpolationLogger;
class CInterpolatorLinear;
class CInterpolatorSpline;
//! Interpolator, calculation inbetween positions //! Latest interpolation result
template <typename Derived> const Aviation::CAircraftSituation &getLastInterpolatedSituation() const { return m_lastSituation; }
class CInterpolator :
protected CSimulationEnvironmentAware,
protected CInterpolationSetupAware,
protected CRemoteAircraftAware
{
public:
//! Log categories
static const QStringList &getLogCategories();
//! Latest interpolation result //! Get interpolated situation
const Aviation::CAircraftSituation &getLastInterpolatedSituation() const { return m_lastSituation; } //! \param currentTimeSinceEpoch milliseconds since epoch for which the situation should be interpolated
//! \param setup interpolation setup
//! \param aircraftNumber number used to spread the computational load of part interpolation
//! \return interpolation result
CInterpolationResult getInterpolation(qint64 currentTimeSinceEpoch, const CInterpolationAndRenderingSetupPerCallsign &setup, uint32_t aircraftNumber);
//! Get interpolated situation //! Attach an observer to read the interpolator's state for debugging
//! \param currentTimeSinceEpoch milliseconds since epoch for which the situation should be interpolated //! \remark parts logging has a \c bool \c log flag
//! \param setup interpolation setup void attachLogger(CInterpolationLogger *logger) { m_logger = logger; }
//! \param aircraftNumber number used to spread the computational load of part interpolation
//! \return interpolation result
CInterpolationResult getInterpolation(qint64 currentTimeSinceEpoch, const CInterpolationAndRenderingSetupPerCallsign &setup, uint32_t aircraftNumber);
//! Attach an observer to read the interpolator's state for debugging //! Is logger attached?
//! \remark parts logging has a \c bool \c log flag bool hasAttachedLogger() const { return m_logger; }
void attachLogger(CInterpolationLogger *logger) { m_logger = logger; }
//! Is logger attached? //! Get an interpolator info string (for debug info)
bool hasAttachedLogger() const { return m_logger; } QString getInterpolatorInfo() const;
//! Get an interpolator info string (for debug info) //! Reset last interpolation to null
QString getInterpolatorInfo() const; //! \remark mainly needed in UNIT tests
void resetLastInterpolation();
//! Reset last interpolation to null //! Init, or re-init the corressponding model
//! \remark mainly needed in UNIT tests //! \remark either by passing a model or using the provider
void resetLastInterpolation(); void initCorrespondingModel(const CAircraftModel &model = {});
//! Init, or re-init the corressponding model //! Mark as unit test
//! \remark either by passing a model or using the provider void markAsUnitTest();
void initCorrespondingModel(const CAircraftModel &model = {});
//! Mark as unit test //! Get count of invalid situations
void markAsUnitTest(); int getInvalidSituationsCount() const { return m_invalidSituations; }
//! Get count of invalid situations //! Interpolation messages
int getInvalidSituationsCount() const { return m_invalidSituations; } const CStatusMessageList &getInterpolationMessages() const { return m_interpolationMessages; }
//! Interpolation messages //! Do we have interpolation messages
const CStatusMessageList &getInterpolationMessages() const { return m_interpolationMessages; } bool hasInterpolationMessages() const { return !m_interpolationMessages.isEmpty(); }
//! Do we have interpolation messages protected:
bool hasInterpolationMessages() const { return !m_interpolationMessages.isEmpty(); } //! Constructor
CInterpolator(const Aviation::CCallsign &callsign,
ISimulationEnvironmentProvider *simEnvProvider, IInterpolationSetupProvider *setupProvider, IRemoteAircraftProvider *remoteProvider,
CInterpolationLogger *logger);
protected: //! Inits all data members for this current interpolation step
//! Constructor //! \param currentTimeSinceEpoch milliseconds since epoch for which the situation should be interpolated
CInterpolator(const Aviation::CCallsign &callsign, //! \param setup interpolation setup
ISimulationEnvironmentProvider *simEnvProvider, IInterpolationSetupProvider *setupProvider, IRemoteAircraftProvider *remoteProvider, //! \param aircraftNumber passing the aircraft number allows to equally distribute among the steps and not to do it always together for all aircraft
CInterpolationLogger *logger); bool initIniterpolationStepData(qint64 currentTimeSinceEpoch, const CInterpolationAndRenderingSetupPerCallsign &setup, int aircraftNumber);
//! Inits all data members for this current interpolation step //! Init the interpolated situation
//! \param currentTimeSinceEpoch milliseconds since epoch for which the situation should be interpolated Aviation::CAircraftSituation initInterpolatedSituation(const Aviation::CAircraftSituation &oldSituation, const Aviation::CAircraftSituation &newSituation) const;
//! \param setup interpolation setup
//! \param aircraftNumber passing the aircraft number allows to equally distribute among the steps and not to do it always together for all aircraft
bool initIniterpolationStepData(qint64 currentTimeSinceEpoch, const CInterpolationAndRenderingSetupPerCallsign &setup, int aircraftNumber);
//! Init the interpolated situation //! Current interpolated situation
Aviation::CAircraftSituation initInterpolatedSituation(const Aviation::CAircraftSituation &oldSituation, const Aviation::CAircraftSituation &newSituation) const; Aviation::CAircraftSituation getInterpolatedSituation();
//! Current interpolated situation //! Parts before given offset time
Aviation::CAircraftSituation getInterpolatedSituation(); Aviation::CAircraftParts getInterpolatedParts();
//! Parts before given offset time //! Interpolated parts, if not available guessed parts
Aviation::CAircraftParts getInterpolatedParts(); Aviation::CAircraftParts getInterpolatedOrGuessedParts(int aircraftNumber);
//! Interpolated parts, if not available guessed parts //! Center of gravity
Aviation::CAircraftParts getInterpolatedOrGuessedParts(int aircraftNumber); const PhysicalQuantities::CLength &getModelCG() const { return m_model.getCG(); }
//! Center of gravity //! Do logging
const PhysicalQuantities::CLength &getModelCG() const { return m_model.getCG(); } bool doLogging() const;
//! Do logging //! Decides threshold when situation is considered on ground
bool doLogging() const; //! \sa BlackMisc::Aviation::CAircraftSituation::setOnGroundFromGroundFactorFromInterpolation
static double groundInterpolationFactor();
//! Decides threshold when situation is considered on ground const Aviation::CCallsign m_callsign; //!< corresponding callsign
//! \sa BlackMisc::Aviation::CAircraftSituation::setOnGroundFromGroundFactorFromInterpolation CAircraftModel m_model; //!< corresponding model (required for CG)
static double groundInterpolationFactor();
const Aviation::CCallsign m_callsign; //!< corresponding callsign // values for current interpolation step
CAircraftModel m_model; //!< corresponding model (required for CG) qint64 m_currentTimeMsSinceEpoch = -1; //!< current time
qint64 m_lastInvalidLogTs = -1; //!< last invalid situation timestamp
Aviation::CAircraftSituationList m_currentSituations; //!< current situations obtained by remoteAircraftSituationsAndChange
Aviation::CAircraftSituationChange m_pastSituationsChange; //!< situations change of provider (i.e. network) situations
CInterpolationAndRenderingSetupPerCallsign m_currentSetup; //!< used setup
CInterpolationStatus m_currentInterpolationStatus; //!< this step's situation status
CPartsStatus m_currentPartsStatus; //!< this step's parts status
CPartsStatus m_lastPartsStatus; //!< status for last parts, used when last parts are re-used because of m_partsToSituationInterpolationRatio
int m_partsToSituationInterpolationRatio = 2; //!< ratio between parts and situation interpolation, 1..always, 2..every 2nd situation
int m_partsToSituationGuessingRatio = 5; //!< ratio between parts guessing and situation interpolation
int m_invalidSituations = 0; //!< mainly when there are no new situations
CStatusMessageList m_interpolationMessages; //!< interpolation messages
// values for current interpolation step Aviation::CAircraftSituation m_lastSituation { Aviation::CAircraftSituation::null() }; //!< latest interpolation
qint64 m_currentTimeMsSinceEpoch = -1; //!< current time Aviation::CAircraftParts m_lastParts { Aviation::CAircraftParts::null() }; //!< latest parts
qint64 m_lastInvalidLogTs = -1; //!< last invalid situation timestamp PhysicalQuantities::CLength m_currentSceneryOffset { PhysicalQuantities::CLength::null() }; //!< calculated scenery offset if any
Aviation::CAircraftSituationList m_currentSituations; //!< current situations obtained by remoteAircraftSituationsAndChange
Aviation::CAircraftSituationChange m_pastSituationsChange; //!< situations change of provider (i.e. network) situations
CInterpolationAndRenderingSetupPerCallsign m_currentSetup; //!< used setup
CInterpolationStatus m_currentInterpolationStatus; //!< this step's situation status
CPartsStatus m_currentPartsStatus; //!< this step's parts status
CPartsStatus m_lastPartsStatus; //!< status for last parts, used when last parts are re-used because of m_partsToSituationInterpolationRatio
int m_partsToSituationInterpolationRatio = 2; //!< ratio between parts and situation interpolation, 1..always, 2..every 2nd situation
int m_partsToSituationGuessingRatio = 5; //!< ratio between parts guessing and situation interpolation
int m_invalidSituations = 0; //!< mainly when there are no new situations
CStatusMessageList m_interpolationMessages; //!< interpolation messages
Aviation::CAircraftSituation m_lastSituation { Aviation::CAircraftSituation::null() }; //!< latest interpolation qint64 m_situationsLastModified { -1 }; //!< when situations were last modified
Aviation::CAircraftParts m_lastParts { Aviation::CAircraftParts::null() }; //!< latest parts qint64 m_situationsLastModifiedUsed { -1 }; //!< interpolant based on situations last updated
PhysicalQuantities::CLength m_currentSceneryOffset { PhysicalQuantities::CLength::null() }; //!< calculated scenery offset if any int m_interpolatedSituationsCounter { 0 }; //!< counter for each interpolated situations: used for statistics, every n-th interpolation ....
qint64 m_situationsLastModified { -1 }; //!< when situations were last modified bool m_unitTest = false; //!< mark as unit test
qint64 m_situationsLastModifiedUsed { -1 }; //!< interpolant based on situations last updated
int m_interpolatedSituationsCounter { 0 }; //!< counter for each interpolated situations: used for statistics, every n-th interpolation ....
bool m_unitTest = false; //!< mark as unit test //! Verify gnd flag, times, ... true means "OK"
bool verifyInterpolationSituations(const Aviation::CAircraftSituation &oldest, const Aviation::CAircraftSituation &newer, const Aviation::CAircraftSituation &latest,
const CInterpolationAndRenderingSetupPerCallsign &setup = CInterpolationAndRenderingSetupPerCallsign::null());
//! Verify gnd flag, times, ... true means "OK" private:
bool verifyInterpolationSituations(const Aviation::CAircraftSituation &oldest, const Aviation::CAircraftSituation &newer, const Aviation::CAircraftSituation &latest, CInterpolationLogger *m_logger = nullptr; //!< optional interpolation logger
const CInterpolationAndRenderingSetupPerCallsign &setup = CInterpolationAndRenderingSetupPerCallsign::null()); QTimer m_initTimer; //!< timer to init model, will be deleted when interpolator is deleted and cancel the call
private: //! Guessed parts
CInterpolationLogger *m_logger = nullptr; //!< optional interpolation logger static Aviation::CAircraftParts guessParts(const Aviation::CAircraftSituation &situation, const Aviation::CAircraftSituationChange &change, const Simulation::CAircraftModel &model);
QTimer m_initTimer; //!< timer to init model, will be deleted when interpolator is deleted and cancel the call
//! Guessed parts //! Log parts
static Aviation::CAircraftParts guessParts(const Aviation::CAircraftSituation &situation, const Aviation::CAircraftSituationChange &change, const Simulation::CAircraftModel &model); void logParts(const Aviation::CAircraftParts &parts, int partsNo, bool empty) const;
//! Log parts //! Get situations and calculate change, also correct altitudes if applicable
void logParts(const Aviation::CAircraftParts &parts, int partsNo, bool empty) const; //! \remark calculates offset (scenery) and situations change
Aviation::CAircraftSituationList remoteAircraftSituationsAndChange(const CInterpolationAndRenderingSetupPerCallsign &setup);
//! Get situations and calculate change, also correct altitudes if applicable //! Center of gravity, fetched from provider in case needed
//! \remark calculates offset (scenery) and situations change PhysicalQuantities::CLength getAndFetchModelCG(const PhysicalQuantities::CLength &dbCG);
Aviation::CAircraftSituationList remoteAircraftSituationsAndChange(const CInterpolationAndRenderingSetupPerCallsign &setup);
//! Center of gravity, fetched from provider in case needed //! Preset the ground elevation based on info we already have, either by transfer or elevation
PhysicalQuantities::CLength getAndFetchModelCG(const PhysicalQuantities::CLength &dbCG); //! \remark either sets a gnd. elevation or sets it to null
//! \remark situationToPreset position is unknown
//! \remark situationToPreset needs to be between oldSituation and newSituation
//! \sa CAircraftSituation::transferGroundElevation
static bool presetGroundElevation(Aviation::CAircraftSituation &situationToPreset, const Aviation::CAircraftSituation &oldSituation, const Aviation::CAircraftSituation &newSituation, const Aviation::CAircraftSituationChange &change);
//! Preset the ground elevation based on info we already have, either by transfer or elevation //! Deferred init
//! \remark either sets a gnd. elevation or sets it to null void deferredInit();
//! \remark situationToPreset position is unknown
//! \remark situationToPreset needs to be between oldSituation and newSituation
//! \sa CAircraftSituation::transferGroundElevation
static bool presetGroundElevation(Aviation::CAircraftSituation &situationToPreset, const Aviation::CAircraftSituation &oldSituation, const Aviation::CAircraftSituation &newSituation, const Aviation::CAircraftSituationChange &change);
//! Deferred init //! Return NULL parts and log
void deferredInit(); const BlackMisc::Aviation::CAircraftParts &logAndReturnNullParts(const QString &info, bool log);
//! Return NULL parts and log //! @{
const BlackMisc::Aviation::CAircraftParts &logAndReturnNullParts(const QString &info, bool log); //! Derived class
Derived *derived() { return static_cast<Derived *>(this); }
const Derived *derived() const { return static_cast<const Derived *>(this); }
//! @}
};
//! @{ //! \cond PRIVATE
//! Derived class extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE CInterpolator<CInterpolatorLinear>;
Derived *derived() { return static_cast<Derived *>(this); } extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE CInterpolator<CInterpolatorSpline>;
const Derived *derived() const { return static_cast<const Derived *>(this); } //! \endcond
//! @}
};
//! \cond PRIVATE
extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE CInterpolator<CInterpolatorLinear>;
extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE CInterpolator<CInterpolatorSpline>;
//! \endcond
} // namespace
} // namespace } // namespace
// namespace
#endif // guard #endif // guard