Thunderbots Project
Loading...
Searching...
No Matches
Duration Class Reference

#include <duration.h>

Inheritance diagram for Duration:
Collaboration diagram for Duration:

Public Member Functions

 Duration ()
 
bool operator== (const Duration &other) const
 
bool operator!= (const Duration &other) const
 
bool operator< (const Duration &other) const
 
bool operator<= (const Duration &other) const
 
bool operator> (const Duration &other) const
 
bool operator>= (const Duration &other) const
 
Duration operator+ (const Duration &duration) const
 
Duration operator- (const Duration &duration) const
 
Durationoperator+= (const Duration &duration)
 
Durationoperator-= (const Duration &duration)
 
- Public Member Functions inherited from Time
 Time ()
 
double toSeconds () const
 
double toMilliseconds () const
 
virtual ~Time ()=0
 

Static Public Member Functions

static const Duration fromSeconds (double seconds)
 
static const Duration fromMilliseconds (double milliseconds)
 

Friends

std::ostream & operator<< (std::ostream &output_stream, const Duration &duration)
 

Additional Inherited Members

- Static Public Attributes inherited from Time
static constexpr double EPSILON = 1e-15
 
- Protected Member Functions inherited from Time
 Time (double time_seconds)
 
- Protected Attributes inherited from Time
double time_in_seconds
 

Detailed Description

A simple Duration class built around doubles. It is meant to represent some duration of time

Constructor & Destructor Documentation

◆ Duration()

Duration ( )

The default constructor for a Duration. Creates a Duration of length 0

Member Function Documentation

◆ fromMilliseconds()

const Duration fromMilliseconds ( double  milliseconds)
static

Creates a new Duration value from a value in milliseconds

Parameters
millisecondsA value in milliseconds, from which to create the Duration
Returns
A Duration created from the given value

◆ fromSeconds()

const Duration fromSeconds ( double  seconds)
static

Creates a new Duration value from a value in seconds.

Parameters
secondsA value in seconds, from which to create the Duration
Returns
A Duration created from the given value

◆ operator!=()

bool operator!= ( const Duration other) const

Compares Durations for inequality

Parameters
otherthe Duration to compare with for inequality
Returns
true if the Durations are not equal, and false otherwise

◆ operator+()

Duration operator+ ( const Duration duration) const

Defines the addition operator for Durations. Allows Durations to be added to Durations

Parameters
durationthe duration to add to this Duration
Returns
A new Duration with the given Duration added to this Duration

◆ operator+=()

Duration & operator+= ( const Duration duration)

Defines the addition compound assignment operator for Durations. Allows Duration to be increased by another Duration

Parameters
durationthe duration to add to this Duration
Returns
Reference to the duration that was updated

◆ operator-()

Duration operator- ( const Duration duration) const

Defines the subtraction operator for Durations. Allows Durations to be subtracted from Durations

Parameters
durationthe Duration to subtract from this Duration
Returns
A new Duration with the given Duration subtracted from this current Duration

◆ operator-=()

Duration & operator-= ( const Duration duration)

Defines the subtraction compound assignment operator for Durations. Allows Duration to be subtracted from this Durations

Parameters
durationthe Duration to subtract from this Duration
Returns
Reference to the duration that was updated

◆ operator<()

bool operator< ( const Duration other) const

Defines the "less than" operator. Returns true if this Duration is strictly less than (and not equal to) the other Duration

Parameters
otherthe Duration to compare with
Returns
true if this Duration is strictly less than (and not equal to) the other Duration, and false otherwise

◆ operator<=()

bool operator<= ( const Duration other) const

Defines the "less than or equal to" operator. Returns true if this Duration is less than or equal to the other Duration

Parameters
otherthe Duration to compare with
Returns
true if this Duration is less than or equal to the other Duration, and false otherwise

◆ operator==()

bool operator== ( const Duration other) const

Compares Durations for equality. Durations are considered equal if their values in seconds are within EPSILON from one another.

Parameters
otherthe Duration to compare with for equality
Returns
true if the Durations are equal and false otherwise

◆ operator>()

bool operator> ( const Duration other) const

Defines the "greater than" operator. Returns true if this Duration is strictly greater than (and not equal to) the other Duration

Parameters
otherthe Duration to compare with
Returns
true if this Duration is strictly greater than (and not equal to) the other Duration, and false otherwise

◆ operator>=()

bool operator>= ( const Duration other) const

Defines the "greater than or equal to" operator. Returns true if this Duration is greater than or equal to the other Duration

Parameters
otherthe Duration to compare with
Returns
true if this Duration is greater than or equal to the other Duration, and false otherwise

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  output_stream,
const Duration duration 
)
friend

Implements the << operator for printing

Parameters
ostreamThe stream to print to
timeThe time to print
Returns
The output stream with the string representation of the class appended

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