mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-03 16:25:54 +08:00
Ref T231, Ref T238 maxValue for PQs
Remark: max() as function name caused compile errors
This commit is contained in:
@@ -19,7 +19,6 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
namespace PhysicalQuantities
|
namespace PhysicalQuantities
|
||||||
{
|
{
|
||||||
|
|
||||||
//! Physical unit length (length)
|
//! Physical unit length (length)
|
||||||
class BLACKMISC_EXPORT CLength : public CPhysicalQuantity<CLengthUnit, CLength>
|
class BLACKMISC_EXPORT CLength : public CPhysicalQuantity<CLengthUnit, CLength>
|
||||||
{
|
{
|
||||||
@@ -33,7 +32,6 @@ namespace BlackMisc
|
|||||||
//! \copydoc CPhysicalQuantity(const QString &unitString)
|
//! \copydoc CPhysicalQuantity(const QString &unitString)
|
||||||
CLength(const QString &unitString) : CPhysicalQuantity(unitString) {}
|
CLength(const QString &unitString) : CPhysicalQuantity(unitString) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|
||||||
|
|||||||
@@ -357,6 +357,22 @@ namespace BlackMisc
|
|||||||
return this->valueRoundedWithUnit(this->getUnit(), -1, i18n);
|
return this->valueRoundedWithUnit(this->getUnit(), -1, i18n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class MU, class PQ>
|
||||||
|
const PQ &CPhysicalQuantity<MU, PQ>::maxValue(const PQ &pq1, const PQ &pq2)
|
||||||
|
{
|
||||||
|
if (pq1.isNull()) { return pq2; }
|
||||||
|
if (pq2.isNull()) { return pq1; }
|
||||||
|
return pq1 > pq2 ? pq1 : pq2;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class MU, class PQ>
|
||||||
|
const PQ &CPhysicalQuantity<MU, PQ>::minValue(const PQ &pq1, const PQ &pq2)
|
||||||
|
{
|
||||||
|
if (pq1.isNull()) { return pq2; }
|
||||||
|
if (pq2.isNull()) { return pq1; }
|
||||||
|
return pq1 < pq2 ? pq1 : pq2;
|
||||||
|
}
|
||||||
|
|
||||||
template <class MU, class PQ>
|
template <class MU, class PQ>
|
||||||
uint CPhysicalQuantity<MU, PQ>::getValueHash() const
|
uint CPhysicalQuantity<MU, PQ>::getValueHash() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -234,6 +234,12 @@ namespace BlackMisc
|
|||||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||||
QString convertToQString(bool i18n = false) const;
|
QString convertToQString(bool i18n = false) const;
|
||||||
|
|
||||||
|
//! Maximum of 2 quantities
|
||||||
|
static const PQ &maxValue(const PQ &pq1, const PQ &pq2);
|
||||||
|
|
||||||
|
//! Minimum of 2 quantities
|
||||||
|
static const PQ &minValue(const PQ &pq1, const PQ &pq2);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! Constructor with double
|
//! Constructor with double
|
||||||
CPhysicalQuantity(double value, MU unit);
|
CPhysicalQuantity(double value, MU unit);
|
||||||
|
|||||||
Reference in New Issue
Block a user