DUECA/DUSIME
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | Friends | List of all members
dueca::TimeSpec Class Reference

A TimeSpec is a specification for a time interval. More...

#include <TimeSpec.hxx>

Inheritance diagram for dueca::TimeSpec:
Inheritance graph
[legend]
Collaboration diagram for dueca::TimeSpec:
Collaboration graph
[legend]

Public Member Functions

 TimeSpec (const TimeSpec &)
 Copy constructor.
 
 TimeSpec (TimeTickType validity_start, TimeTickType validity_end)
 Complete constructor, with the start and end time.
 
 TimeSpec (int validity_start, int validity_end)
 Complete constructor, with the start and end time.
 
 TimeSpec (TimeTickType validity_start)
 Constructor for a TimeSpec that starts and ends at the same time.
 
 TimeSpec (double validity_start, double validity_end)
 Constructor with double arguments.
 
 TimeSpec (float validity_start, float validity_end)
 Variation with float.
 
 TimeSpec (const DataTimeSpec &)
 Constructor with a DataTimeSpec as input.
 
 TimeSpec ()
 Default constructor.
 
virtual ~TimeSpec ()
 Destructor.
 
virtual TimeSpecclone () const
 This clones a TimeSpec, giving back a pointer to an identical copy.
 
virtual bool advance (const TimeSpec &a)
 Move the time forward with the data given in another TimeSpec.
 
virtual bool advance (const DataTimeSpec &a)
 Move the time forward with the data given in a DataTimeSpec.
 
virtual bool advance (const TimeTickType &validity_end=MAX_TIMETICK)
 Move the time to the next contiguous interval, that ends at the end tick specified in the parameter.
 
virtual bool forceAdvance (const TimeTickType &validity_point)
 Jump ahead in time, possibly leaving a gap.
 
virtual bool forceAdvance (const DataTimeSpec &t)
 Jump ahead in time, possibly leaving a gap.
 
TimeTickType getValidityStart () const
 Returns the time at which the interval starts.
 
TimeTickType getValidityEnd () const
 Returns the time at which the interval has ended.
 
TimeTickType getValiditySpan () const
 Returns the size of the interval.
 
bool operator== (const TimeSpec &other) const
 Compare one interval to another.
 
bool operator!= (const TimeSpec &other) const
 Compare one interval to another, and return true when not equal.
 
TimeSpec operator+ (const int delta) const
 Move an interval up with a time delta.
 
TimeSpec operator+ (const unsigned int delta) const
 Move an interval up with a time delta.
 
TimeSpec operator+ (const double delta) const
 Move an interval up with a time in seconds.
 
TimeSpec operator+ (const float delta) const
 Move an interval up with a time in seconds.
 
TimeSpec operator- (const double delta) const
 Move an interval up with a time in seconds.
 
TimeSpec operator- (const float delta) const
 Move an interval up with a time in seconds.
 
TimeSpec operator- (const int delta) const
 Move an interval back with a time delta.
 
TimeSpec operator- (const unsigned int delta) const
 Move an interval back with a time delta.
 
int operator- (const TimeSpec &to) const
 Get the difference between two timespec's.
 
TimeSpecoperator= (const DataTimeSpec &o)
 Copy from a data timespec.
 
double getDtInSeconds () const
 Get the value of the interval in seconds.
 
int getUsecsElapsed () const
 Find out how many microseconds elapsed since the formal start of this time.
 
ostreamprint (ostream &os) const
 Write to stream, mainly for debugging purposes.
 

Static Public Member Functions

static const TimeSpecendOfTime ()
 The time spec at the end of time.
 
static const TimeSpecstartOfTime ()
 The time spec at the beginning of time.
 

Static Public Attributes

static const TimeSpec end_of_time
 A special time spec at the end of time.
 
static const TimeSpec start_of_time
 Timespec at the start of time.
 

Protected Attributes

TimeTickType validity_start
 The time interval starts here.
 
TimeTickType validity_end
 The time interval ends before this.
 

Friends

