refs #126 null unit infrastructure, a sentinel to mark an uninitialized or unused physical quantity

This commit is contained in:
Mathew Sutcliffe
2014-02-18 18:36:49 +00:00
parent afc494ee5e
commit 8b1ef4345d
4 changed files with 151 additions and 2 deletions

View File

@@ -39,8 +39,7 @@ namespace BlackMisc
*/
double CMeasurementUnit::convertFrom(double value, const CMeasurementUnit &unit) const
{
Q_ASSERT(this->m_converter);
Q_ASSERT(unit.m_converter);
if (this->isNull() || unit.isNull()) return -1; // models the previous behaviour of using -1 as a sentinel value
if (this->m_converter == unit.m_converter) return value;
return this->m_converter->fromDefault(unit.m_converter->toDefault(value));
}