AndroMeta  2.0.0
Public Member Functions | Static Public Member Functions | Friends
Meta::MTime Class Reference

Time data type and operations. More...

#include <MTime.h>

Inheritance diagram for Meta::MTime:
Meta::MObjectBase

List of all members.

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)
MTimeoperator= (const MTime &time)
MTimeoperator+= (double sec)
MTimeoperator+= (const MTime &time)
MTime operator+ (double sec) const
MTime operator+ (const MTime &time) const
MTimeoperator-= (double sec)
MTimeoperator-= (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_

Detailed Description

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 & Destructor Documentation

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.

Parameters:
absolutetrue 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.

Construct a time from a node which holds a stored mvar.

Destructor.


Member Function Documentation

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.

Parameters:
yeare.g: 2005
static MTime Meta::MTime::now ( ) [static]
Returns:
The current time.
uint64_t Meta::MTime::nsec ( ) const

Return this time's nanoseconds.

MTime Meta::MTime::operator+ ( double  sec) const [inline]
Parameters:
secA seconds offset.
MTime& Meta::MTime::operator+= ( double  sec)
Parameters:
secA seconds offset.
MTime Meta::MTime::operator- ( double  sec) const [inline]
Parameters:
secA seconds offset.
MTime& Meta::MTime::operator-= ( double  sec)
Parameters:
secA 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
Returns:
A string representation of time using strftime() syntax, with the added token $nsec to reprsent nanoseconds.

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