Classes

The following classes are available globally.

  • A base class for all clock objects. New clock classes must subclass the ClockBase class.

    See more

    Declaration

    Objective-C

    @interface ClockBase : NSObject <ClockProtocol>

    Swift

    class ClockBase : NSObject, ClockProtocol
  • CorrelatedClock is a clock locked to the tick count of the parent clock by a correlation and frequency setting. Correlation is a tuple (parentTicks, selfTicks). When the parent clock ticks property has the value parentTicks, the ticks property of this clock shall have the value selfTicks.

    @discussion You can alter the correlation and tickRate and speed of this clock dynamically. Changes to tickRate and speed will not shift the point of correlation. This means that a change in tickRate or speed will probably cause the current tick value of the clock to jump. The amount it jumps by will be proportional to the distance the current time is from the point of correlation.

    If you want a speed change to only affect the ticks from a particular point (e.g. the current tick value) onwards then you must re-base the correlation.

    Warning

    The maths to calculate and convert tick values will be performed, by default, as integer maths unless the parameters controlling the clock (tickRate etc) are floating point, or the ticks property of the parent clock supplies floating point values.

    There is a function provided to do that in some circumstances:

    @code c = CorrelatedClock(parentClock=parent, tickRate=1000, correlation=(50,78))

        ... time passes ...
    
        // now freeze the clock AT ITS CURRENT TICK VALUE
    
        c.rebaseCorrelationAtTicks(c.ticks)
        c.speed = 0
    
        // now resume the clock but at half speed, but again without the tick value jumping
        c.correlation = ( parent.ticks, c.ticks )
        c.speed = 0.5;
    
    See more

    Declaration

    Objective-C

    @interface CorrelatedClock : ClockBase

    Swift

    class CorrelatedClock : ClockBase
  • A class to calculate monotinic time from the host’s system clock

    See more

    Declaration

    Objective-C

    @interface MonotonicTime : NSObject

    Swift

    class MonotonicTime : NSObject
  • A clock whose tick offset and speed can be adjusted on the fly. Must be based on another clock, a parent clock. A tunable clock specifies a correlation relationship with respect to its parent clock. This correlation specifies a tick value, a tick rate and a speed value for this clock and a tick value from the parent clock as from which this relationship applies.

    Advancement of time of this clock is based on the tick count and rates reported by the supplied parent clock. If you adjust the tickRate or speed, then the change is applied going forward from the moment it is made. E.g. if you are observing the rate of increase of the ticks property, then doubling the speed wil cause the ticks property to start increasing faster but will not cause it to suddenly jump value.

    See more

    Declaration

    Objective-C

    @interface TunableClock : ClockBase

    Swift

    class TunableClock : ClockBase