All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
gazebo::common::Time Class Reference

A Time class, can be used to hold wall- or sim-time. More...

#include <Time.hh>

Public Member Functions

 Time ()
 Constructors.
 
 Time (const Time &_time)
 Copy constructor.
 
 Time (const struct timeval &_tv)
 Constructor.
 
 Time (const struct timespec &_tv)
 Constructor.
 
 Time (int32_t _sec, int32_t _nsec)
 Constructor.
 
 Time (double _time)
 Constuctor.
 
virtual ~Time ()
 Destructor.
 
double Double () const
 Get the time as a double.
 
float Float () const
 Get the time as a float.
 
bool operator!= (const struct timeval &tv) const
 Equal to operator.
 
bool operator!= (const struct timespec &tv) const
 Equal to operator.
 
bool operator!= (const Time &time) const
 Equal to operator.
 
bool operator!= (double time) const
 Equal to operator.
 
Time operator* (const struct timeval &tv) const
 Multiplication operator.
 
Time operator* (const struct timespec &tv) const
 Multiplication operator.
 
Time operator* (const Time &time) const
 Multiplication operators.
 
const Timeoperator*= (const struct timeval &tv)
 Multiplication assignment operator.
 
const Timeoperator*= (const struct timespec &tv)
 Multiplication assignment operator.
 
const Timeoperator*= (const Time &time)
 Multiplication operators.
 
Time operator+ (const struct timeval &tv) const
 Addition operators.
 
Time operator+ (const struct timespec &tv) const
 Addition operators.
 
Time operator+ (const Time &time) const
 Addition operators.
 
const Timeoperator+= (const struct timeval &tv)
 Addition assignment operator.
 
const Timeoperator+= (const struct timespec &tv)
 Addition assignment operator.
 
const Timeoperator+= (const Time &time)
 Addition assignemtn operator.
 
Time operator- (const struct timeval &tv) const
 Subtraction operator.
 
Time operator- (const struct timespec &tv) const
 Subtraction operator.
 
Time operator- (const Time &time) const
 Subtraction operator.
 
const Timeoperator-= (const struct timeval &tv)
 Subtraction assignment operator.
 
const Timeoperator-= (const struct timespec &tv)
 Subtraction assignment operator.
 
const Timeoperator-= (const Time &time)
 Subtraction assignment operator.
 
Time operator/ (const struct timeval &tv) const
 Division operator.
 
Time operator/ (const struct timespec &tv) const
 Division operator.
 
Time operator/ (const Time &time) const
 Division operator.
 
const Timeoperator/= (const struct timeval &tv)
 Division assignment operator.
 
const Timeoperator/= (const struct timespec &tv)
 Division assignment operator.
 
const Timeoperator/= (const Time &time)
 Division assignment operator.
 
bool operator< (const struct timeval &tv) const
 Less than operator.
 
bool operator< (const struct timespec &tv) const
 Less than operator.
 
bool operator< (const Time &time) const
 Less than operator.
 
bool operator< (double time) const
 Less than operator.
 
bool operator<= (const struct timeval &tv) const
 Less than or equal to operator.
 
bool operator<= (const struct timespec &tv) const
 Less than or equal to operator.
 
bool operator<= (const Time &time) const
 Less than or equal to operator.
 
bool operator<= (double time) const
 Less than or equal to operator.
 
Timeoperator= (const struct timeval &tv)
 Assignment operator.
 
Timeoperator= (const struct timespec &tv)
 Assignment operator.
 
Timeoperator= (const Time &time)
 Assignment operator.
 
bool operator== (const struct timeval &tv) const
 Equal to operator.
 
bool operator== (const struct timespec &tv) const
 Equal to operator.
 
bool operator== (const Time &time) const
 Equal to operator.
 
bool operator== (double time) const
 Equal to operator.
 
bool operator> (const struct timeval &tv) const
 Greater than operator.
 
bool operator> (const struct timespec &tv) const
 Greater than operator.
 
bool operator> (const Time &time) const
 Greater than operator.
 
bool operator> (double time) const
 Greater than operator.
 
bool operator>= (const struct timeval &tv) const
 Greater than or equal operator.
 
bool operator>= (const struct timespec &tv) const
 Greater than or equal operator.
 
bool operator>= (const Time &time) const
 Greater than or equal operator.
 
bool operator>= (double time) const
 Greater than or equal operator.
 
void Set (int32_t _sec, int32_t _nsec)
 Set to sec and nsec.
 
void Set (double _seconds)
 Set to seconds.
 
void SetToWallTime ()
 Set the time to the wall time.
 

Static Public Member Functions

static const TimeGetWallTime ()
 Get the wall time.
 
static double MicToNano (double _ms)
 Convert microseconds to nanoseconds.
 
static double MilToNano (double _ms)
 Convert milliseconds to nanoseconds.
 
static Time MSleep (unsigned int _ms)
 Millisecond sleep.
 
static Time NSleep (unsigned int _ns)
 Nano sleep.
 
static Time NSleep (Time _time)
 Nano sleep.
 
static double SecToNano (double _sec)
 Convert seconds to nanoseconds.
 

Public Attributes

int32_t nsec
 Microseconds.
 
int32_t sec
 Seconds.
 

Friends

std::ostream & operator<< (std::ostream &_out, const gazebo::common::Time &_time)
 Stream insertion operator.
 
std::istream & operator>> (std::istream &_in, gazebo::common::Time &_time)
 Stream extraction operator.
 

Detailed Description

A Time class, can be used to hold wall- or sim-time.

stored as sec and nano-sec.

Constructor & Destructor Documentation

gazebo::common::Time::Time ( )

Constructors.

gazebo::common::Time::Time ( const Time _time)

Copy constructor.

Parameters
[in]timeTime to copy
gazebo::common::Time::Time ( const struct timeval &  _tv)

Constructor.

Parameters
[in]tvTime to initialize to
gazebo::common::Time::Time ( const struct timespec &  _tv)

Constructor.

Parameters
[in]tvTime to initialize to
gazebo::common::Time::Time ( int32_t  _sec,
int32_t  _nsec 
)

Constructor.

Parameters
[in]secSeconds
[in]nsecMicroseconds
gazebo::common::Time::Time ( double  _time)

Constuctor.

Parameters
[in]timeTime in double format sec.nsec
virtual gazebo::common::Time::~Time ( )
virtual

Destructor.

Member Function Documentation

double gazebo::common::Time::Double ( ) const

Get the time as a double.

Returns
Time as a double in seconds
float gazebo::common::Time::Float ( ) const

Get the time as a float.

Returns
Time as a float in seconds
static const Time& gazebo::common::Time::GetWallTime ( )
static

Get the wall time.

Returns
the current time
static double gazebo::common::Time::MicToNano ( double  _ms)
inlinestatic

Convert microseconds to nanoseconds.

Parameters
_msmicroseconds
Returns
nanoseconds
static double gazebo::common::Time::MilToNano ( double  _ms)
inlinestatic

Convert milliseconds to nanoseconds.

Parameters
[in]_msmilliseconds
Returns
nanoseconds
static Time gazebo::common::Time::MSleep ( unsigned int  _ms)
static

Millisecond sleep.

Parameters
[in]_msmilliseconds
static Time gazebo::common::Time::NSleep ( unsigned int  _ns)
static

Nano sleep.

Parameters
[in]_nsnanoseconds
static Time gazebo::common::Time::NSleep ( Time  _time)
static

Nano sleep.

Parameters
[in]_timeis a Time
bool gazebo::common::Time::operator!= ( const struct timeval &  tv) const

Equal to operator.

Parameters
[in]tvthe time to compare to
Returns
true if values are the same, false otherwise
bool gazebo::common::Time::operator!= ( const struct timespec &  tv) const

Equal to operator.

Parameters
[in]tvthe time to compare to
Returns
true if values are the same, false otherwise
bool gazebo::common::Time::operator!= ( const Time time) const

Equal to operator.

Parameters
[in]timethe time to compare to
Returns
true if values are the same, false otherwise
bool gazebo::common::Time::operator!= ( double  time) const

Equal to operator.

Parameters
[in]timethe time to compare to
Returns
true if values are the same, false otherwise
Time gazebo::common::Time::operator* ( const struct timeval &  tv) const

Multiplication operator.

Returns
Time instance
Time gazebo::common::Time::operator* ( const struct timespec &  tv) const

Multiplication operator.

Returns
Time instance
Time gazebo::common::Time::operator* ( const Time time) const

Multiplication operators.

Parameters
[in]timethe scaling factor
Returns
a scaled Time instance
const Time& gazebo::common::Time::operator*= ( const struct timeval &  tv)

Multiplication assignment operator.

Parameters
[in]tvthe scaling duration
Returns
a reference to this instance
const Time& gazebo::common::Time::operator*= ( const struct timespec &  tv)

Multiplication assignment operator.

Parameters
[in]tvthe scaling duration
Returns
a reference to this instance
const Time& gazebo::common::Time::operator*= ( const Time time)

Multiplication operators.

Parameters
[in]timescale factor
Returns
a scaled Time instance
Time gazebo::common::Time::operator+ ( const struct timeval &  tv) const

Addition operators.

Parameters
[in]tvthe time to add
Returns
a Time instance
Time gazebo::common::Time::operator+ ( const struct timespec &  tv) const

Addition operators.

Parameters
[in]tvthe time to add
Returns
a Time instance
Time gazebo::common::Time::operator+ ( const Time time) const

Addition operators.

Returns
a Time instance
const Time& gazebo::common::Time::operator+= ( const struct timeval &  tv)

Addition assignment operator.

Parameters
[in]tv
Returns
a reference to this instance
const Time& gazebo::common::Time::operator+= ( const struct timespec &  tv)

Addition assignment operator.

Parameters
[in]tv
Returns
a reference to this instance
const Time& gazebo::common::Time::operator+= ( const Time time)

Addition assignemtn operator.

Returns
a Time instance
Time gazebo::common::Time::operator- ( const struct timeval &  tv) const

Subtraction operator.

Returns
a Time instance
Time gazebo::common::Time::operator- ( const struct timespec &  tv) const

Subtraction operator.

Returns
a Time instance
Time gazebo::common::Time::operator- ( const Time time) const

Subtraction operator.

Returns
a Time instance
const Time& gazebo::common::Time::operator-= ( const struct timeval &  tv)

Subtraction assignment operator.

Returns
a Time instance
const Time& gazebo::common::Time::operator-= ( const struct timespec &  tv)

Subtraction assignment operator.

Returns
a Time instance
const Time& gazebo::common::Time::operator-= ( const Time time)

Subtraction assignment operator.

Returns
a reference to this instance
Time gazebo::common::Time::operator/ ( const struct timeval &  tv) const

Division operator.

Parameters
[in]tva timeval divisor
Returns
a Time instance
Time gazebo::common::Time::operator/ ( const struct timespec &  tv) const

Division operator.

Parameters
[in]tva timespec divisor
Returns
a Time instance
Time gazebo::common::Time::operator/ ( const Time time) const

Division operator.

Parameters
[in]timethe divisor
Returns
a Time instance
const Time& gazebo::common::Time::operator/= ( const struct timeval &  tv)

Division assignment operator.

Parameters
[in]tva divisor
Returns
a Time instance
const Time& gazebo::common::Time::operator/= ( const struct timespec &  tv)

Division assignment operator.

Parameters
[in]tva divisor
Returns
a Time instance
const Time& gazebo::common::Time::operator/= ( const Time time)

Division assignment operator.

Parameters
[in]timethe divisor
Returns
a Time instance
bool gazebo::common::Time::operator< ( const struct timeval &  tv) const

Less than operator.

Parameters
[in]tvthe time to compare with
Returns
true if tv is shorter than this, false otherwise
bool gazebo::common::Time::operator< ( const struct timespec &  tv) const

Less than operator.

Parameters
[in]tvthe time to compare with
Returns
true if tv is shorter than this, false otherwise
bool gazebo::common::Time::operator< ( const Time time) const

Less than operator.

Parameters
[in]timethe time to compare with
Returns
true if time is shorter than this, false otherwise
bool gazebo::common::Time::operator< ( double  time) const

Less than operator.

Parameters
[in]timethe time to compare with
Returns
true if time is shorter than this, false otherwise
bool gazebo::common::Time::operator<= ( const struct timeval &  tv) const

Less than or equal to operator.

Parameters
[in]tvthe time to compare with
Returns
true if tv is shorter than or equal to this, false otherwise
bool gazebo::common::Time::operator<= ( const struct timespec &  tv) const

Less than or equal to operator.

Parameters
[in]tvthe time to compare with
Returns
true if tv is shorter than or equal to this, false otherwise
bool gazebo::common::Time::operator<= ( const Time time) const

Less than or equal to operator.

Parameters
[in]timethe time to compare with
Returns
true if time is shorter than or equal to this, false otherwise
bool gazebo::common::Time::operator<= ( double  time) const

Less than or equal to operator.

Parameters
[in]timethe time to compare with
Returns
true if time is shorter than or equal to this, false otherwise
Time& gazebo::common::Time::operator= ( const struct timeval &  tv)

Assignment operator.

Parameters
[in]tvthe new time
Returns
a reference to this instance
Time& gazebo::common::Time::operator= ( const struct timespec &  tv)

Assignment operator.

Parameters
[in]tvthe new time
Returns
a reference to this instance
Time& gazebo::common::Time::operator= ( const Time time)

Assignment operator.

Parameters
[in]timethe new time
Returns
a reference to this instance
bool gazebo::common::Time::operator== ( const struct timeval &  tv) const

Equal to operator.

Parameters
[in]tvthe time to compare to
Returns
true if values are the same, false otherwise
bool gazebo::common::Time::operator== ( const struct timespec &  tv) const

Equal to operator.

Parameters
[in]tvthe time to compare to
Returns
true if values are the same, false otherwise
bool gazebo::common::Time::operator== ( const Time time) const

Equal to operator.

Parameters
[in]tvthe time to compare to
Returns
true if values are the same, false otherwise
bool gazebo::common::Time::operator== ( double  time) const

Equal to operator.

Parameters
[in]timethe time to compare to
Returns
true if values are the same, false otherwise
bool gazebo::common::Time::operator> ( const struct timeval &  tv) const

Greater than operator.

Parameters
[in]timethe time to compare with
Returns
true if time is greater than this, false otherwise
bool gazebo::common::Time::operator> ( const struct timespec &  tv) const

Greater than operator.

Parameters
[in]timethe time to compare with
Returns
true if time is greater than this, false otherwise
bool gazebo::common::Time::operator> ( const Time time) const

Greater than operator.

Parameters
[in]timethe time to compare with
Returns
true if time is greater than this, false otherwise
bool gazebo::common::Time::operator> ( double  time) const

Greater than operator.

Parameters
[in]timethe time to compare with
Returns
true if time is greater than this, false otherwise
bool gazebo::common::Time::operator>= ( const struct timeval &  tv) const

Greater than or equal operator.

Parameters
[in]tvthe time to compare with
Returns
true if tv is greater than or equal to this, false otherwise
bool gazebo::common::Time::operator>= ( const struct timespec &  tv) const

Greater than or equal operator.

Parameters
[in]tvthe time to compare with
Returns
true if tv is greater than or equal to this, false otherwise
bool gazebo::common::Time::operator>= ( const Time time) const

Greater than or equal operator.

Parameters
[in]timethe time to compare with
Returns
true if time is greater than or equal to this, false otherwise
bool gazebo::common::Time::operator>= ( double  time) const

Greater than or equal operator.

Parameters
[in]timethe time to compare with
Returns
true if time is greater than or equal to this, false otherwise
static double gazebo::common::Time::SecToNano ( double  _sec)
inlinestatic

Convert seconds to nanoseconds.

Parameters
[in]_secduration in seconds
Returns
nanoseconds
void gazebo::common::Time::Set ( int32_t  _sec,
int32_t  _nsec 
)

Set to sec and nsec.

Parameters
[in]secSeconds
[in]nsecmicro seconds
void gazebo::common::Time::Set ( double  _seconds)

Set to seconds.

Parameters
[in]secondsNumber of seconds
void gazebo::common::Time::SetToWallTime ( )

Set the time to the wall time.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  _out,
const gazebo::common::Time _time 
)
friend

Stream insertion operator.

Parameters
[in]_outthe output stream
[in]_timetime to write to the stream
Returns
the output stream
std::istream& operator>> ( std::istream &  _in,
gazebo::common::Time _time 
)
friend

Stream extraction operator.

Parameters
[in]_inthe input stream
[in]_timetime to read from to the stream
Returns
the input stream

Member Data Documentation

int32_t gazebo::common::Time::nsec

Microseconds.

int32_t gazebo::common::Time::sec

Seconds.


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