Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages | Examples

ArTime Class Reference

#include <ariaUtil.h>

List of all members.


Detailed Description

A class for time readings and measuring durations.

This class is for timing durations or time between events. The time values it stores are relative to an abritrary starting time; it does not correspond to "real world" or "wall clock" time in any way, so DON'T use this for keeping track of what time it is, just for timestamps and relative timing (e.g. "this loop needs to sleep another 100 ms").

The recommended methods to use are setToNow() to reset the time, mSecSince() to obtain the number of miliseconds elapsed since it was last reset (or secSince() if you don't need milisecond precision), and mSecSince(ArTime) or secSince(ArTime) to find the difference between two ArTime objects.

On systems where it is supported this will use a monotonic clock, this is an ever increasing system that is not dependent on what the time of day is set to. Normally for linux gettimeofday is used, but if the time is changed forwards or backwards then bad things can happen. Windows uses a time since bootup, which functions the same as the monotonic clock anyways. You can use ArTime::usingMonotonicClock() to see if this is being used. Note that an ArTime will have had to have been set to for this to be a good value... Aria::init does this however, so that should not be an issue. It looks like the monotonic clocks won't work on linux kernels before 2.6.

Examples:

actsColorFollowingExample.cpp, directMotionExample.cpp, gotoActionExample.cpp, gpsExample.cpp, and vcc4CameraExample.cpp.


Public Member Functions

void addMSec (long ms)
 Add some milliseconds (can be negative) to this time.
 ArTime ()
 Constructor. Time is initialized to the current time.
time_t getMSec (void) const
 Gets the milliseconds value (occuring after the seconds value).
time_t getSec (void) const
 Gets the seconds value (since the arbitrary starting time).
bool isAfter (ArTime testTime) const
 returns whether the given time is after this one or not
bool isAt (ArTime testTime) const
 returns whether the given time is equal to this time or not
bool isBefore (ArTime testTime) const
 returns whether the given time is before this one or not
void log (void) const
 Logs the time.
long mSecSince (void) const
 Finds the number of milliseconds from this timestamp to now.
long mSecSince (ArTime since) const
 Gets the number of milliseconds since the given timestamp to this one.
long mSecTo (void) const
 Finds the number of millisecs from when this timestamp is set to to now (the inverse of mSecSince()).
long secSince (void) const
 Finds the number of seconds from when this timestamp was set to now.
long secSince (ArTime since) const
 Gets the number of seconds since the given timestamp to this one.
long secTo (void) const
 Finds the number of seconds from when this timestamp is set to to now (the inverse of secSince()).
void setMSec (time_t msec)
 Sets the milliseconds value (occuring after the seconds value).
void setSec (time_t sec)
 Sets the seconds value (since the arbitrary starting time).
void setToNow (void)
 Resets the time.
 ~ArTime ()
 Destructor.

Static Public Member Functions

static bool usingMonotonicClock ()
 Gets if we're using a monotonic (ever increasing) clock.

Protected Attributes

time_t myMSec
time_t mySec


The documentation for this class was generated from the following files:
Generated on Thu Jan 7 10:34:44 2010 for Aria by  doxygen 1.4.2