ClockBase
@interface ClockBase : NSObject <ClockProtocol>
A base class for all clock objects. New clock classes must subclass the ClockBase class.
-
A parent clock for this clock.
Declaration
Objective-C
@property (readwrite, strong, nonatomic) ClockBase *parent;Swift
var parent: ClockBase! { get set } -
this clock’s tickrate in number of ticks per second (required)
Declaration
Objective-C
@property (assign, readwrite, nonatomic) uint64_t tickRate;Swift
var tickRate: UInt64 { get set } -
this clock’s speed. Specifies how time is mapped to child time space from the parent time space. (required) For example, if speed is 2.0 local time progresses twice as fast as parent time. Defaults to 1.0.
Declaration
Objective-C
@property (assign, readwrite, nonatomic) float speed;Swift
var speed: Float { get set } -
Sets or provides the availability of this clock.
Declaration
Objective-C
@property (assign, readwrite, nonatomic) BOOL available;Swift
var available: Bool { get set } -
A clock error’s static error component in nano seconds. In the simplest of cases, e.g. for a system clock this is the system clock’s precision. In other clocks, this will include other non-time-varying sources of error e.g. for WallClock, the RTT
Declaration
Objective-C
@property (assign, readwrite, nonatomic) int64_t staticError;Swift
var staticError: Int64 { get set } -
this clock’s time-varying error. This is the rate at which the error for this clock grows. Specified in ppm (parts per million). A clock’s errorRate is the sum of its errorRate and the errorRate of its parent clock. For a SystemClock, this is equal to the frequency error.
Declaration
Objective-C
@property (getter=errorRate, assign, readwrite, nonatomic) uint32_t errorRate;Swift
var errorRate: UInt32 { get set } -
Time in ticks on clock’s timeline from which staticError and errorRate applies. In clocks where there are offset readjustments, the error parameters (staticError and errorRate) are updated at the time of adjustment and only apply from that time onwards.
Declaration
Objective-C
@property (assign, readwrite, nonatomic) int64_t errorTicksFrom;Swift
var errorTicksFrom: Int64 { get set } -
Returns the ‘effective speed’ of this clock. This is equal to multiplying together the speed properties of this clock and all of the parents up to the root clock
Declaration
Objective-C
- (float)getEffectiveSpeed;Swift
func getEffectiveSpeed() -> FloatReturn Value
Returns the ‘effective speed’ of this clock
-
Compute time in seconds from the tick value and this clock’s tick rate
Declaration
Objective-C
- (Float64)computeTime:(int64_t)ticks;Swift
func computeTime(_ ticks: Int64) -> Float64Parameters
tickstime in ticks
Return Value
time in seconds
-
Compute time in nanoseconds from the tick value and this clock’s tick rate
Declaration
Objective-C
- (Float64)computeTimeNanos:(int64_t)ticks;Swift
func computeTimeNanos(_ ticks: Int64) -> Float64Parameters
tickstime in ticks
Return Value
time in nano secs
-
Method to convert from a tick value for this clock to the equivalent tick value (representing the same point in time) for the parent clock.
Implementations should use the parent clock’s
tickRateandspeedproperties when performing the conversionDeclaration
Objective-C
- (int64_t)toParentTicks:(int64_t)ticks;Swift
func toParentTicks(_ ticks: Int64) -> Int64Parameters
ticksa tick value for this clock
Return Value
The specified tick value of this clock converted to the timescale of the parent clock
-
- Method to convert from a tick value for this clock’s parent to the equivalent tick value (representing the same point in time) for this clock.
Implementations should use this clock’s
tickRateandspeedproperties when performing the conversion. * - - parameter: ticks a tick value for this clock *
- - returns: The specified tick value for the parent clock converted to the timescale of this clock.
Declaration
Objective-C
- (int64_t)fromParentTicks:(int64_t)ticks;Swift
func fromParentTicks(_ ticks: Int64) -> Int64Parameters
ticksa tick value for this clock
Return Value
The specified tick value for the parent clock converted to the timescale of this clock.
- Method to convert from a tick value for this clock’s parent to the equivalent tick value (representing the same point in time) for this clock.
Implementations should use this clock’s
-
Converts a tick value for this clock into a tick value corresponding to the timescale of another clock.
Declaration
Objective-C
- (int64_t)toOtherClock:(ClockBase *)otherClock Ticks:(int64_t)ticks WithError:(NSError **)error;Swift
func toOtherClock(_ otherClock: ClockBase!, ticks: Int64, withError error: NSErrorPointer) -> Int64Parameters
otherClockA ClockBase object representing another clock.
ticksA time (tick value) for this clock
errorA pointer to an NSError pointer parameter
Return Value
The tick value of the
otherClockthat represents the same moment in time. Users should check the value returned inerror. Error codes are specified in ClockErrors.h. -
measure this clock’s precision
Declaration
Objective-C
- (double)estimatePrecision:(NSUInteger)sampleSize;Swift
func estimatePrecision(_ sampleSize: UInt) -> DoubleParameters
sampleSizenumber of samples for calculation
Return Value
measured precision
-
Get the error of the clock reading at specified time. A clock reading’s error value has a static error component and another error component which grows over time.
Declaration
Objective-C
- (int64_t)dispersionAtTime:(int64_t)timeInNanos;Swift
func dispersion(atTime timeInNanos: Int64) -> Int64Parameters
timetime value in nanoseconds
Return Value
error of this clock at time ‘timeInNanos’
-
Add an observer for clock state changes. Uses IOS’s Key-Value-Coding mechanism.
Declaration
Objective-C
- (void)addObserver:(id)observer context:(void *)context;Swift
func addObserver(_ observer: Any!, context: UnsafeMutableRawPointer!)Parameters
observerthe observer object to be notified
contextA context to differentiate between observed clock objects
-
Remove observer from this clock object
Declaration
Objective-C
- (void)removeObserver:(id)observer Context:(void *)context;Swift
func removeObserver(_ observer: Any!, context: UnsafeMutableRawPointer!)Parameters
observerobserver to unregister
contextcontext to differentiate between clock objects
View on GitHub
ClockBase Class Reference