1 module dunitconversion.conversionrule; 2 3 import dunitconversion.linearfunction; 4 5 /** 6 * The ConversionRule struct represents a unit conversion rule from 7 * base unit to second unit within the specified family. Note that in UnitConvertor 8 * class each family can be represented with the single base unit. In other words you 9 * can't have two unit conversion rules with the same family but different base units 10 */ 11 struct ConversionRule { 12 13 @disable this(); 14 15 /** 16 * Constructs a rule 17 */ 18 this(string family, string baseUnit, string unit, LinearFunction convertFunction) { 19 this.family = family; 20 this.baseUnit = baseUnit; 21 this.unit = unit; 22 this.convertFunction = convertFunction; 23 } 24 25 string family; /// Family name for this pair of units, like length, speed 26 string baseUnit; /// Base unit for this family 27 string unit; /// Unit to convert to 28 LinearFunction convertFunction; /// Linear function to perform conversion from base unit to unit 29 }