mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-27 19:25:49 +08:00
refs #403 workaround different extern template behaviour with MinGW
This commit is contained in:
@@ -108,12 +108,12 @@ namespace BlackMisc
|
||||
CONTAINER &container();
|
||||
};
|
||||
|
||||
extern template class ICallsignObjectList<BlackMisc::Aviation::CAtcStation, BlackMisc::Aviation::CAtcStationList>;
|
||||
extern template class ICallsignObjectList<BlackMisc::Aviation::CAircraft, BlackMisc::Aviation::CAircraftList>;
|
||||
extern template class ICallsignObjectList<BlackMisc::Aviation::CAircraftSituation, BlackMisc::Aviation::CAircraftSituationList>;
|
||||
extern template class ICallsignObjectList<BlackMisc::Aviation::CAircraftParts, BlackMisc::Aviation::CAircraftPartsList>;
|
||||
extern template class ICallsignObjectList<BlackMisc::Simulation::CSimulatedAircraft, BlackMisc::Simulation::CSimulatedAircraftList>;
|
||||
extern template class ICallsignObjectList<BlackMisc::Network::CClient, BlackMisc::Network::CClientList>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE ICallsignObjectList<BlackMisc::Aviation::CAtcStation, BlackMisc::Aviation::CAtcStationList>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE ICallsignObjectList<BlackMisc::Aviation::CAircraft, BlackMisc::Aviation::CAircraftList>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE ICallsignObjectList<BlackMisc::Aviation::CAircraftSituation, BlackMisc::Aviation::CAircraftSituationList>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE ICallsignObjectList<BlackMisc::Aviation::CAircraftParts, BlackMisc::Aviation::CAircraftPartsList>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE ICallsignObjectList<BlackMisc::Simulation::CSimulatedAircraft, BlackMisc::Simulation::CSimulatedAircraftList>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE ICallsignObjectList<BlackMisc::Network::CClient, BlackMisc::Network::CClientList>;
|
||||
|
||||
} //namespace
|
||||
} // namespace
|
||||
|
||||
@@ -23,6 +23,12 @@ namespace BlackMisc
|
||||
namespace Aviation
|
||||
{
|
||||
|
||||
template <class AVIO>
|
||||
bool CModulator<AVIO>::isDefaultValue() const
|
||||
{
|
||||
return (this->m_frequencyActive == FrequencyNotSet());
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
void CModulator<AVIO>::toggleActiveStandby()
|
||||
{
|
||||
@@ -31,6 +37,66 @@ namespace BlackMisc
|
||||
this->m_frequencyStandby = a;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
BlackMisc::PhysicalQuantities::CFrequency CModulator<AVIO>::getFrequencyActive() const
|
||||
{
|
||||
return this->m_frequencyActive;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
BlackMisc::PhysicalQuantities::CFrequency CModulator<AVIO>::getFrequencyStandby() const
|
||||
{
|
||||
return this->m_frequencyStandby;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
void CModulator<AVIO>::setFrequencyActive(const BlackMisc::PhysicalQuantities::CFrequency &frequency)
|
||||
{
|
||||
this->m_frequencyActive = frequency;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
void CModulator<AVIO>::setFrequencyStandby(const BlackMisc::PhysicalQuantities::CFrequency &frequency)
|
||||
{
|
||||
this->m_frequencyStandby = frequency;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
qint32 CModulator<AVIO>::getVolumeOutput() const
|
||||
{
|
||||
return this->m_volumeOutput;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
qint32 CModulator<AVIO>::getVolumeInput() const
|
||||
{
|
||||
return this->m_volumeInput;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
void CModulator<AVIO>::setVolumeOutput(qint32 volume)
|
||||
{
|
||||
this->m_volumeOutput = volume;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
void CModulator<AVIO>::setVolumeInput(qint32 volume)
|
||||
{
|
||||
this->m_volumeInput = volume;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
bool CModulator<AVIO>::isEnabled() const
|
||||
{
|
||||
return this->m_enabled;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
void CModulator<AVIO>::setEnabled(bool enable)
|
||||
{
|
||||
this->m_enabled = enable;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
CVariant CModulator<AVIO>::propertyByIndex(const CPropertyIndex &index) const
|
||||
{
|
||||
@@ -85,6 +151,113 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
CModulator<AVIO>::CModulator() :
|
||||
CModulator::CValueObject("default") {}
|
||||
|
||||
template <class AVIO>
|
||||
CModulator<AVIO>::CModulator(const QString &name, const BlackMisc::PhysicalQuantities::CFrequency &activeFrequency, const BlackMisc::PhysicalQuantities::CFrequency &standbyFrequency) :
|
||||
CModulator::CValueObject(name), m_frequencyActive(activeFrequency), m_frequencyStandby(standbyFrequency) {}
|
||||
|
||||
template <class AVIO>
|
||||
QString CModulator<AVIO>::convertToQString(bool i18n) const
|
||||
{
|
||||
QString s(this->getName());
|
||||
s.append(" Active: ").append(this->m_frequencyActive.valueRoundedWithUnit(3, i18n));
|
||||
s.append(" Standby: ").append(this->m_frequencyStandby.valueRoundedWithUnit(3, i18n));
|
||||
return s;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
void CModulator<AVIO>::setFrequencyActiveKHz(double frequencyKHz)
|
||||
{
|
||||
this->m_frequencyActive = BlackMisc::PhysicalQuantities::CFrequency(frequencyKHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::kHz());
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
void CModulator<AVIO>::setFrequencyStandbyKHz(double frequencyKHz)
|
||||
{
|
||||
this->m_frequencyStandby = BlackMisc::PhysicalQuantities::CFrequency(frequencyKHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::kHz());
|
||||
}
|
||||
|
||||
|
||||
template <class AVIO>
|
||||
void CModulator<AVIO>::setFrequencyActiveMHz(double frequencyMHz)
|
||||
{
|
||||
frequencyMHz = Math::CMathUtils::round(frequencyMHz, 3);
|
||||
this->m_frequencyActive = BlackMisc::PhysicalQuantities::CFrequency(frequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz());
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
void CModulator<AVIO>::setFrequencyStandbyMHz(double frequencyMHz)
|
||||
{
|
||||
frequencyMHz = Math::CMathUtils::round(frequencyMHz, 3);
|
||||
this->m_frequencyStandby = BlackMisc::PhysicalQuantities::CFrequency(frequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz());
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
const QString &CModulator<AVIO>::NameCom1()
|
||||
{
|
||||
static QString n("COM1");
|
||||
return n;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
const QString &CModulator<AVIO>::NameCom2()
|
||||
{
|
||||
static QString n("COM2");
|
||||
return n;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
const QString &CModulator<AVIO>::NameCom3()
|
||||
{
|
||||
static QString n("COM3");
|
||||
return n;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
const QString &CModulator<AVIO>::NameNav1()
|
||||
{
|
||||
static QString n("NAV1");
|
||||
return n;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
const QString &CModulator<AVIO>::NameNav2()
|
||||
{
|
||||
static QString n("NAV2");
|
||||
return n;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
const QString &CModulator<AVIO>::NameNav3()
|
||||
{
|
||||
static QString n("NAV3");
|
||||
return n;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
const QString &CModulator<AVIO>::NameAdf1()
|
||||
{
|
||||
static QString n("ADF1");
|
||||
return n;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
const QString &CModulator<AVIO>::NameAdf2()
|
||||
{
|
||||
static QString n("ADF2");
|
||||
return n;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
const BlackMisc::PhysicalQuantities::CFrequency &CModulator<AVIO>::FrequencyNotSet()
|
||||
{
|
||||
static BlackMisc::PhysicalQuantities::CFrequency f;
|
||||
return f;
|
||||
}
|
||||
|
||||
template <class AVIO>
|
||||
AVIO const *CModulator<AVIO>::derived() const
|
||||
{
|
||||
|
||||
@@ -41,55 +41,40 @@ namespace BlackMisc
|
||||
};
|
||||
|
||||
//! Default value?
|
||||
virtual bool isDefaultValue() const
|
||||
{
|
||||
return (this->m_frequencyActive == FrequencyNotSet());
|
||||
}
|
||||
virtual bool isDefaultValue() const;
|
||||
|
||||
//! Toggle active and standby frequencies
|
||||
void toggleActiveStandby();
|
||||
|
||||
//! Active frequency
|
||||
BlackMisc::PhysicalQuantities::CFrequency getFrequencyActive() const
|
||||
{
|
||||
return this->m_frequencyActive;
|
||||
}
|
||||
BlackMisc::PhysicalQuantities::CFrequency getFrequencyActive() const;
|
||||
|
||||
//! Standby frequency
|
||||
BlackMisc::PhysicalQuantities::CFrequency getFrequencyStandby() const
|
||||
{
|
||||
return this->m_frequencyStandby;
|
||||
}
|
||||
BlackMisc::PhysicalQuantities::CFrequency getFrequencyStandby() const;
|
||||
|
||||
//! Set active frequency
|
||||
virtual void setFrequencyActive(const BlackMisc::PhysicalQuantities::CFrequency &frequency)
|
||||
{
|
||||
this->m_frequencyActive = frequency;
|
||||
}
|
||||
virtual void setFrequencyActive(const BlackMisc::PhysicalQuantities::CFrequency &frequency);
|
||||
|
||||
//! Set standby frequency
|
||||
virtual void setFrequencyStandby(const BlackMisc::PhysicalQuantities::CFrequency &frequency)
|
||||
{
|
||||
this->m_frequencyStandby = frequency;
|
||||
}
|
||||
virtual void setFrequencyStandby(const BlackMisc::PhysicalQuantities::CFrequency &frequency);
|
||||
|
||||
//! Output volume 0..100
|
||||
qint32 getVolumeOutput() const { return this->m_volumeOutput; }
|
||||
qint32 getVolumeOutput() const;
|
||||
|
||||
//! Input volume 0..100
|
||||
qint32 getVolumeInput() const { return this->m_volumeInput; }
|
||||
qint32 getVolumeInput() const;
|
||||
|
||||
//! Output volume 0.100
|
||||
void setVolumeOutput(qint32 volume) { this->m_volumeOutput = volume; }
|
||||
void setVolumeOutput(qint32 volume);
|
||||
|
||||
//! Input volume 0..100
|
||||
void setVolumeInput(qint32 volume) { this->m_volumeInput = volume; }
|
||||
void setVolumeInput(qint32 volume);
|
||||
|
||||
//! Enabled?
|
||||
bool isEnabled() const { return this->m_enabled;}
|
||||
bool isEnabled() const;
|
||||
|
||||
//! Enabled?
|
||||
void setEnabled(bool enable) { this->m_enabled = enable;}
|
||||
void setEnabled(bool enable);
|
||||
|
||||
//! \copydoc CValueObject::propertyByIndex
|
||||
virtual CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||
@@ -99,110 +84,52 @@ namespace BlackMisc
|
||||
|
||||
protected:
|
||||
//! Default constructor
|
||||
CModulator() :
|
||||
CModulator::CValueObject("default") {}
|
||||
CModulator();
|
||||
|
||||
//! Constructor
|
||||
CModulator(const QString &name, const BlackMisc::PhysicalQuantities::CFrequency &activeFrequency, const BlackMisc::PhysicalQuantities::CFrequency &standbyFrequency) :
|
||||
CModulator::CValueObject(name), m_frequencyActive(activeFrequency), m_frequencyStandby(standbyFrequency) {}
|
||||
CModulator(const QString &name, const BlackMisc::PhysicalQuantities::CFrequency &activeFrequency, const BlackMisc::PhysicalQuantities::CFrequency &standbyFrequency);
|
||||
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
virtual QString convertToQString(bool i18n = false) const override
|
||||
{
|
||||
QString s(this->getName());
|
||||
s.append(" Active: ").append(this->m_frequencyActive.valueRoundedWithUnit(3, i18n));
|
||||
s.append(" Standby: ").append(this->m_frequencyStandby.valueRoundedWithUnit(3, i18n));
|
||||
return s;
|
||||
}
|
||||
virtual QString convertToQString(bool i18n = false) const override;
|
||||
|
||||
//! Set active frequency
|
||||
void setFrequencyActiveKHz(double frequencyKHz)
|
||||
{
|
||||
this->m_frequencyActive = BlackMisc::PhysicalQuantities::CFrequency(frequencyKHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::kHz());
|
||||
}
|
||||
void setFrequencyActiveKHz(double frequencyKHz);
|
||||
|
||||
//! Set standby frequency
|
||||
void setFrequencyStandbyKHz(double frequencyKHz)
|
||||
{
|
||||
this->m_frequencyStandby = BlackMisc::PhysicalQuantities::CFrequency(frequencyKHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::kHz());
|
||||
}
|
||||
void setFrequencyStandbyKHz(double frequencyKHz);
|
||||
|
||||
//! Set active frequency
|
||||
virtual void setFrequencyActiveMHz(double frequencyMHz)
|
||||
{
|
||||
frequencyMHz = Math::CMathUtils::round(frequencyMHz, 3);
|
||||
this->m_frequencyActive = BlackMisc::PhysicalQuantities::CFrequency(frequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz());
|
||||
}
|
||||
virtual void setFrequencyActiveMHz(double frequencyMHz);
|
||||
|
||||
//! Set standby frequency
|
||||
virtual void setFrequencyStandbyMHz(double frequencyMHz)
|
||||
{
|
||||
frequencyMHz = Math::CMathUtils::round(frequencyMHz, 3);
|
||||
this->m_frequencyStandby = BlackMisc::PhysicalQuantities::CFrequency(frequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz());
|
||||
}
|
||||
virtual void setFrequencyStandbyMHz(double frequencyMHz);
|
||||
|
||||
//! COM1
|
||||
static const QString &NameCom1()
|
||||
{
|
||||
static QString n("COM1");
|
||||
return n;
|
||||
}
|
||||
static const QString &NameCom1();
|
||||
|
||||
//! COM2
|
||||
static const QString &NameCom2()
|
||||
{
|
||||
static QString n("COM2");
|
||||
return n;
|
||||
}
|
||||
static const QString &NameCom2();
|
||||
|
||||
//! COM3
|
||||
static const QString &NameCom3()
|
||||
{
|
||||
static QString n("COM3");
|
||||
return n;
|
||||
}
|
||||
static const QString &NameCom3();
|
||||
|
||||
//! NAV1
|
||||
static const QString &NameNav1()
|
||||
{
|
||||
static QString n("NAV1");
|
||||
return n;
|
||||
}
|
||||
static const QString &NameNav1();
|
||||
|
||||
//! NAV2
|
||||
static const QString &NameNav2()
|
||||
{
|
||||
static QString n("NAV2");
|
||||
return n;
|
||||
}
|
||||
static const QString &NameNav2();
|
||||
|
||||
//! NAV3
|
||||
static const QString &NameNav3()
|
||||
{
|
||||
static QString n("NAV3");
|
||||
return n;
|
||||
}
|
||||
static const QString &NameNav3();
|
||||
|
||||
//! ADF1
|
||||
static const QString &NameAdf1()
|
||||
{
|
||||
static QString n("ADF1");
|
||||
return n;
|
||||
}
|
||||
static const QString &NameAdf1();
|
||||
|
||||
//! ADF2
|
||||
static const QString &NameAdf2()
|
||||
{
|
||||
static QString n("ADF2");
|
||||
return n;
|
||||
}
|
||||
static const QString &NameAdf2();
|
||||
|
||||
//! Frequency not set
|
||||
static const BlackMisc::PhysicalQuantities::CFrequency &FrequencyNotSet()
|
||||
{
|
||||
static BlackMisc::PhysicalQuantities::CFrequency f;
|
||||
return f;
|
||||
}
|
||||
static const BlackMisc::PhysicalQuantities::CFrequency &FrequencyNotSet();
|
||||
|
||||
private:
|
||||
BLACK_ENABLE_TUPLE_CONVERSION(CModulator)
|
||||
@@ -219,9 +146,9 @@ namespace BlackMisc
|
||||
AVIO *derived();
|
||||
};
|
||||
|
||||
extern template class CModulator<CComSystem>;
|
||||
extern template class CModulator<CNavSystem>;
|
||||
extern template class CModulator<CAdfSystem>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE CModulator<CComSystem>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE CModulator<CNavSystem>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE CModulator<CAdfSystem>;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,4 +24,10 @@
|
||||
# define BLACKMISC_EXPORT
|
||||
#endif
|
||||
|
||||
#endif // BLACKMISC_MACROS_H
|
||||
#if defined(Q_OS_WIN) && defined(Q_CC_GNU)
|
||||
# define BLACKMISC_EXPORT_TEMPLATE BLACKMISC_EXPORT
|
||||
#else
|
||||
# define BLACKMISC_EXPORT_TEMPLATE
|
||||
#endif
|
||||
|
||||
#endif // BLACKMISC_MACROS_H
|
||||
|
||||
@@ -17,7 +17,77 @@ namespace BlackMisc
|
||||
namespace Geo
|
||||
{
|
||||
|
||||
template <class LATorLON> LATorLON CEarthAngle<LATorLON>::fromWgs84(const QString &wgsCoordinate)
|
||||
template <class LATorLON>
|
||||
CEarthAngle<LATorLON> &CEarthAngle<LATorLON>::operator +=(const CEarthAngle &latOrLon)
|
||||
{
|
||||
this->PhysicalQuantities::CAngle::operator +=(latOrLon);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class LATorLON>
|
||||
CEarthAngle<LATorLON> &CEarthAngle<LATorLON>::operator -=(const CEarthAngle &latOrLon)
|
||||
{
|
||||
this->PhysicalQuantities::CAngle::operator -=(latOrLon);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class LATorLON>
|
||||
CEarthAngle<LATorLON> &CEarthAngle<LATorLON>::operator *=(double multiply)
|
||||
{
|
||||
this->PhysicalQuantities::CAngle::operator *=(multiply);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class LATorLON>
|
||||
bool CEarthAngle<LATorLON>::operator >(const CEarthAngle &latOrLon) const
|
||||
{
|
||||
return this->PhysicalQuantities::CAngle::operator >(latOrLon);
|
||||
}
|
||||
|
||||
template <class LATorLON>
|
||||
bool CEarthAngle<LATorLON>::operator <(const CEarthAngle &latOrLon) const
|
||||
{
|
||||
return this->PhysicalQuantities::CAngle::operator >(latOrLon);
|
||||
}
|
||||
|
||||
template <class LATorLON>
|
||||
bool CEarthAngle<LATorLON>::operator <=(const CEarthAngle &latOrLon) const
|
||||
{
|
||||
return this->PhysicalQuantities::CAngle::operator <=(latOrLon);
|
||||
}
|
||||
|
||||
template <class LATorLON>
|
||||
bool CEarthAngle<LATorLON>::operator >=(const CEarthAngle &latOrLon) const
|
||||
{
|
||||
return this->PhysicalQuantities::CAngle::operator >=(latOrLon);
|
||||
}
|
||||
|
||||
template <class LATorLON>
|
||||
LATorLON CEarthAngle<LATorLON>::operator +(const CEarthAngle &latOrLon) const
|
||||
{
|
||||
LATorLON l(*this);
|
||||
l += latOrLon;
|
||||
return l;
|
||||
}
|
||||
|
||||
template <class LATorLON>
|
||||
LATorLON CEarthAngle<LATorLON>::operator -(const CEarthAngle &latOrLon) const
|
||||
{
|
||||
LATorLON l(*this);
|
||||
l -= latOrLon;
|
||||
return l;
|
||||
}
|
||||
|
||||
template <class LATorLON>
|
||||
LATorLON CEarthAngle<LATorLON>::operator *(double multiply) const
|
||||
{
|
||||
LATorLON l(*this);
|
||||
l *= multiply;
|
||||
return l;
|
||||
}
|
||||
|
||||
template <class LATorLON>
|
||||
LATorLON CEarthAngle<LATorLON>::fromWgs84(const QString &wgsCoordinate)
|
||||
{
|
||||
// http://www.regular-expressions.info/floatingpoint.html
|
||||
const QString wgs = wgsCoordinate.simplified().trimmed();
|
||||
@@ -65,7 +135,35 @@ namespace BlackMisc
|
||||
return LATorLON(a);
|
||||
}
|
||||
|
||||
template <class LATorLON> CIcon CEarthAngle<LATorLON>::toIcon() const
|
||||
template <class LATorLON>
|
||||
CEarthAngle<LATorLON>::CEarthAngle()
|
||||
: CEarthAngle::CValueObject(0.0, BlackMisc::PhysicalQuantities::CAngleUnit::deg())
|
||||
{ }
|
||||
|
||||
template <class LATorLON>
|
||||
CEarthAngle<LATorLON>::CEarthAngle(double value, const BlackMisc::PhysicalQuantities::CAngleUnit &unit)
|
||||
: CEarthAngle::CValueObject(value, unit)
|
||||
{ }
|
||||
|
||||
template <class LATorLON>
|
||||
CEarthAngle<LATorLON>::CEarthAngle(const BlackMisc::PhysicalQuantities::CAngle &angle)
|
||||
: CEarthAngle::CValueObject(angle)
|
||||
{ }
|
||||
|
||||
template <class LATorLON>
|
||||
QString CEarthAngle<LATorLON>::convertToQString(bool i18n) const
|
||||
{
|
||||
return this->valueRoundedWithUnit(BlackMisc::PhysicalQuantities::CAngleUnit::deg(), 6, i18n);
|
||||
}
|
||||
|
||||
template <class LATorLON>
|
||||
LATorLON const *CEarthAngle<LATorLON>::derived() const { return static_cast<LATorLON const *>(this); }
|
||||
|
||||
template <class LATorLON>
|
||||
LATorLON *CEarthAngle<LATorLON>::derived() { return static_cast<LATorLON *>(this); }
|
||||
|
||||
template <class LATorLON>
|
||||
CIcon CEarthAngle<LATorLON>::toIcon() const
|
||||
{
|
||||
return BlackMisc::CIconList::iconByIndex(CIcons::GeoPosition);
|
||||
}
|
||||
|
||||
@@ -37,73 +37,33 @@ namespace BlackMisc
|
||||
{
|
||||
public:
|
||||
//! Plus operator +=
|
||||
CEarthAngle &operator +=(const CEarthAngle &latOrLon)
|
||||
{
|
||||
this->PhysicalQuantities::CAngle::operator +=(latOrLon);
|
||||
return *this;
|
||||
}
|
||||
CEarthAngle &operator +=(const CEarthAngle &latOrLon);
|
||||
|
||||
//! Minus operator-=
|
||||
CEarthAngle &operator -=(const CEarthAngle &latOrLon)
|
||||
{
|
||||
this->PhysicalQuantities::CAngle::operator -=(latOrLon);
|
||||
return *this;
|
||||
}
|
||||
CEarthAngle &operator -=(const CEarthAngle &latOrLon);
|
||||
|
||||
//! Multiply operator *=
|
||||
CEarthAngle operator *=(double multiply)
|
||||
{
|
||||
this->PhysicalQuantities::CAngle::operator *=(multiply);
|
||||
return *this;
|
||||
}
|
||||
CEarthAngle &operator *=(double multiply);
|
||||
|
||||
//! Greater operator >
|
||||
bool operator >(const CEarthAngle &latOrLon) const
|
||||
{
|
||||
return this->PhysicalQuantities::CAngle::operator >(latOrLon);
|
||||
}
|
||||
|
||||
bool operator >(const CEarthAngle &latOrLon) const;
|
||||
//! Less operator <
|
||||
bool operator <(const CEarthAngle &latOrLon) const
|
||||
{
|
||||
return this->PhysicalQuantities::CAngle::operator >(latOrLon);
|
||||
}
|
||||
bool operator <(const CEarthAngle &latOrLon) const;
|
||||
|
||||
//! Less equal operator <=
|
||||
bool operator <=(const CEarthAngle &latOrLon) const
|
||||
{
|
||||
return this->PhysicalQuantities::CAngle::operator <=(latOrLon);
|
||||
}
|
||||
bool operator <=(const CEarthAngle &latOrLon) const;
|
||||
|
||||
//! Greater equal operator >=
|
||||
bool operator >=(const CEarthAngle &latOrLon) const
|
||||
{
|
||||
return this->PhysicalQuantities::CAngle::operator >=(latOrLon);
|
||||
}
|
||||
bool operator >=(const CEarthAngle &latOrLon) const;
|
||||
|
||||
//! Plus operator +
|
||||
LATorLON operator +(const CEarthAngle &latOrLon) const
|
||||
{
|
||||
LATorLON l(*this);
|
||||
l += latOrLon;
|
||||
return l;
|
||||
}
|
||||
LATorLON operator +(const CEarthAngle &latOrLon) const;
|
||||
|
||||
//! Minus operator -
|
||||
LATorLON operator -(const CEarthAngle &latOrLon) const
|
||||
{
|
||||
LATorLON l(*this);
|
||||
l -= latOrLon;
|
||||
return l;
|
||||
}
|
||||
LATorLON operator -(const CEarthAngle &latOrLon) const;
|
||||
|
||||
//! Multiply operator *
|
||||
LATorLON operator *(double multiply) const
|
||||
{
|
||||
LATorLON l(*this);
|
||||
l *= multiply;
|
||||
return l;
|
||||
}
|
||||
LATorLON operator *(double multiply) const;
|
||||
|
||||
//! \copydoc CValueObject::toIcon
|
||||
CIcon toIcon() const override;
|
||||
@@ -117,30 +77,27 @@ namespace BlackMisc
|
||||
|
||||
protected:
|
||||
//! Default constructor
|
||||
CEarthAngle() : CEarthAngle::CValueObject(0.0, BlackMisc::PhysicalQuantities::CAngleUnit::deg()) {}
|
||||
CEarthAngle();
|
||||
|
||||
//! Init by double value
|
||||
CEarthAngle(double value, const BlackMisc::PhysicalQuantities::CAngleUnit &unit) : CEarthAngle::CValueObject(value, unit) {}
|
||||
CEarthAngle(double value, const BlackMisc::PhysicalQuantities::CAngleUnit &unit);
|
||||
|
||||
//! Init by CAngle value
|
||||
CEarthAngle(const BlackMisc::PhysicalQuantities::CAngle &angle) : CEarthAngle::CValueObject(angle) {}
|
||||
CEarthAngle(const BlackMisc::PhysicalQuantities::CAngle &angle);
|
||||
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
virtual QString convertToQString(bool i18n = false) const override
|
||||
{
|
||||
return this->valueRoundedWithUnit(BlackMisc::PhysicalQuantities::CAngleUnit::deg(), 6, i18n);
|
||||
}
|
||||
virtual QString convertToQString(bool i18n = false) const override;
|
||||
|
||||
private:
|
||||
//! Easy access to derived class (CRTP template parameter)
|
||||
LATorLON const *derived() const { return static_cast<LATorLON const *>(this); }
|
||||
LATorLON const *derived() const;
|
||||
|
||||
//! Easy access to derived class (CRTP template parameter)
|
||||
LATorLON *derived() { return static_cast<LATorLON *>(this); }
|
||||
LATorLON *derived();
|
||||
};
|
||||
|
||||
extern template class CEarthAngle<CLatitude>;
|
||||
extern template class CEarthAngle<CLongitude>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE CEarthAngle<CLatitude>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE CEarthAngle<CLongitude>;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,10 +61,10 @@ namespace BlackMisc
|
||||
CONTAINER &container();
|
||||
};
|
||||
|
||||
extern template class IGeoObjectList<BlackMisc::Aviation::CAtcStation, BlackMisc::Aviation::CAtcStationList>;
|
||||
extern template class IGeoObjectList<BlackMisc::Aviation::CAircraft, BlackMisc::Aviation::CAircraftList>;
|
||||
extern template class IGeoObjectList<BlackMisc::Aviation::CAirport, BlackMisc::Aviation::CAirportList>;
|
||||
extern template class IGeoObjectList<BlackMisc::Simulation::CSimulatedAircraft, BlackMisc::Simulation::CSimulatedAircraftList>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE IGeoObjectList<BlackMisc::Aviation::CAtcStation, BlackMisc::Aviation::CAtcStationList>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE IGeoObjectList<BlackMisc::Aviation::CAircraft, BlackMisc::Aviation::CAircraftList>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE IGeoObjectList<BlackMisc::Aviation::CAirport, BlackMisc::Aviation::CAirportList>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE IGeoObjectList<BlackMisc::Simulation::CSimulatedAircraft, BlackMisc::Simulation::CSimulatedAircraftList>;
|
||||
|
||||
//! List of objects with geo coordinates.
|
||||
template<class OBJ, class CONTAINER>
|
||||
@@ -92,10 +92,10 @@ namespace BlackMisc
|
||||
|
||||
};
|
||||
|
||||
extern template class IGeoObjectWithRelativePositionList<BlackMisc::Aviation::CAtcStation, BlackMisc::Aviation::CAtcStationList>;
|
||||
extern template class IGeoObjectWithRelativePositionList<BlackMisc::Aviation::CAircraft, BlackMisc::Aviation::CAircraftList>;
|
||||
extern template class IGeoObjectWithRelativePositionList<BlackMisc::Aviation::CAirport, BlackMisc::Aviation::CAirportList>;
|
||||
extern template class IGeoObjectWithRelativePositionList<BlackMisc::Simulation::CSimulatedAircraft, BlackMisc::Simulation::CSimulatedAircraftList>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE IGeoObjectWithRelativePositionList<BlackMisc::Aviation::CAtcStation, BlackMisc::Aviation::CAtcStationList>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE IGeoObjectWithRelativePositionList<BlackMisc::Aviation::CAircraft, BlackMisc::Aviation::CAircraftList>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE IGeoObjectWithRelativePositionList<BlackMisc::Aviation::CAirport, BlackMisc::Aviation::CAirportList>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE IGeoObjectWithRelativePositionList<BlackMisc::Simulation::CSimulatedAircraft, BlackMisc::Simulation::CSimulatedAircraftList>;
|
||||
|
||||
} //namespace
|
||||
} // namespace
|
||||
|
||||
@@ -16,11 +16,46 @@ namespace BlackMisc
|
||||
namespace PhysicalQuantities
|
||||
{
|
||||
|
||||
template <class MU, class PQ> CPhysicalQuantity<MU, PQ>::CPhysicalQuantity(double value, const MU &unit) :
|
||||
template <class MU, class PQ>
|
||||
MU CPhysicalQuantity<MU, PQ>::getUnit() const
|
||||
{
|
||||
return this->m_unit;
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
void CPhysicalQuantity<MU, PQ>::setUnit(const MU &unit)
|
||||
{
|
||||
this->m_unit = unit;
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
void CPhysicalQuantity<MU, PQ>::setUnitBySymbol(const QString &unitName)
|
||||
{
|
||||
this->m_unit = CMeasurementUnit::unitFromSymbol<MU>(unitName);
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
QString CPhysicalQuantity<MU, PQ>::getUnitSymbol() const { return this->m_unit.getSymbol(true); }
|
||||
|
||||
template <class MU, class PQ>
|
||||
CPhysicalQuantity<MU, PQ>::CPhysicalQuantity() :
|
||||
m_value(0.0), m_unit(MU::nullUnit())
|
||||
{ }
|
||||
|
||||
template <class MU, class PQ>
|
||||
CPhysicalQuantity<MU, PQ>::CPhysicalQuantity(double value, const MU &unit) :
|
||||
m_value(unit.isNull() ? 0.0 : value), m_unit(unit)
|
||||
{ }
|
||||
|
||||
template <class MU, class PQ> bool CPhysicalQuantity<MU, PQ>::operator ==(const CPhysicalQuantity<MU, PQ> &other) const
|
||||
template <class MU, class PQ>
|
||||
CPhysicalQuantity<MU, PQ>::CPhysicalQuantity(const QString &unitString) :
|
||||
m_value(0.0), m_unit(MU::nullUnit())
|
||||
{
|
||||
this->parseFromString(unitString);
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
bool CPhysicalQuantity<MU, PQ>::operator ==(const CPhysicalQuantity<MU, PQ> &other) const
|
||||
{
|
||||
if (this == &other) return true;
|
||||
|
||||
@@ -31,55 +66,94 @@ namespace BlackMisc
|
||||
return diff <= this->m_unit.getEpsilon();
|
||||
}
|
||||
|
||||
template <class MU, class PQ> bool CPhysicalQuantity<MU, PQ>::operator !=(const CPhysicalQuantity<MU, PQ> &other) const
|
||||
template <class MU, class PQ>
|
||||
bool CPhysicalQuantity<MU, PQ>::operator !=(const CPhysicalQuantity<MU, PQ> &other) const
|
||||
{
|
||||
return !((*this) == other);
|
||||
}
|
||||
|
||||
template <class MU, class PQ> CPhysicalQuantity<MU, PQ> &CPhysicalQuantity<MU, PQ>::operator +=(const CPhysicalQuantity<MU, PQ> &other)
|
||||
template <class MU, class PQ>
|
||||
CPhysicalQuantity<MU, PQ> &CPhysicalQuantity<MU, PQ>::operator +=(const CPhysicalQuantity<MU, PQ> &other)
|
||||
{
|
||||
this->m_value += other.value(this->m_unit);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class MU, class PQ> PQ CPhysicalQuantity<MU, PQ>::operator +(const PQ &other) const
|
||||
template <class MU, class PQ>
|
||||
PQ CPhysicalQuantity<MU, PQ>::operator +(const PQ &other) const
|
||||
{
|
||||
PQ copy(other);
|
||||
copy += *this;
|
||||
return copy;
|
||||
}
|
||||
|
||||
template <class MU, class PQ> void CPhysicalQuantity<MU, PQ>::addValueSameUnit(double value)
|
||||
template <class MU, class PQ>
|
||||
void CPhysicalQuantity<MU, PQ>::addValueSameUnit(double value)
|
||||
{
|
||||
this->m_value += value;
|
||||
}
|
||||
|
||||
template <class MU, class PQ> void CPhysicalQuantity<MU, PQ>::substractValueSameUnit(double value)
|
||||
template <class MU, class PQ>
|
||||
void CPhysicalQuantity<MU, PQ>::substractValueSameUnit(double value)
|
||||
{
|
||||
this->m_value -= value;
|
||||
}
|
||||
|
||||
template <class MU, class PQ> CPhysicalQuantity<MU, PQ> &CPhysicalQuantity<MU, PQ>::operator -=(const CPhysicalQuantity<MU, PQ> &other)
|
||||
template <class MU, class PQ>
|
||||
CPhysicalQuantity<MU, PQ> &CPhysicalQuantity<MU, PQ>::operator -=(const CPhysicalQuantity<MU, PQ> &other)
|
||||
{
|
||||
this->m_value -= other.value(this->m_unit);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class MU, class PQ> PQ CPhysicalQuantity<MU, PQ>::operator -(const PQ &other) const
|
||||
template <class MU, class PQ>
|
||||
PQ CPhysicalQuantity<MU, PQ>::operator -(const PQ &other) const
|
||||
{
|
||||
PQ copy = *derived();
|
||||
copy -= other;
|
||||
return copy;
|
||||
}
|
||||
|
||||
template <class MU, class PQ> void CPhysicalQuantity<MU, PQ>::marshallToDbus(QDBusArgument &argument) const
|
||||
template <class MU, class PQ>
|
||||
bool CPhysicalQuantity<MU, PQ>::isZeroEpsilonConsidered() const
|
||||
{
|
||||
return this->m_unit.isEpsilon(this->m_value);
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
bool CPhysicalQuantity<MU, PQ>::isPositiveWithEpsilonConsidered() const
|
||||
{
|
||||
return !this->isZeroEpsilonConsidered() && this->m_value > 0;
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
bool CPhysicalQuantity<MU, PQ>::isNegativeWithEpsilonConsidered() const
|
||||
{
|
||||
return !this->isZeroEpsilonConsidered() && this->m_value < 0;
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
void CPhysicalQuantity<MU, PQ>::makePositive()
|
||||
{
|
||||
if (this->m_value < 0) { this->m_value *= -1.0; }
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
void CPhysicalQuantity<MU, PQ>::makeNegative()
|
||||
{
|
||||
if (this->m_value > 0) { this->m_value *= -1.0; }
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
void CPhysicalQuantity<MU, PQ>::marshallToDbus(QDBusArgument &argument) const
|
||||
{
|
||||
argument << this->value(UnitClass::defaultUnit());
|
||||
argument << this->m_value;
|
||||
argument << this->m_unit;
|
||||
}
|
||||
|
||||
template <class MU, class PQ> void CPhysicalQuantity<MU, PQ>::unmarshallFromDbus(const QDBusArgument &argument)
|
||||
template <class MU, class PQ>
|
||||
void CPhysicalQuantity<MU, PQ>::unmarshallFromDbus(const QDBusArgument &argument)
|
||||
{
|
||||
double ignore;
|
||||
argument >> ignore;
|
||||
@@ -87,33 +161,38 @@ namespace BlackMisc
|
||||
argument >> this->m_unit;
|
||||
}
|
||||
|
||||
template <class MU, class PQ> CPhysicalQuantity<MU, PQ> &CPhysicalQuantity<MU, PQ>::operator *=(double factor)
|
||||
template <class MU, class PQ>
|
||||
CPhysicalQuantity<MU, PQ> &CPhysicalQuantity<MU, PQ>::operator *=(double factor)
|
||||
{
|
||||
this->m_value *= factor;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class MU, class PQ> PQ CPhysicalQuantity<MU, PQ>::operator *(double factor) const
|
||||
template <class MU, class PQ>
|
||||
PQ CPhysicalQuantity<MU, PQ>::operator *(double factor) const
|
||||
{
|
||||
PQ copy = *derived();
|
||||
copy *= factor;
|
||||
return copy;
|
||||
}
|
||||
|
||||
template <class MU, class PQ> CPhysicalQuantity<MU, PQ> &CPhysicalQuantity<MU, PQ>::operator /=(double divisor)
|
||||
template <class MU, class PQ>
|
||||
CPhysicalQuantity<MU, PQ> &CPhysicalQuantity<MU, PQ>::operator /=(double divisor)
|
||||
{
|
||||
this->m_value /= divisor;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class MU, class PQ> PQ CPhysicalQuantity<MU, PQ>::operator /(double divisor) const
|
||||
template <class MU, class PQ>
|
||||
PQ CPhysicalQuantity<MU, PQ>::operator /(double divisor) const
|
||||
{
|
||||
PQ copy = *derived();
|
||||
copy /= divisor;
|
||||
return copy;
|
||||
}
|
||||
|
||||
template <class MU, class PQ> bool CPhysicalQuantity<MU, PQ>::operator <(const CPhysicalQuantity<MU, PQ> &other) const
|
||||
template <class MU, class PQ>
|
||||
bool CPhysicalQuantity<MU, PQ>::operator <(const CPhysicalQuantity<MU, PQ> &other) const
|
||||
{
|
||||
if (*this == other) return false;
|
||||
if (this->isNull() || other.isNull()) return false;
|
||||
@@ -121,24 +200,28 @@ namespace BlackMisc
|
||||
return (this->m_value < other.value(this->m_unit));
|
||||
}
|
||||
|
||||
template <class MU, class PQ> bool CPhysicalQuantity<MU, PQ>::operator >(const CPhysicalQuantity<MU, PQ> &other) const
|
||||
template <class MU, class PQ>
|
||||
bool CPhysicalQuantity<MU, PQ>::operator >(const CPhysicalQuantity<MU, PQ> &other) const
|
||||
{
|
||||
return other < *this;
|
||||
}
|
||||
|
||||
template <class MU, class PQ> bool CPhysicalQuantity<MU, PQ>::operator >=(const CPhysicalQuantity<MU, PQ> &other) const
|
||||
template <class MU, class PQ>
|
||||
bool CPhysicalQuantity<MU, PQ>::operator >=(const CPhysicalQuantity<MU, PQ> &other) const
|
||||
{
|
||||
if (*this == other) return true;
|
||||
return *this > other;
|
||||
}
|
||||
|
||||
template <class MU, class PQ> bool CPhysicalQuantity<MU, PQ>::operator <=(const CPhysicalQuantity<MU, PQ> &other) const
|
||||
template <class MU, class PQ>
|
||||
bool CPhysicalQuantity<MU, PQ>::operator <=(const CPhysicalQuantity<MU, PQ> &other) const
|
||||
{
|
||||
if (*this == other) return true;
|
||||
return *this < other;
|
||||
}
|
||||
|
||||
template <class MU, class PQ> PQ &CPhysicalQuantity<MU, PQ>::switchUnit(const MU &newUnit)
|
||||
template <class MU, class PQ>
|
||||
PQ &CPhysicalQuantity<MU, PQ>::switchUnit(const MU &newUnit)
|
||||
{
|
||||
if (this->m_unit != newUnit)
|
||||
{
|
||||
@@ -148,38 +231,82 @@ namespace BlackMisc
|
||||
return *derived();
|
||||
}
|
||||
|
||||
template <class MU, class PQ> void CPhysicalQuantity<MU, PQ>::setValueSameUnit(double baseValue)
|
||||
template <class MU, class PQ>
|
||||
bool CPhysicalQuantity<MU, PQ>::isNull() const
|
||||
{
|
||||
return this->m_unit.isNull();
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
void CPhysicalQuantity<MU, PQ>::setNull()
|
||||
{
|
||||
this->m_unit = MU::nullUnit();
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
double CPhysicalQuantity<MU, PQ>::value() const
|
||||
{
|
||||
if (this->isNull())
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
return this->m_value;
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
void CPhysicalQuantity<MU, PQ>::setCurrentUnitValue(double value)
|
||||
{
|
||||
if (!this->isNull())
|
||||
{
|
||||
this->m_value = value;
|
||||
}
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
void CPhysicalQuantity<MU, PQ>::setValueSameUnit(double baseValue)
|
||||
{
|
||||
this->m_value = baseValue;
|
||||
}
|
||||
|
||||
template <class MU, class PQ> QString CPhysicalQuantity<MU, PQ>::valueRoundedWithUnit(const MU &unit, int digits, bool i18n) const
|
||||
template <class MU, class PQ>
|
||||
QString CPhysicalQuantity<MU, PQ>::valueRoundedWithUnit(const MU &unit, int digits, bool i18n) const
|
||||
{
|
||||
return unit.makeRoundedQStringWithUnit(this->value(unit), digits, i18n);
|
||||
}
|
||||
|
||||
template <class MU, class PQ> double CPhysicalQuantity<MU, PQ>::valueRounded(const MU &unit, int digits) const
|
||||
template <class MU, class PQ>
|
||||
QString CPhysicalQuantity<MU, PQ>::valueRoundedWithUnit(int digits, bool i18n) const
|
||||
{
|
||||
return this->valueRoundedWithUnit(this->m_unit, digits, i18n);
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
double CPhysicalQuantity<MU, PQ>::valueRounded(const MU &unit, int digits) const
|
||||
{
|
||||
return unit.roundValue(this->value(unit), digits);
|
||||
}
|
||||
|
||||
template <class MU, class PQ> int CPhysicalQuantity<MU, PQ>::valueInteger(const MU &unit) const
|
||||
template <class MU, class PQ>
|
||||
int CPhysicalQuantity<MU, PQ>::valueInteger(const MU &unit) const
|
||||
{
|
||||
double v = unit.roundValue(this->value(unit), 0);
|
||||
return static_cast<int>(v);
|
||||
}
|
||||
|
||||
template <class MU, class PQ> double CPhysicalQuantity<MU, PQ>::valueRounded(int digits) const
|
||||
template <class MU, class PQ>
|
||||
double CPhysicalQuantity<MU, PQ>::valueRounded(int digits) const
|
||||
{
|
||||
return this->valueRounded(this->m_unit, digits);
|
||||
}
|
||||
|
||||
template <class MU, class PQ> double CPhysicalQuantity<MU, PQ>::value(const MU &unit) const
|
||||
template <class MU, class PQ>
|
||||
double CPhysicalQuantity<MU, PQ>::value(const MU &unit) const
|
||||
{
|
||||
return unit.convertFrom(this->m_value, this->m_unit);
|
||||
}
|
||||
|
||||
template <class MU, class PQ> QString CPhysicalQuantity<MU, PQ>::convertToQString(bool i18n) const
|
||||
template <class MU, class PQ>
|
||||
QString CPhysicalQuantity<MU, PQ>::convertToQString(bool i18n) const
|
||||
{
|
||||
if (this->isNull())
|
||||
{
|
||||
@@ -188,7 +315,8 @@ namespace BlackMisc
|
||||
return this->valueRoundedWithUnit(this->getUnit(), -1, i18n);
|
||||
}
|
||||
|
||||
template <class MU, class PQ> uint CPhysicalQuantity<MU, PQ>::getValueHash() const
|
||||
template <class MU, class PQ>
|
||||
uint CPhysicalQuantity<MU, PQ>::getValueHash() const
|
||||
{
|
||||
QList<uint> hashs;
|
||||
// there is no double qHash
|
||||
@@ -197,7 +325,8 @@ namespace BlackMisc
|
||||
return BlackMisc::calculateHash(hashs, "PQ");
|
||||
}
|
||||
|
||||
template <class MU, class PQ> QJsonObject CPhysicalQuantity<MU, PQ>::toJson() const
|
||||
template <class MU, class PQ>
|
||||
QJsonObject CPhysicalQuantity<MU, PQ>::toJson() const
|
||||
{
|
||||
QJsonObject json;
|
||||
json.insert("value", QJsonValue(this->m_value));
|
||||
@@ -205,24 +334,28 @@ namespace BlackMisc
|
||||
return json;
|
||||
}
|
||||
|
||||
template <class MU, class PQ> void CPhysicalQuantity<MU, PQ>::convertFromJson(const QJsonObject &json)
|
||||
template <class MU, class PQ>
|
||||
void CPhysicalQuantity<MU, PQ>::convertFromJson(const QJsonObject &json)
|
||||
{
|
||||
const QString unitSymbol = json.value("unit").toString();
|
||||
this->setUnitBySymbol(unitSymbol);
|
||||
this->m_value = json.value("value").toDouble();
|
||||
}
|
||||
|
||||
template <class MU, class PQ> void CPhysicalQuantity<MU, PQ>::parseFromString(const QString &value, CPqString::SeparatorMode mode)
|
||||
template <class MU, class PQ>
|
||||
void CPhysicalQuantity<MU, PQ>::parseFromString(const QString &value, CPqString::SeparatorMode mode)
|
||||
{
|
||||
*this = CPqString::parse<PQ>(value, mode);
|
||||
}
|
||||
|
||||
template <class MU, class PQ> void CPhysicalQuantity<MU, PQ>::parseFromString(const QString &value)
|
||||
template <class MU, class PQ>
|
||||
void CPhysicalQuantity<MU, PQ>::parseFromString(const QString &value)
|
||||
{
|
||||
*this = CPqString::parse<PQ>(value, CPqString::SeparatorsCLocale);
|
||||
}
|
||||
|
||||
template <class MU, class PQ> CVariant CPhysicalQuantity<MU, PQ>::propertyByIndex(const CPropertyIndex &index) const
|
||||
template <class MU, class PQ>
|
||||
CVariant CPhysicalQuantity<MU, PQ>::propertyByIndex(const CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return this->toCVariant(); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
@@ -247,7 +380,8 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
template <class MU, class PQ> void CPhysicalQuantity<MU, PQ>::setPropertyByIndex(const CVariant &variant, const CPropertyIndex &index)
|
||||
template <class MU, class PQ>
|
||||
void CPhysicalQuantity<MU, PQ>::setPropertyByIndex(const CVariant &variant, const CPropertyIndex &index)
|
||||
{
|
||||
if (index.isMyself())
|
||||
{
|
||||
@@ -276,7 +410,8 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
template <class MU, class PQ> int CPhysicalQuantity<MU, PQ>::compareImpl(const PQ &a, const PQ &b)
|
||||
template <class MU, class PQ>
|
||||
int CPhysicalQuantity<MU, PQ>::compareImpl(const PQ &a, const PQ &b)
|
||||
{
|
||||
if (a.isNull() > b.isNull()) { return -1; }
|
||||
if (a.isNull() < b.isNull()) { return 1; }
|
||||
@@ -286,6 +421,18 @@ namespace BlackMisc
|
||||
else { return 0; }
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
PQ const *CPhysicalQuantity<MU, PQ>::derived() const
|
||||
{
|
||||
return static_cast<PQ const *>(this);
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
PQ *CPhysicalQuantity<MU, PQ>::derived()
|
||||
{
|
||||
return static_cast<PQ *>(this);
|
||||
}
|
||||
|
||||
// see here for the reason of thess forward instantiations
|
||||
// http://www.parashift.com/c++-faq/separate-template-class-defn-from-decl.html
|
||||
template class CPhysicalQuantity<CLengthUnit, CLength>;
|
||||
|
||||
@@ -76,53 +76,37 @@ namespace BlackMisc
|
||||
};
|
||||
|
||||
//! Unit
|
||||
MU getUnit() const { return this->m_unit; }
|
||||
MU getUnit() const;
|
||||
|
||||
/*!
|
||||
* \brief Simply set unit, do no calclulate conversion
|
||||
* \sa switchUnit
|
||||
*/
|
||||
void setUnit(const MU &unit) { this->m_unit = unit; }
|
||||
void setUnit(const MU &unit);
|
||||
|
||||
//! Set unit by string
|
||||
void setUnitBySymbol(const QString &unitName)
|
||||
{
|
||||
this->m_unit = CMeasurementUnit::unitFromSymbol<MU>(unitName);
|
||||
}
|
||||
void setUnitBySymbol(const QString &unitName);
|
||||
|
||||
//! Unit
|
||||
QString getUnitSymbol() const { return this->m_unit.getSymbol(true); }
|
||||
QString getUnitSymbol() const;
|
||||
|
||||
//! Change unit, and convert value to maintain the same quantity
|
||||
PQ &switchUnit(const MU &newUnit);
|
||||
|
||||
//! Is quantity null?
|
||||
bool isNull() const { return this->m_unit.isNull(); }
|
||||
bool isNull() const;
|
||||
|
||||
//! Set null
|
||||
void setNull() { this->m_unit = MU::nullUnit(); }
|
||||
void setNull();
|
||||
|
||||
//! Value in given unit
|
||||
double value(const MU &unit) const;
|
||||
|
||||
//! Value in current unit
|
||||
double value() const
|
||||
{
|
||||
if (this->isNull())
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
return this->m_value;
|
||||
}
|
||||
double value() const;
|
||||
|
||||
//! Set value in current unit
|
||||
void setCurrentUnitValue(double value)
|
||||
{
|
||||
if (!this->isNull())
|
||||
{
|
||||
this->m_value = value;
|
||||
}
|
||||
}
|
||||
void setCurrentUnitValue(double value);
|
||||
|
||||
//! Rounded value in given unit
|
||||
double valueRounded(const MU &unit, int digits = -1) const;
|
||||
@@ -137,10 +121,7 @@ namespace BlackMisc
|
||||
QString valueRoundedWithUnit(const MU &unit, int digits = -1, bool i18n = false) const;
|
||||
|
||||
//! Value to QString with the current unit, e.g. "5.00m"
|
||||
QString valueRoundedWithUnit(int digits = -1, bool i18n = false) const
|
||||
{
|
||||
return this->valueRoundedWithUnit(this->m_unit, digits, i18n);
|
||||
}
|
||||
QString valueRoundedWithUnit(int digits = -1, bool i18n = false) const;
|
||||
|
||||
//! Change value without changing unit
|
||||
void setValueSameUnit(double value);
|
||||
@@ -197,31 +178,19 @@ namespace BlackMisc
|
||||
PQ operator -(const PQ &other) const;
|
||||
|
||||
//! Quantity value <= epsilon
|
||||
bool isZeroEpsilonConsidered() const { return this->m_unit.isEpsilon(this->m_value); }
|
||||
bool isZeroEpsilonConsidered() const;
|
||||
|
||||
//! Value >= 0 epsilon considered
|
||||
bool isPositiveWithEpsilonConsidered() const
|
||||
{
|
||||
return !this->isZeroEpsilonConsidered() && this->m_value > 0;
|
||||
}
|
||||
bool isPositiveWithEpsilonConsidered() const;
|
||||
|
||||
//! Value <= 0 epsilon considered
|
||||
bool isNegativeWithEpsilonConsidered() const
|
||||
{
|
||||
return !this->isZeroEpsilonConsidered() && this->m_value < 0;
|
||||
}
|
||||
bool isNegativeWithEpsilonConsidered() const;
|
||||
|
||||
//! Make value always positive
|
||||
void makePositive()
|
||||
{
|
||||
if (this->m_value < 0) { this->m_value *= -1.0; }
|
||||
}
|
||||
void makePositive();
|
||||
|
||||
//! Make value always negative
|
||||
void makeNegative()
|
||||
{
|
||||
if (this->m_value > 0) { this->m_value *= -1.0; }
|
||||
}
|
||||
void makeNegative();
|
||||
|
||||
//! \copydoc CValueObject::marshallToDbus
|
||||
virtual void marshallToDbus(QDBusArgument &argument) const override;
|
||||
@@ -254,16 +223,13 @@ namespace BlackMisc
|
||||
|
||||
//! Default constructor
|
||||
//! \todo Remove as part of MS' CValueObject refactoring
|
||||
CPhysicalQuantity() : m_value(0.0), m_unit(MU::nullUnit()) {}
|
||||
CPhysicalQuantity();
|
||||
|
||||
//! Constructor with double
|
||||
CPhysicalQuantity(double value, const MU &unit);
|
||||
|
||||
//! Constructor by parsed string, e.g. 10m
|
||||
CPhysicalQuantity(const QString &unitString) : m_value(0.0), m_unit(MU::nullUnit())
|
||||
{
|
||||
this->parseFromString(unitString);
|
||||
}
|
||||
CPhysicalQuantity(const QString &unitString);
|
||||
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
virtual QString convertToQString(bool i18n = false) const override;
|
||||
@@ -279,21 +245,21 @@ namespace BlackMisc
|
||||
static int compareImpl(const PQ &, const PQ &);
|
||||
|
||||
//! Easy access to derived class (CRTP template parameter)
|
||||
PQ const *derived() const { return static_cast<PQ const *>(this); }
|
||||
PQ const *derived() const;
|
||||
|
||||
//! Easy access to derived class (CRTP template parameter)
|
||||
PQ *derived() { return static_cast<PQ *>(this); }
|
||||
PQ *derived();
|
||||
};
|
||||
|
||||
extern template class CPhysicalQuantity<CLengthUnit, CLength>;
|
||||
extern template class CPhysicalQuantity<CPressureUnit, CPressure>;
|
||||
extern template class CPhysicalQuantity<CFrequencyUnit, CFrequency>;
|
||||
extern template class CPhysicalQuantity<CMassUnit, CMass>;
|
||||
extern template class CPhysicalQuantity<CTemperatureUnit, CTemperature>;
|
||||
extern template class CPhysicalQuantity<CSpeedUnit, CSpeed>;
|
||||
extern template class CPhysicalQuantity<CAngleUnit, CAngle>;
|
||||
extern template class CPhysicalQuantity<CTimeUnit, CTime>;
|
||||
extern template class CPhysicalQuantity<CAccelerationUnit, CAcceleration>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE CPhysicalQuantity<CLengthUnit, CLength>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE CPhysicalQuantity<CPressureUnit, CPressure>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE CPhysicalQuantity<CFrequencyUnit, CFrequency>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE CPhysicalQuantity<CMassUnit, CMass>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE CPhysicalQuantity<CTemperatureUnit, CTemperature>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE CPhysicalQuantity<CSpeedUnit, CSpeed>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE CPhysicalQuantity<CAngleUnit, CAngle>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE CPhysicalQuantity<CTimeUnit, CTime>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE CPhysicalQuantity<CAccelerationUnit, CAcceleration>;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,10 +101,10 @@ namespace BlackMisc
|
||||
CONTAINER &container();
|
||||
};
|
||||
|
||||
extern template class ITimestampObjectList<BlackMisc::Aviation::CAircraftSituation, BlackMisc::Aviation::CAircraftSituationList>;
|
||||
extern template class ITimestampObjectList<BlackMisc::Aviation::CAircraftParts, BlackMisc::Aviation::CAircraftPartsList>;
|
||||
extern template class ITimestampObjectList<BlackMisc::Network::CTextMessage, BlackMisc::Network::CTextMessageList>;
|
||||
extern template class ITimestampObjectList<BlackMisc::CStatusMessage, BlackMisc::CStatusMessageList>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE ITimestampObjectList<BlackMisc::Aviation::CAircraftSituation, BlackMisc::Aviation::CAircraftSituationList>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE ITimestampObjectList<BlackMisc::Aviation::CAircraftParts, BlackMisc::Aviation::CAircraftPartsList>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE ITimestampObjectList<BlackMisc::Network::CTextMessage, BlackMisc::Network::CTextMessageList>;
|
||||
extern template class BLACKMISC_EXPORT_TEMPLATE ITimestampObjectList<BlackMisc::CStatusMessage, BlackMisc::CStatusMessageList>;
|
||||
|
||||
} //namespace
|
||||
|
||||
|
||||
Reference in New Issue
Block a user