Class DTime



Provides the current time at a millisecond resolution. Each DTime stores a time value that can be used to determine how much time has elapsed:

DTime myTime;

//Store the current time
myTime.updateTime();

//Sleep for half a second
DEngine::sleep(500);

//Output the difference between the stored and current time
cout << myTime.timeElapsed() << endl;


DTime(void)

The default constructor.


DTime(const DTime &source)

Creates an object that is an copy of source.


DTime& operator= (const DTime &source)

Sets this object to be a copy of source.


void addTime(uint32_t amount)

Adds amount milliseconds to the stored time.


uint16_t getMilliseconds(void)

Returns the milliseconds component of the stored time.


uint32_t getSeconds(void)

Returns the seconds component of the stored time.


void setTime(uint32_t seconds, uint16_t milliseconds)

Sets the stored time to the specified number of seconds and milliseconds.


uint32_t timeElapsed(void)

Returns the difference between the current time and the stored time in milliseconds.


void updateTime(void)

Sets the stored time to the current time.


void useEngine(DEngine *engine)

Normally, the timeElapsed and updateTime functions perform a system call to get the current system time. This is a relatively expensive operation, and can be inefficient if there are hundreds of DTime objects. The DEngine stores the current time each time its update function is called. Any DTime objects that are registered with that engine will use its stored value instead of retrieving the system time themselves. Set engine to NULL to return to the DTime's default behaviour.





















Back to class reference