Ref T261, utility functions in value classes

* set offset values
* do not change PQs if PQ is null
* sorted by callsign
This commit is contained in:
Klaus Basan
2018-05-07 01:51:45 +02:00
committed by Roland Winklmeier
parent 3f4cb7529c
commit 8e3b55b4ca
9 changed files with 47 additions and 15 deletions

View File

@@ -143,6 +143,7 @@ namespace BlackMisc
template <class MU, class PQ>
const PQ &CPhysicalQuantity<MU, PQ>::makePositive()
{
if (this->isNull() || m_value == 0) { return *this->derived(); }
if (m_value < 0) { m_value *= -1.0; }
return *this->derived();
}
@@ -150,6 +151,7 @@ namespace BlackMisc
template <class MU, class PQ>
const PQ &CPhysicalQuantity<MU, PQ>::makeNegative()
{
if (this->isNull() || m_value == 0) { return *this->derived(); }
if (m_value > 0) { m_value *= -1.0; }
return *this->derived();
}
@@ -157,6 +159,7 @@ namespace BlackMisc
template<class MU, class PQ>
PQ CPhysicalQuantity<MU, PQ>::abs() const
{
if (this->isNull() || m_value == 0) { return *this->derived(); }
if (m_value >= 0) { return *this->derived(); }
PQ copy(*this->derived());
return copy.makePositive();