|
AndroMeta
2.0.0
|
Time data type and operations. More...
#include <MTime.h>
Public Member Functions | |
| MTime () | |
| MTime (double sec, bool absolute=false) | |
| MTime (uint64_t sec, uint64_t nsec) | |
| MTime (const MTime &time) | |
| MTime (const MVar &v, RestoreOpt opt) | |
| MTime (mnode n) | |
| ~MTime () | |
| void | store (mvar &v) const |
| uint64_t | sec () const |
| uint64_t | nsec () const |
| void | setSec (uint64_t sec) |
| void | setNSec (uint64_t nsec) |
| MTime & | operator= (const MTime &time) |
| MTime & | operator+= (double sec) |
| MTime & | operator+= (const MTime &time) |
| MTime | operator+ (double sec) const |
| MTime | operator+ (const MTime &time) const |
| MTime & | operator-= (double sec) |
| MTime & | operator-= (const MTime &time) |
| MTime | operator- (double sec) const |
| MTime | operator- (const MTime &time) const |
| bool | operator< (const MTime &time) const |
| bool | operator> (const MTime &time) const |
| bool | operator<= (const MTime &time) const |
| bool | operator>= (const MTime &time) const |
| bool | operator== (const MTime &time) const |
| bool | operator!= (const MTime &time) const |
| mstr | toStr (const mstr &format="%Y-%m-%d %T.$nsec") const |
| double | asDouble () const |
| operator double () const | |
Static Public Member Functions | |
| static MTime | now () |
| static void | sleep (const MTime &timeout) |
| static void | dayInfo (int year, int month, int day, int &dayOfYear, int &dayOfWeek) |
| static void | dayOfYear (uint64_t year, int dayOfYear, int &month, int &day) |
Friends | |
| class | MTime_ |
Time data type and operations.
Represents time as seconds + nanosends since UNIX epoch. Various parts of the framework use MTime as an absolute time (e.g: "timeout" parameters) unless otherwise specified. Time is typically passed as double which gives an absolute time from an offset, e.g: mutex.lock(0.05) -- sets the timeout to 0.05 secs in the future.
Constructor.
| Meta::MTime::MTime | ( | double | sec, |
| bool | absolute = false |
||
| ) |
Construct an absolute time from seconds. This is the most common constructor which is typically used to implicitly construct an absolute time for the various framework methods that require a timeout parameter. So when Object::await(const mtime& timeout) is defined, object.await(0.5) constructs an absolute timeout 0.5 seconds into the future.
| absolute | true if sec refers to an absolute time. |
| Meta::MTime::MTime | ( | uint64_t | sec, |
| uint64_t | nsec | ||
| ) |
Construct an absolute time from seconds + nanoseconds.
| Meta::MTime::MTime | ( | const MTime & | time | ) |
Copy constructor.
| Meta::MTime::MTime | ( | const MVar & | v, |
| RestoreOpt | opt | ||
| ) |
Restore constructor.
| Meta::MTime::MTime | ( | mnode | n | ) |
Construct a time from a node which holds a stored mvar.
Destructor.
| static void Meta::MTime::dayInfo | ( | int | year, |
| int | month, | ||
| int | day, | ||
| int & | dayOfYear, | ||
| int & | dayOfWeek | ||
| ) | [static] |
Get day of week and day of year. All values start at 1, e.g: month = 1 is January, dayOfWeek = 7 is Saturday.
| static void Meta::MTime::dayOfYear | ( | uint64_t | year, |
| int | dayOfYear, | ||
| int & | month, | ||
| int & | day | ||
| ) | [static] |
From the day of year, find the month and day. All values start at 1.
| year | e.g: 2005 |
| static MTime Meta::MTime::now | ( | ) | [static] |
| uint64_t Meta::MTime::nsec | ( | ) | const |
Return this time's nanoseconds.
| MTime Meta::MTime::operator+ | ( | double | sec | ) | const [inline] |
| sec | A seconds offset. |
| MTime& Meta::MTime::operator+= | ( | double | sec | ) |
| sec | A seconds offset. |
| MTime Meta::MTime::operator- | ( | double | sec | ) | const [inline] |
| sec | A seconds offset. |
| MTime& Meta::MTime::operator-= | ( | double | sec | ) |
| sec | A seconds offset. |
| uint64_t Meta::MTime::sec | ( | ) | const |
Return this time's seconds.
| void Meta::MTime::setNSec | ( | uint64_t | nsec | ) |
Set this time's nanoseconds.
| void Meta::MTime::setSec | ( | uint64_t | sec | ) |
Set this time's seconds.
| static void Meta::MTime::sleep | ( | const MTime & | timeout | ) | [static] |
Sleep until timeout has been reached.
| void Meta::MTime::store | ( | mvar & | v | ) | const [virtual] |
Store this time to v.
Reimplemented from Meta::MObjectBase.
| mstr Meta::MTime::toStr | ( | const mstr & | format = "%Y-%m-%d %T.$nsec" | ) | const |
1.7.6.1