PIP 0.5.0_alpha Platform-Independent Primitives

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
PISystemTime Class Reference

System time. More...

## Public Member Functions
| PISystemTime ()
| Contructs system time with s = ns = 0.
| PISystemTime (long s, long ns)
| Contructs system time with s = "s" and ns = "ns".
| PISystemTime (const PISystemTime &t)
| Contructs system time from another.
double | toSeconds () const
| Returns stored system time value in seconds.
double | toMilliseconds () const
| Returns stored system time value in milliseconds.
double | toMicroseconds () const
| Returns stored system time value in microseconds.
double | toNanoseconds () const
| Returns stored system time value in nanoseconds.
PISystemTime & | addSeconds (double v)
| Add to stored system time "v" seconds.
PISystemTime & | addMilliseconds (double v)
| Add to stored system time "v" milliseconds.
PISystemTime & | addMicroseconds (double v)
| Add to stored system time "v" microseconds.
PISystemTime & | addNanoseconds (double v)
| Add to stored system time "v" nanoseconds.
void | sleep ()
PISystemTime | abs () const
| Returns copy of this system time with absolutely values of s and ns.
PISystemTime | operator+ (const PISystemTime &t) const
| Returns sum of this system time with "t".
PISystemTime | operator- (const PISystemTime &t) const
| Returns difference between this system time and "t".
PISystemTime | operator* (const double &v) const
| Returns multiplication between this system time and "t".
PISystemTime | operator/ (const double &v) const
| Returns division between this system time and "t".
PISystemTime & | operator+= (const PISystemTime &t)
| Add to stored value system time "t".
PISystemTime & | operator-= (const PISystemTime &t)
| Subtract from stored value system time "t".
PISystemTime & | operator*= (const double &v)
| Multiply stored value system time by "v".
PISystemTime & | operator/= (const double &v)
| Divide stored value system time by "v".
bool | operator== (const PISystemTime &t) const
| Compare system times.
bool | operator!= (const PISystemTime &t) const
| Compare system times.
bool | operator> (const PISystemTime &t) const
| Compare system times.
bool | operator< (const PISystemTime &t) const
| Compare system times.
bool | operator>= (const PISystemTime &t) const
| Compare system times.
bool | operator<= (const PISystemTime &t) const
| Compare system times.

## Static Public Member Functions
static PISystemTime | fromSeconds (double v)
| Contructs system time from seconds "v".
static PISystemTime | fromMilliseconds (double v)
| Contructs system time from milliseconds "v".
static PISystemTime | fromMicroseconds (double v)
| Contructs system time from microseconds "v".
static PISystemTime | fromNanoseconds (double v)
| Contructs system time from nanoseconds "v".
static PISystemTime | current (bool precise_but_not_system=false)
| Returns current system time.

## Public Attributes
long | seconds
| Seconds of stored system time.
long | nanoseconds
| Nanoseconds of stored system time.

## Detailed Description

System time.

# Synopsis

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.

# Example

int main() {
PISystemTime t0; // s = ns = 0
t0.addMilliseconds(200); // s = 0, ns = 200000000
t0.addMilliseconds(900); // s = 1, ns = 100000000
t0 -= PISystemTime::fromSeconds(0.1); // s = 1, ns = 0
t0.sleep(); // sleep for 1 second
PISystemTime t1;
t0 = currentSystemTime();
piMSleep(500);
t1 = currentSystemTime();
(t1 - t0).sleep(); // sleep for 500 milliseconds
return 0;
};

## Member Function Documentation

void PISystemTime::sleep | ( |  | ) |
| inline

Sleep for stored value.

Warning
  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.