SbTime Class Reference
[Basics]

Class for representation of a time. More...

#include <Inventor/SbTime.h>

List of all members.

Public Member Functions

 SbTime ()
 SbTime (double sec)
 SbTime (time_t sec, long usec)
 SbTime (const struct timeval *tv)
void setToTimeOfDay ()
void setValue (double sec)
void setValue (time_t sec, long usec)
void setValue (const struct timeval *tv)
void setMsecValue (unsigned long msec)
double getValue () const
void getValue (time_t &sec, long &usec) const
void getValue (struct timeval *tv) const
unsigned long getMsecValue () const
SbString format (const char *fmt="%S.%i") const
SbString formatDate (const char *fmt=DEFAULT_FORMAT_DATE) const
SbTimeoperator+= (const SbTime &tm)
SbTimeoperator-= (const SbTime &tm)
SbTime operator- () const
SbTimeoperator*= (double s)
SbTimeoperator/= (double s)
double operator/ (const SbTime &tm) const
SbTime operator% (const SbTime &tm) const
int operator== (const SbTime &tm) const
int operator!= (const SbTime &tm) const
SbBool operator< (const SbTime &tm) const
SbBool operator> (const SbTime &tm) const
SbBool operator<= (const SbTime &tm) const
SbBool operator>= (const SbTime &tm) const

Static Public Member Functions

static SbTime getTimeOfDay ()
static SbTime zero ()
static void sleep (const int msec)
static void usleep (size_t usec)
static SbTime max ()
static SbTime maxTime ()

Friends

SbTime operator+ (const SbTime &t0, const SbTime &t1)
SbTime operator- (const SbTime &t0, const SbTime &t1)
SbTime operator* (const SbTime &tm, double s)
SbTime operator* (double s, const SbTime &tm)
SbTime operator/ (const SbTime &tm, double s)

Detailed Description

Class for representation of a time.

This class represents and performs operations on time. Operations may be done in seconds, seconds and microseconds, or using a struct timeval (defined in time.h ).

SEE ALSO

SbElapsedTime


Constructor & Destructor Documentation

SbTime::SbTime (  )  [inline]

Default constructor.

The time value is not initialized.

SbTime::SbTime ( double  sec  ) 

Constructor taking seconds.

NOTE that an integer parameter will not automatically cast to a double to invoke the constructor taking seconds; that is, SbTime(1) will result in a compilation error. SbTime(1.0) must be used instead. This is to avoid errors in upgrading from an earlier release, in which SbTime(1) had different semantics. In future releases, this distinction will be eliminated, and the effect of SbTime(1.0) and that of SbTime(1) will be identical.

SbTime::SbTime ( time_t  sec,
long  usec 
)

Constructor taking seconds and microseconds.

SbTime::SbTime ( const struct timeval *  tv  ) 

Constructor taking a struct timeval.


Member Function Documentation

SbString SbTime::format ( const char *  fmt = "%S.%i"  )  const

Convert to a string.

The default format is seconds with 3 digits of fraction precision. fmt is a character string that consists of field descriptors and text characters, in a manner analogous to printf(). Each field descriptor consists of a % character followed by another character which specifies the replacement for the field descriptor. All other characters are copied from fmt into the result. The following field descriptors are supported:

       \%  the `\%' character
       D  total number of days
       H  total number of hours
       M  total number of minutes
       S  total number of seconds
       I  total number of milliseconds
       U  total number of microseconds
       h  hours remaining after the days (00-23)
       m  minutes remaining after the hours (00-59)
       s  seconds remaining after the minutes (00-59)
       i  milliseconds remaining after the seconds (000-999)
       u  microseconds remaining after the seconds (000000-999999)
     

The uppercase descriptors are formatted with a leading `-' for negative times; the lowercase descriptors are formatted fixed width, with leading zeros. For example, a reasonable format string might be "elapsed time: \%M minutes, \%s seconds". The default value of fmt, "\%S.\%i", formats the time as seconds with 3 digits of fractional precision.

