Adding a time unit

To represent some other form of time--for example, sound samples, video frames, or foot taps--you derive new classes from TTime. To implement a new time unit:

  1. Provide a conversion to picoseconds for use by TTime::SetPicoseconds and the TTime picoseconds constructor.
    Typically, you provide constants that define the number of picoseconds per unit and the number of units per second.
  2. Provide a constructor that takes a const TTime& to support conversion between the TTime classes.
    Typically, you also provide a constructor that takes a number of time units.
  3. Provide a function that returns the number of units an object represents.
    For example, the GetDays function of the TDays instance aWeek would return the number of days aWeek represents.
For example, the MIDI system uses a dimensionless time unit called a tick. This time unit is implemented as a TMIDITick class derived from TTime. TMIDITick provides:


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker