A Time class, can be used to hold wall- or sim-time. More...
#include <common/common.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 Time & | operator*= (const struct timeval &_tv) |
| Multiplication assignment operator. | |
| const Time & | operator*= (const struct timespec &_tv) |
| Multiplication assignment operator. | |
| const Time & | operator*= (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 Time & | operator+= (const struct timeval &_tv) |
| Addition assignment operator. | |
| const Time & | operator+= (const struct timespec &_tv) |
| Addition assignment operator. | |
| const Time & | operator+= (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 Time & | operator-= (const struct timeval &_tv) |
| Subtraction assignment operator. | |
| const Time & | operator-= (const struct timespec &_tv) |
| Subtraction assignment operator. | |
| const Time & | operator-= (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 Time & | operator/= (const struct timeval &_tv) |
| Division assignment operator. | |
| const Time & | operator/= (const struct timespec &_tv) |
| Division assignment operator. | |
| const Time & | operator/= (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. | |
| Time & | operator= (const struct timeval &_tv) |
| Assignment operator. | |
| Time & | operator= (const struct timespec &_tv) |
| Assignment operator. | |
| Time & | operator= (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 Time & | GetWallTime () |
| 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. | |
| gazebo::common::Time::Time | ( | ) |
Constructors.
| gazebo::common::Time::Time | ( | const struct timeval & | _tv | ) |
Constructor.
| [in] | _tv | Time to initialize to |
| gazebo::common::Time::Time | ( | const struct timespec & | _tv | ) |
Constructor.
| [in] | _tv | Time to initialize to |
| gazebo::common::Time::Time | ( | int32_t | _sec, |
| int32_t | _nsec | ||
| ) |
Constructor.
| [in] | _sec | Seconds |
| [in] | _nsec | Nanoseconds |
| gazebo::common::Time::Time | ( | double | _time | ) |
Constuctor.
| [in] | _time | Time in double format sec.nsec |
|
virtual |
Destructor.
| double gazebo::common::Time::Double | ( | ) | const |
Get the time as a double.
| float gazebo::common::Time::Float | ( | ) | const |
Get the time as a float.
|
static |
Get the wall time.
|
inlinestatic |
Convert microseconds to nanoseconds.
| _ms | microseconds |
|
inlinestatic |
Convert milliseconds to nanoseconds.
| [in] | _ms | milliseconds |
|
static |
Millisecond sleep.
| [in] | _ms | milliseconds |
|
static |
Nano sleep.
| [in] | _ns | nanoseconds |
Nano sleep.
| [in] | _time | is a Time |
| bool gazebo::common::Time::operator!= | ( | const struct timeval & | _tv | ) | const |
Equal to operator.
| [in] | _tv | the time to compare to |
| bool gazebo::common::Time::operator!= | ( | const struct timespec & | _tv | ) | const |
Equal to operator.
| [in] | _tv | the time to compare to |
| bool gazebo::common::Time::operator!= | ( | const Time & | _time | ) | const |
Equal to operator.
| [in] | _time | the time to compare to |
| bool gazebo::common::Time::operator!= | ( | double | _time | ) | const |
Equal to operator.
| [in] | _time | the time to compare to |
| Time gazebo::common::Time::operator* | ( | const struct timeval & | _tv | ) | const |
| Time gazebo::common::Time::operator* | ( | const struct timespec & | _tv | ) | const |
| const Time& gazebo::common::Time::operator*= | ( | const struct timeval & | _tv | ) |
Multiplication assignment operator.
| [in] | _tv | the scaling duration |
| const Time& gazebo::common::Time::operator*= | ( | const struct timespec & | _tv | ) |
Multiplication assignment operator.
| [in] | _tv | the scaling duration |
| Time gazebo::common::Time::operator+ | ( | const struct timeval & | _tv | ) | const |
| Time gazebo::common::Time::operator+ | ( | const struct timespec & | _tv | ) | const |
| const Time& gazebo::common::Time::operator+= | ( | const struct timeval & | _tv | ) |
Addition assignment operator.
| [in] | _tv | the time to add |
| const Time& gazebo::common::Time::operator+= | ( | const struct timespec & | _tv | ) |
Addition assignment operator.
| [in] | _tv | the time to add |
| Time gazebo::common::Time::operator- | ( | const struct timeval & | _tv | ) | const |
| Time gazebo::common::Time::operator- | ( | const struct timespec & | _tv | ) | const |
| const Time& gazebo::common::Time::operator-= | ( | const struct timeval & | _tv | ) |
| const Time& gazebo::common::Time::operator-= | ( | const struct timespec & | _tv | ) |
Subtraction assignment operator.
| [in] | _time | The time to subtract |
| Time gazebo::common::Time::operator/ | ( | const struct timeval & | _tv | ) | const |
| Time gazebo::common::Time::operator/ | ( | const struct timespec & | _tv | ) | const |
| const Time& gazebo::common::Time::operator/= | ( | const struct timeval & | _tv | ) |
| const Time& gazebo::common::Time::operator/= | ( | const struct timespec & | _tv | ) |
| bool gazebo::common::Time::operator< | ( | const struct timeval & | _tv | ) | const |
Less than operator.
| [in] | _tv | the time to compare with |
| bool gazebo::common::Time::operator< | ( | const struct timespec & | _tv | ) | const |
Less than operator.
| [in] | _tv | the time to compare with |
| bool gazebo::common::Time::operator< | ( | const Time & | _time | ) | const |
Less than operator.
| [in] | _time | the time to compare with |
| bool gazebo::common::Time::operator< | ( | double | _time | ) | const |
Less than operator.
| [in] | _time | the time to compare with |
| bool gazebo::common::Time::operator<= | ( | const struct timeval & | _tv | ) | const |
Less than or equal to operator.
| [in] | _tv | the time to compare with |
| bool gazebo::common::Time::operator<= | ( | const struct timespec & | _tv | ) | const |
Less than or equal to operator.
| [in] | _tv | the time to compare with |
| bool gazebo::common::Time::operator<= | ( | const Time & | _time | ) | const |
Less than or equal to operator.
| [in] | _time | the time to compare with |
| bool gazebo::common::Time::operator<= | ( | double | _time | ) | const |
Less than or equal to operator.
| [in] | _time | the time to compare with |
| Time& gazebo::common::Time::operator= | ( | const struct timeval & | _tv | ) |
Assignment operator.
| [in] | _tv | the new time |
| Time& gazebo::common::Time::operator= | ( | const struct timespec & | _tv | ) |
Assignment operator.
| [in] | _tv | the new time |
Assignment operator.
| [in] | _time | the new time |
| bool gazebo::common::Time::operator== | ( | const struct timeval & | _tv | ) | const |
Equal to operator.
| [in] | _tv | the time to compare to |
| bool gazebo::common::Time::operator== | ( | const struct timespec & | _tv | ) | const |
Equal to operator.
| [in] | _tv | the time to compare to |
| bool gazebo::common::Time::operator== | ( | const Time & | _time | ) | const |
Equal to operator.
| [in] | _time | the time to compare to |
| bool gazebo::common::Time::operator== | ( | double | _time | ) | const |
Equal to operator.
| [in] | _time | the time to compare to |
| bool gazebo::common::Time::operator> | ( | const struct timeval & | _tv | ) | const |
Greater than operator.
| [in] | _tv | the time to compare with |
| bool gazebo::common::Time::operator> | ( | const struct timespec & | _tv | ) | const |
Greater than operator.
| [in] | _tv | the time to compare with |
| bool gazebo::common::Time::operator> | ( | const Time & | _time | ) | const |
Greater than operator.
| [in] | _time | the time to compare with |
| bool gazebo::common::Time::operator> | ( | double | _time | ) | const |
Greater than operator.
| [in] | _time | the time to compare with |
| bool gazebo::common::Time::operator>= | ( | const struct timeval & | _tv | ) | const |
Greater than or equal operator.
| [in] | _tv | the time to compare with |
| bool gazebo::common::Time::operator>= | ( | const struct timespec & | _tv | ) | const |
Greater than or equal operator.
| [in] | _tv | the time to compare with |
| bool gazebo::common::Time::operator>= | ( | const Time & | _time | ) | const |
Greater than or equal operator.
| [in] | _time | the time to compare with |
| bool gazebo::common::Time::operator>= | ( | double | _time | ) | const |
Greater than or equal operator.
| [in] | _time | the time to compare with |
|
inlinestatic |
Convert seconds to nanoseconds.
| [in] | _sec | duration in seconds |
| void gazebo::common::Time::Set | ( | int32_t | _sec, |
| int32_t | _nsec | ||
| ) |
Set to sec and nsec.
| [in] | _sec | Seconds |
| [in] | _nsec | Nanoseconds |
| void gazebo::common::Time::Set | ( | double | _seconds | ) |
Set to seconds.
| [in] | _seconds | Number of seconds |
| void gazebo::common::Time::SetToWallTime | ( | ) |
Set the time to the wall time.
|
friend |
Stream insertion operator.
| [in] | _out | the output stream |
| [in] | _time | time to write to the stream |
|
friend |
Stream extraction operator.
| [in] | _in | the input stream |
| [in] | _time | time to read from to the stream |
| int32_t gazebo::common::Time::nsec |
Microseconds.
| int32_t gazebo::common::Time::sec |
Seconds.