SbString SbTime::formatDate ( const char *  fmt = DEFAULT_FORMAT_DATE  )  const

Convert to a date string, interpreting the time as seconds since Jan 1, 1970.

The default format gives "Tuesday, 01/26/93 11:23:41 AM". See the strftime() reference page for explanation of the format string.

unsigned long SbTime::getMsecValue (  )  const

Get time in milliseconds (for Xt).

static SbTime SbTime::getTimeOfDay (  )  [static]

Get the current time (seconds since Jan 1, 1970).

void SbTime::getValue ( struct timeval *  tv  )  const

Get time in a struct timeval.

void SbTime::getValue ( time_t &  sec,
long &  usec 
) const

Get time in seconds and microseconds.

double SbTime::getValue (  )  const

Get time in seconds as a double.

static SbTime SbTime::max (  )  [static]

Deprecated.

Get a time far, far into the future. Replaced by SbTime::maxTime() method.

static SbTime SbTime::maxTime (  )  [static]

Get a time far, far into the future.

Replace the deprecated SbTime::max() method.

int SbTime::operator!= ( const SbTime tm  )  const

Inequality operator.

SbTime SbTime::operator% ( const SbTime tm  )  const

Modulus for two times (remainder when time1 is divided by time2).

SbTime& SbTime::operator*= ( double  s  ) 

Destructive multiplication by scalar.

SbTime& SbTime::operator+= ( const SbTime tm  ) 

Addition of two times which modifies the time structure.

SbTime SbTime::operator- (  )  const

Unary negation.

SbTime& SbTime::operator-= ( const SbTime tm  ) 

Subtraction of two times which modifies the time structure.

double SbTime::operator/ ( const SbTime tm  )  const

Division by another time.

SbTime& SbTime::operator/= ( double  s  ) 

Destructive division by scalar.

SbBool SbTime::operator< ( const SbTime tm  )  const [inline]

Relational (less than) operator.

SbBool SbTime::operator<= ( const SbTime tm  )  const [inline]

Relational (less than or equal to) operator.

int SbTime::operator== ( const SbTime tm  )  const

Equality operator.

SbBool SbTime::operator> ( const SbTime tm  )  const [inline]

Relational (greater than) operator.

SbBool SbTime::operator>= ( const SbTime tm  )  const [inline]

Relational (greater than or equal to) operator.

void SbTime::setMsecValue ( unsigned long  msec  ) 

Set time from milliseconds.

void SbTime::setToTimeOfDay (  ) 

Set to the current time (seconds since Jan 1, 1970).

void SbTime::setValue ( const struct timeval *  tv  ) 

Set time from a struct timeval.

void SbTime::setValue ( time_t  sec,
long  usec 
)

Set time from seconds + microseconds.

void SbTime::setValue ( double  sec  ) 

Set time from a double (in seconds).

static void SbTime::sleep ( const int  msec  )  [static]

Sleep for specified time (in msec).

static void SbTime::usleep ( size_t  usec  )  [static]

Sleep for specified time (in microsec).

static SbTime SbTime::zero (  )  [static]

Get a zero time.


Friends And Related Function Documentation

SbTime operator* ( double  s,
const SbTime tm 
) [friend]

Multiplication by scalar.

SbTime operator* ( const SbTime tm,
double  s 
) [friend]

Multiplication by scalar.

SbTime operator+ ( const SbTime t0,
const SbTime t1 
) [friend]

Addition of two times.

SbTime operator- ( const SbTime t0,
const SbTime t1 
) [friend]

Subtraction of two times.

SbTime operator/ ( const SbTime tm,
double  s 
) [friend]

Division by scalar.


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

Open Inventor Toolkit reference manual, generated on 12 Feb 2024
Copyright © Thermo Fisher Scientific All rights reserved.
http://www.openinventor.com/