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

A RepetitiveInterval is an advanced interval which can repeat and can be used to find a simple Interval that a time point falls in. More...

#include <repetitive-interval.hpp>

Classes

class  Result
 

Public Types

enum  RepeatUnit { NONE = 0, DAY = 1, MONTH = 2, YEAR = 3 }
 

Public Member Functions

 RepetitiveInterval ()
 Create a default RepetitiveInterval with one day duration, non-repeating.
 
 RepetitiveInterval (MillisecondsSince1970 startDate, MillisecondsSince1970 endDate, int intervalStartHour, int intervalEndHour, int nRepeats=0, RepeatUnit repeatUnit=RepeatUnit::NONE)
 Create a RepetitiveInterval with the given values. More...
 
Result getInterval (MillisecondsSince1970 timePoint) const
 Get an interval that covers the time point. More...
 
int compare (const RepetitiveInterval &other) const
 Compare this to the other RepetitiveInterval. More...
 
MillisecondsSince1970 getStartDate () const
 Get the start date. More...
 
MillisecondsSince1970 getEndDate () const
 Get the end date. More...
 
int getIntervalStartHour () const
 Get the interval start hour. More...
 
int getIntervalEndHour () const
 Get the interval end hour. More...
 
int getNRepeats () const
 Get the number of repeats. More...
 
RepeatUnit getRepeatUnit () const
 Get the repeat unit. More...
 

Friends

class Schedule
 

Detailed Description

A RepetitiveInterval is an advanced interval which can repeat and can be used to find a simple Interval that a time point falls in.

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

Constructor & Destructor Documentation

ndn::RepetitiveInterval::RepetitiveInterval ( MillisecondsSince1970  startDate,
MillisecondsSince1970  endDate,
int  intervalStartHour,
int  intervalEndHour,
int  nRepeats = 0,
RepeatUnit  repeatUnit = RepeatUnit::NONE 
)

Create a RepetitiveInterval with the given values.

startDate must be earlier than or same as endDate. intervalStartHour must be less than intervalEndHour.

Parameters
startDateThe start date as milliseconds since Jan 1, 1970 UTC.
endDateThe end date as milliseconds since Jan 1, 1970 UTC.
intervalStartHourThe start hour in the day, from 0 to 23.
intervalEndHourThe end hour in the day from 1 to 24.
nRepeats(optional) Repeat the interval nRepeats repetitions, every unit, until endDate. If ommitted, use 0.
repeatUnit(optional) The unit of the repetition. If this is NONE or omitted, then startDate must equal endDate. If omitted, use NONE.
Exceptions
runtime_errorif the above conditions are not met.

Member Function Documentation

int ndn::RepetitiveInterval::compare ( const RepetitiveInterval other) const

Compare this to the other RepetitiveInterval.

Parameters
otherThe other RepetitiveInterval to compare to.
Returns
-1 if this is less than the other, 1 if greater and 0 if equal.
MillisecondsSince1970 ndn::RepetitiveInterval::getEndDate ( ) const
inline

Get the end date.

Returns
The end date as milliseconds since Jan 1, 1970 UTC.
RepetitiveInterval::Result ndn::RepetitiveInterval::getInterval ( MillisecondsSince1970  timePoint) const

Get an interval that covers the time point.

If there is no interval covering the time point, this returns false for isPositive and returns a negative interval.

Parameters
timePointThe time point as milliseconds since Jan 1, 1970 UTC.
Returns
An object with fields (isPositive, interval) where isPositive is true if the returned interval is positive or false if negative, and interval is the Interval covering the time point or a negative interval if not found.
int ndn::RepetitiveInterval::getIntervalEndHour ( ) const
inline

Get the interval end hour.

Returns
The interval end hour.
int ndn::RepetitiveInterval::getIntervalStartHour ( ) const
inline

Get the interval start hour.

Returns
The interval start hour.
int ndn::RepetitiveInterval::getNRepeats ( ) const
inline

Get the number of repeats.

Returns
The number of repeats.
RepeatUnit ndn::RepetitiveInterval::getRepeatUnit ( ) const
inline

Get the repeat unit.

Returns
The repeat unit.
MillisecondsSince1970 ndn::RepetitiveInterval::getStartDate ( ) const
inline

Get the start date.

Returns
The start date as milliseconds since Jan 1, 1970 UTC.

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