SGTimeStamp Class Reference

The SGTimeStamp class allows you to mark and compare time stamps with nanosecond accuracy (if your system has support for this level of accuracy). More...

#include <timestamp.hxx>

List of all members.

Public Member Functions

 SGTimeStamp ()
 Default constructor, initialize time to zero.
void stamp ()
 Hmm, might reenable them at some time, but since it is not clear what the input unit of the int is, omit them for now.
void setTime (const double &seconds)
 Set the time from a double value.
void setTime (sec_type sec, nsec_type nsec)
 Set the time from a seconds/nanoseconds pair.
long get_seconds () const
int get_usec () const
const sec_type & getSeconds () const
const nsec_type & getNanoSeconds () const
double toNSecs () const
double toUSecs () const
double toMSecs () const
double toSecs () const
SGTimeStampoperator+= (const SGTimeStamp &c)
 Inplace addition.
SGTimeStampoperator-= (const SGTimeStamp &c)
 Inplace subtraction.

Static Public Member Functions

static SGTimeStamp fromSecMSec (sec_type sec, nsec_type msec)
 Create SGTimeStamps from input with given units.
static SGTimeStamp now ()
 Return a timestamp with the current time.

Detailed Description

The SGTimeStamp class allows you to mark and compare time stamps with nanosecond accuracy (if your system has support for this level of accuracy).

The SGTimeStamp is useful for tracking the elapsed time of various events in your program. You can also use it to keep constistant motion across varying frame rates.

Note SGTimestamp does not deliver the time of day. The content of this stamps might be, dependent on the implementation, a time to an arbitrary base time.

Definition at line 55 of file timestamp.hxx.


Constructor & Destructor Documentation

SGTimeStamp::SGTimeStamp (  )  [inline]

Default constructor, initialize time to zero.

Definition at line 61 of file timestamp.hxx.


Member Function Documentation

long SGTimeStamp::get_seconds (  )  const [inline]
Returns:
the saved seconds of this time stamp

Definition at line 103 of file timestamp.hxx.

int SGTimeStamp::get_usec (  )  const [inline]
Returns:
the saved microseconds of this time stamp

Definition at line 106 of file timestamp.hxx.

const nsec_type& SGTimeStamp::getNanoSeconds (  )  const [inline]
Returns:
the saved nanoseconds of this time stamp

Definition at line 112 of file timestamp.hxx.

const sec_type& SGTimeStamp::getSeconds (  )  const [inline]
Returns:
the saved seconds of this time stamp

Definition at line 109 of file timestamp.hxx.

void SGTimeStamp::stamp (  ) 

Hmm, might reenable them at some time, but since it is not clear what the input unit of the int is, omit them for now.

Use the static constructor functions where it is clear from the method name how the arguments are meant. Update stored time to current time (seconds and nanoseconds)

Definition at line 61 of file timestamp.cxx.

double SGTimeStamp::toMSecs (  )  const [inline]
Returns:
the value of the timestamp in milliseconds, use doubles to avoid overflow. If you need real nanosecond accuracy for time differences, build up a SGTimeStamp reference time and compare SGTimeStamps directly.

Definition at line 136 of file timestamp.hxx.

double SGTimeStamp::toNSecs (  )  const [inline]
Returns:
the value of the timestamp in nanoseconds, use doubles to avoid overflow. If you need real nanosecond accuracy for time differences, build up a SGTimeStamp reference time and compare SGTimeStamps directly.

Definition at line 120 of file timestamp.hxx.

double SGTimeStamp::toSecs (  )  const [inline]
Returns:
the value of the timestamp in seconds, use doubles to avoid overflow. If you need real nanosecond accuracy for time differences, build up a SGTimeStamp reference time and compare SGTimeStamps directly.

Definition at line 144 of file timestamp.hxx.

double SGTimeStamp::toUSecs (  )  const [inline]
Returns:
the value of the timestamp in microseconds, use doubles to avoid overflow. If you need real nanosecond accuracy for time differences, build up a SGTimeStamp reference time and compare SGTimeStamps directly.

Definition at line 128 of file timestamp.hxx.


The documentation for this class was generated from the following files:

Generated on 23 Feb 2010 for SimGear by  doxygen 1.6.1