Skip to content

TimePeriod

class TimePeriod

This class models a time period expressed by two time points, i.e. start and stop.

The default constructor create a time period of length zero, i.e. start=stop.

Functions

Name Description
TimePeriod Default constructor creates and empty time period
TimePeriod Constructs a time period from Hash.
TimePeriod Constructs a time period from two given timestamps start : Epochstamp object stop : Epochstamp object
getDuration Return the time duration (i.e. length) of a time period. Return : TimeDuration object
getStart Get the start (resp.
start Set the start (resp.
isOpen Check if period is still open (i.e. not yet stopped) Return : bool
before Check if time point (timestamp) is before, within, or after a time period.
fromHash Serialize time period to and from Hash object.

Function Details

TimePeriod

TimePeriod()

Default constructor creates and empty time period

TimePeriod(const karabo::data::Hash& hash)

Constructs a time period from Hash. Start and stop timestamps are stored under the two reserved keys "KRB_start" and "KRB_stop", respectively.

hash : Hash object ("KRB_start", any, "KRB_stop", any)

TimePeriod(const Epochstamp& start, const Epochstamp& stop)

Constructs a time period from two given timestamps

start : Epochstamp object

stop : Epochstamp object

before

bool before(const Epochstamp& tm) const

Check if time point (timestamp) is before, within, or after a time period.

tm : Epochstamp object

Return : bool

fromHash

void fromHash(const karabo::data::Hash& hash)

Serialize time period to and from Hash object.

hash : Hash object

getDuration

TimeDuration getDuration() const

Return the time duration (i.e. length) of a time period.

Return : TimeDuration object

getStart

Epochstamp getStart() const

Get the start (resp. stop) timestamp

Return : Epochstamp object

isOpen

bool isOpen() const

Check if period is still open (i.e. not yet stopped)

Return : bool

start

void start(const Epochstamp& tm = Epochstamp())

Set the start (resp. stop) timestamp. By default, it set it to the current system epoch timestamp.

tm : Epochstamp (by default, use the current system timestamp)