![]() |
PIP 5.5.3
Platform-Independent Primitives
|
System time with nanosecond precision. More...
#include <pisystemtime.h>
Classes | |
| class | Frequency |
| Frequency type. More... | |
Public Member Functions | |
| PISystemTime () | |
| Contructs time with seconds and nanoseconds = 0. | |
| PISystemTime (int s, int ns) | |
| Contructs time with "s" seconds and "ns" nanoseconds. | |
| PISystemTime (std::pair< int, int > s_ns) | |
| Contructs time with "s" seconds and "ns" nanoseconds. | |
| bool | isNull () const |
| Returns if time is null. | |
| bool | isNotNull () const |
| Returns if time is not null. | |
| bool | isPositive () const |
| Returns if time is greater than 0. | |
| bool | isNegative () const |
| Returns if time is lesser than 0. | |
| double | toSeconds () const |
| Returns time value in seconds. | |
| double | toMilliseconds () const |
| Returns time value in milliseconds. | |
| double | toMicroseconds () const |
| Returns time value in microseconds. | |
| double | toNanoseconds () const |
| Returns time value in nanoseconds. | |
| PISystemTime & | addSeconds (double v) |
| Add to time "v" seconds. | |
| PISystemTime & | addMilliseconds (double v) |
| Add to time "v" milliseconds. | |
| PISystemTime & | addMicroseconds (double v) |
| Add to time "v" microseconds. | |
| PISystemTime & | addNanoseconds (double v) |
| Add to time "v" nanoseconds. | |
| void | sleep () |
| Sleep for this time. More... | |
| void | toTimespec (void *ts) |
| On *nix system assign current value to timespec struct. | |
| PISystemTime::Frequency | toFrequency () |
| Returns Frequency that corresponds this time interval. | |
| PIString | toString () const |
| Returns "yyyy-MM-dd hh:mm:ss.zzz" for absolute time and "<V> <d|h|m|s|ms|us|ns> ..." for relative. | |
| PISystemTime | abs () const |
| Returns copy of this time with absolutely values of s and ns. | |
| PISystemTime | operator+ (const PISystemTime &t) const |
| Returns sum of this time with "t". | |
| PISystemTime | operator- (const PISystemTime &t) const |
| Returns difference between this time and "t". | |
| PISystemTime | operator* (const double &v) const |
| Returns multiplication between this time and "t". | |
| PISystemTime | operator/ (const double &v) const |
| Returns division between this time and "t". | |
| PISystemTime & | operator+= (const PISystemTime &t) |
| Add to time "t". | |
| PISystemTime & | operator-= (const PISystemTime &t) |
| Subtract from time "t". | |
| PISystemTime & | operator*= (const double &v) |
| Multiply time by "v". | |
| PISystemTime & | operator/= (const double &v) |
| Divide time by "v". | |
| bool | operator== (const PISystemTime &t) const |
| Compare operator. | |
| bool | operator!= (const PISystemTime &t) const |
| Compare operator. | |
| bool | operator> (const PISystemTime &t) const |
| Compare operator. | |
| bool | operator< (const PISystemTime &t) const |
| Compare operator. | |
| bool | operator>= (const PISystemTime &t) const |
| Compare operator. | |
| bool | operator<= (const PISystemTime &t) const |
| Compare operator. | |
Static Public Member Functions | |
| static PISystemTime | fromSeconds (double v) |
| Contructs time from seconds "v". | |
| static PISystemTime | fromMilliseconds (double v) |
| Contructs time from milliseconds "v". | |
| static PISystemTime | fromMicroseconds (double v) |
| Contructs time from microseconds "v". | |
| static PISystemTime | fromNanoseconds (double v) |
| Contructs time from nanoseconds "v". | |
| static PISystemTime | fromString (PIString s) |
| Contructs time from string "s" ("yyyy-MM-dd hh:mm:ss.zzz" or free form) | |
| static PISystemTime | current (bool precise_but_not_system=false) |
| Returns current system time. | |
Public Attributes | |
| int | seconds |
| Seconds time part. | |
| int | nanoseconds |
| Nanoseconds time part. | |
System time with nanosecond precision.
This class provide arithmetic functions for POSIX system time. This time represents as seconds and nanosecons in integer formats. You can take current system time with function PISystemTime::current(), compare times, sum or subtract two times, convert time to/from seconds, milliseconds, microseconds or nanoseconds.
| void PISystemTime::sleep | ( | ) |
Sleep for this time.
Use this function to sleep for difference of system times or constructs system time. If you call this function on system time returned with PISystemTime::current() thread will be sleep almost forever