All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Classes | Public Member Functions | List of all members
ndn::Interval Class Reference

An Interval defines a time duration which contains a start timestamp and an end timestamp. More...

#include <interval.hpp>

Classes

class  Error
 Interval.Error extends std::exception for errors using Interval methods. More...
 

Public Member Functions

 Interval (bool isValid=false)
 Create an Interval with the given validity value. More...
 
 Interval (MillisecondsSince1970 startTime, MillisecondsSince1970 endTime)
 Create a valid Interval with the given start and end times. More...
 
void set (const Interval &interval)
 Set this interval to have the same values as the other interval. More...
 
bool covers (MillisecondsSince1970 timePoint) const
 Check if the time point is in this interval. More...
 
IntervalintersectWith (const Interval &interval)
 Set this Interval to the intersection of this and the other interval. More...
 
IntervalunionWith (const Interval &interval)
 Set this Interval to the union of this and the other interval. More...
 
MillisecondsSince1970 getStartTime () const
 Get the start time. More...
 
MillisecondsSince1970 getEndTime () const
 Get the end time. More...
 
bool isValid () const
 Check if this Interval is valid. More...
 
bool isEmpty () const
 Check if this Interval is empty. More...
 

Detailed Description

An Interval defines a time duration which contains a start timestamp and an end timestamp.

Note
This class is an experimental feature. The API may change.

Constructor & Destructor Documentation

ndn::Interval::Interval ( bool  isValid = false)

Create an Interval with the given validity value.

Parameters
isValid(optional) True to create a valid empty interval, false to create an invalid interval. If omitted, create an invalid interval.
ndn::Interval::Interval ( MillisecondsSince1970  startTime,
MillisecondsSince1970  endTime 
)

Create a valid Interval with the given start and end times.

The start time must be less than the end time. To create an empty interval (start time equals end time), use the constructor Interval(true).

Parameters
startTimeThe start time as milliseconds since Jan 1, 1970 UTC.
endTimeThe end time as milliseconds since Jan 1, 1970 UTC.

Member Function Documentation

bool ndn::Interval::covers ( MillisecondsSince1970  timePoint) const

Check if the time point is in this interval.

Parameters
timePointThe time point to check as milliseconds since Jan 1, 1970 UTC.
Returns
True if timePoint is in this interval.
MillisecondsSince1970 ndn::Interval::getEndTime ( ) const

Get the end time.

Returns
The end time as milliseconds since Jan 1, 1970 UTC.
MillisecondsSince1970 ndn::Interval::getStartTime ( ) const

Get the start time.

Returns
The start time as milliseconds since Jan 1, 1970 UTC.
Interval & ndn::Interval::intersectWith ( const Interval interval)

Set this Interval to the intersection of this and the other interval.

This and the other interval should be valid but either can be empty.

Parameters
intervalThe other Interval to intersect with.
Returns
This Interval.
bool ndn::Interval::isEmpty ( ) const

Check if this Interval is empty.

Returns
True if this Interval is empty (start time equals end time), false if not.
bool ndn::Interval::isValid ( ) const
inline

Check if this Interval is valid.

Returns
True if this interval is valid, false if invalid.
void ndn::Interval::set ( const Interval interval)
inline

Set this interval to have the same values as the other interval.

Parameters
intervalThe other Interval with values to copy.
Interval & ndn::Interval::unionWith ( const Interval interval)

Set this Interval to the union of this and the other interval.

This and the other interval should be valid but either can be empty. This and the other interval should have an intersection. (Contiguous intervals are not allowed.)

Parameters
intervalThe other Interval to union with.
Returns
This Interval.
Exceptions
Interval::Errorif the two intervals do not have an intersection.

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