示例#1
0
 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);
 }
示例#2
0
 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;
 }
示例#3
0
 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;
 }