struct DataTimeSpec
 
class PeriodicTimeSpec
 

Detailed Description

A TimeSpec is a specification for a time interval.

It is given in integer time steps, and defines the step from which the time interval is valid, and the step from which it is no longer valid.

Constructor & Destructor Documentation

◆ TimeSpec() [1/5]

dueca::TimeSpec::TimeSpec ( TimeTickType validity_start,
TimeTickType validity_end )

Complete constructor, with the start and end time.

Parameters
validity_starttime tick at which data becomes valid
validity_endtime tick at which data (calc, etc.) becomes invalid.

◆ TimeSpec() [2/5]

dueca::TimeSpec::TimeSpec ( int validity_start,
int validity_end )

Complete constructor, with the start and end time.

This time an integer variation, since often simply integer arguments are given.

Parameters
validity_starttime tick at which data becomes valid
validity_endtime tick at which data (calc, etc.) becomes invalid.

◆ TimeSpec() [3/5]

dueca::TimeSpec::TimeSpec ( TimeTickType validity_start)

Constructor for a TimeSpec that starts and ends at the same time.

For example events are like this.

◆ TimeSpec() [4/5]

dueca::TimeSpec::TimeSpec ( double validity_start,
double validity_end )

Constructor with double arguments.

Note that the argument will be converted to time ticks, and that rounding off may occur.

If start and end are not exactly (as in floating point exactly) equal, the integer end time tick will always be at least one higher than the start time tick. This is to prevent creation of 0 timespans, which can produce infinite loops in clocks.

Parameters
validity_starttime (in s!) at which data becomes valid
validity_endtime (in s!) at which data (calc, etc.) becomes invalid.

◆ TimeSpec() [5/5]

dueca::TimeSpec::TimeSpec ( float validity_start,
float validity_end )

Variation with float.

Note that the argument will be converted to time ticks, and that rounding off may occur.

If start and end are not exactly (as in floating point exactly) equal, the integer end time tick will always be at least one higher than the start time tick. This is to prevent creation of 0 timespans, which can produce infinite loops in clocks.

Parameters
validity_starttime (in s!) at which data becomes valid
validity_endtime (in s!) at which data (calc, etc.) becomes invalid.

Member Function Documentation

◆ clone()

virtual TimeSpec * dueca::TimeSpec::clone ( ) const
virtual

This clones a TimeSpec, giving back a pointer to an identical copy.

Also clones the derived classes.

Reimplemented in dueca::PeriodicTimeSpec.

◆ advance() [1/3]

virtual bool dueca::TimeSpec::advance ( const TimeSpec & a)
virtual

Move the time forward with the data given in another TimeSpec.

Parameters
aTimeSpec with new times.

Reimplemented in dueca::PeriodicTimeSpec.

◆ advance() [2/3]

virtual bool dueca::TimeSpec::advance ( const DataTimeSpec & a)
virtual

Move the time forward with the data given in a DataTimeSpec.

Parameters
aTimeSpec with new times.

Reimplemented in dueca::PeriodicTimeSpec.

◆ advance() [3/3]

virtual bool dueca::TimeSpec::advance ( const TimeTickType & validity_end = MAX_TIMETICK)
virtual

Move the time to the next contiguous interval, that ends at the end tick specified in the parameter.

Reimplemented in dueca::PeriodicTimeSpec.

◆ forceAdvance() [1/2]

virtual bool dueca::TimeSpec::forceAdvance ( const TimeTickType & validity_point)
virtual

Jump ahead in time, possibly leaving a gap.

This does not do great wonders for a TimeSpec, but a PeriodicTimeSpec (one of the derived classes) has different behaviour to an advance and a forceAdvance.

Reimplemented in dueca::PeriodicTimeSpec.

◆ forceAdvance() [2/2]

virtual bool dueca::TimeSpec::forceAdvance ( const DataTimeSpec & t)
virtual

Jump ahead in time, possibly leaving a gap.

Reimplemented in dueca::PeriodicTimeSpec.


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