OSOptionalQuantity ScheduleTypeLimits_Impl::getQuantityFromDouble(unsigned index, boost::optional<double> value, bool returnIP) const { OptionalUnit siUnits = ScheduleTypeLimits::units(unitType(),false); OS_ASSERT(siUnits); OptionalUnit units = siUnits->clone(); if (returnIP) { units = ScheduleTypeLimits::units(unitType(),true); OS_ASSERT(units); } if (value) { Quantity siQuantity(*value,*siUnits); if (!returnIP || (siUnits.get() == units.get())) { return OSOptionalQuantity(siQuantity); } else { OptionalQuantity result = convert(siQuantity,*units); OS_ASSERT(result); return OSOptionalQuantity(*result); } } return OSOptionalQuantity(*units); }
boost::optional<Quantity> ScheduleBase_Impl::toQuantity(double value, bool returnIP) const { OptionalQuantity result; if (OptionalScheduleTypeLimits scheduleTypeLimits = this->scheduleTypeLimits()) { if (OptionalUnit siUnits = ScheduleTypeLimits::units(scheduleTypeLimits->unitType(),false)) { result = Quantity(value,*siUnits); if (returnIP) { OptionalUnit ipUnits = ScheduleTypeLimits::units(scheduleTypeLimits->unitType(),returnIP); OS_ASSERT(ipUnits); if (ipUnits.get() != siUnits.get()) { result = convert(*result,*ipUnits); } } } } return result; }
OSQuantityVector ScheduleBase_Impl::getValues(bool returnIP) const { OSQuantityVector result; if (OptionalScheduleTypeLimits scheduleTypeLimits = this->scheduleTypeLimits()) { if (OptionalUnit siUnits = ScheduleTypeLimits::units(scheduleTypeLimits->unitType(),false)) { result = OSQuantityVector(*siUnits,values()); if (returnIP) { OptionalUnit ipUnits = ScheduleTypeLimits::units(scheduleTypeLimits->unitType(),returnIP); OS_ASSERT(ipUnits); if (ipUnits.get() != siUnits.get()) { result = convert(result,*ipUnits); } } } } return result; }