1 module chimpfella.measurement; 2 public import chimpfella.measurement.phobostimer; 3 import sumtype; 4 5 public alias Measurements = SumType!(PhobosTimer); 6 public alias StateTypes = SumType!(PhobosTimer.StateT); 7 8 //SumType operations are spelled out explicitly to make it more obvious 9 10 Measurements toMeasurement(T)(T x) pure 11 { 12 Measurements tmp; 13 tmp = x; 14 return tmp; 15 } 16 17 @safe StateTypes getState(Measurements fromThis) 18 { 19 return StateTypes(fromThis.match!((ref PhobosTimer f) => f.getState())); 20 } 21 22 @safe auto getHeader(Measurements fromThis) 23 { 24 return (fromThis.match!((ref PhobosTimer f) => f.getHeader())); 25 } 26 @safe auto procMeas(alias func)(ref const Measurements fromThis) 27 { 28 return fromThis.match!((const ref PhobosTimer f) => func(f)); 29 } 30 @safe auto procState(alias func)(ref StateTypes fromThis) 31 { 32 return fromThis.match!((ref PhobosTimer.StateT f) => func(f)); 33 }