OpenEnroth 73e68f7
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Attributes | Friends | List of all members
Duration Class Reference

#include <Duration.h>

Public Member Functions

constexpr Duration ()=default
 
constexpr Duration (int seconds, int minutes, int hours, int days, int weeks, int months, int years)
 
constexpr int64_t ticks () const
 
constexpr int64_t seconds () const
 
constexpr int64_t minutes () const
 
constexpr int64_t hours () const
 
constexpr int days () const
 
constexpr int weeks () const
 
constexpr int months () const
 
constexpr int years () const
 
constexpr int64_t realtimeSeconds () const
 
constexpr int64_t realtimeMilliseconds () const
 
constexpr float realtimeMillisecondsFloat () const
 
constexpr CivilDuration toCivilDuration () const
 
constexpr LongCivilDuration toLongCivilDuration () const
 
constexpr Duration roundedUp (Duration period) const
 
constexpr Duration roundedDown (Duration period) const
 
constexpr Durationoperator+= (Duration rhs)
 
constexpr Durationoperator-= (Duration rhs)
 
template<class R >
requires std::is_arithmetic_v<R>
constexpr Durationoperator*= (R r)
 
template<class R >
requires std::is_arithmetic_v<R>
constexpr Durationoperator/= (R r)
 
constexpr operator bool () const
 

Static Public Member Functions

static constexpr Duration fromTicks (int64_t ticks)
 
static constexpr Duration fromSeconds (int seconds)
 
static constexpr Duration fromMinutes (int minutes)
 
static constexpr Duration fromHours (int hours)
 
static constexpr Duration fromDays (int days)
 
static constexpr Duration fromMonths (int months)
 
static constexpr Duration fromYears (int years)
 
static constexpr Duration fromRealtimeSeconds (int64_t seconds)
 
static constexpr Duration fromRealtimeMilliseconds (int64_t msec)
 
static Duration random (RandomEngine *rng, Duration hi)
 
static Duration randomRealtimeMilliseconds (RandomEngine *rng, int64_t hi)
 
static Duration randomRealtimeMilliseconds (RandomEngine *rng, int64_t lo, int64_t hi)
 
static Duration randomRealtimeSeconds (RandomEngine *rng, int64_t hi)
 
static Duration randomRealtimeSeconds (RandomEngine *rng, int64_t lo, int64_t hi)
 

Static Public Attributes

static constexpr int64_t TICKS_PER_REALTIME_SECOND = 128
 
static constexpr int64_t GAME_SECONDS_IN_REALTIME_SECOND = 30
 

Private Attributes

int64_t _ticks = 0
 

Friends

constexpr friend Duration operator+ (Duration l, Duration r)
 
constexpr friend Duration operator- (Duration l, Duration r)
 
template<class L >
requires std::is_arithmetic_v<L>
constexpr friend Duration operator* (L l, Duration r)
 
template<class R >
requires std::is_arithmetic_v<R>
constexpr friend Duration operator* (Duration l, R r)
 
template<class R >
requires std::is_arithmetic_v<R>
constexpr friend Duration operator/ (Duration l, R r)
 
constexpr friend int64_t operator/ (Duration l, Duration r)
 
constexpr friend Duration operator% (Duration l, Duration r)
 
constexpr friend bool operator== (Duration l, Duration r)=default
 
constexpr friend auto operator<=> (Duration l, Duration r)=default
 

Constructor & Destructor Documentation

◆ Duration() [1/2]

constexpr Duration::Duration ( )
constexprdefault

◆ Duration() [2/2]

constexpr Duration::Duration ( int  seconds,
int  minutes,
int  hours,
int  days,
int  weeks,
int  months,
int  years 
)
inlineconstexpr

Member Function Documentation

◆ days()

constexpr int Duration::days ( ) const
inlineconstexpr

◆ fromDays()

static constexpr Duration Duration::fromDays ( int  days)
inlinestaticconstexpr

◆ fromHours()

static constexpr Duration Duration::fromHours ( int  hours)
inlinestaticconstexpr

◆ fromMinutes()

static constexpr Duration Duration::fromMinutes ( int  minutes)
inlinestaticconstexpr

◆ fromMonths()

static constexpr Duration Duration::fromMonths ( int  months)
inlinestaticconstexpr

◆ fromRealtimeMilliseconds()

static constexpr Duration Duration::fromRealtimeMilliseconds ( int64_t  msec)
inlinestaticconstexpr

◆ fromRealtimeSeconds()

static constexpr Duration Duration::fromRealtimeSeconds ( int64_t  seconds)
inlinestaticconstexpr

◆ fromSeconds()

static constexpr Duration Duration::fromSeconds ( int  seconds)
inlinestaticconstexpr

◆ fromTicks()

static constexpr Duration Duration::fromTicks ( int64_t  ticks)
inlinestaticconstexpr

◆ fromYears()

static constexpr Duration Duration::fromYears ( int  years)
inlinestaticconstexpr

◆ hours()

constexpr int64_t Duration::hours ( ) const
inlineconstexpr

◆ minutes()

constexpr int64_t Duration::minutes ( ) const
inlineconstexpr

◆ months()

constexpr int Duration::months ( ) const
inlineconstexpr

◆ operator bool()

constexpr Duration::operator bool ( ) const
inlineexplicitconstexpr

◆ operator*=()

template<class R >
requires std::is_arithmetic_v<R>
constexpr Duration & Duration::operator*= ( r)
inlineconstexpr

◆ operator+=()

constexpr Duration & Duration::operator+= ( Duration  rhs)
inlineconstexpr

◆ operator-=()

constexpr Duration & Duration::operator-= ( Duration  rhs)
inlineconstexpr

◆ operator/=()

template<class R >
requires std::is_arithmetic_v<R>
constexpr Duration & Duration::operator/= ( r)
inlineconstexpr

◆ random()

Duration Duration::random ( RandomEngine rng,
Duration  hi 
)
static

◆ randomRealtimeMilliseconds() [1/2]

Duration Duration::randomRealtimeMilliseconds ( RandomEngine rng,
int64_t  hi 
)
static

◆ randomRealtimeMilliseconds() [2/2]

Duration Duration::randomRealtimeMilliseconds ( RandomEngine rng,
int64_t  lo,
int64_t  hi 
)
static

◆ randomRealtimeSeconds() [1/2]

Duration Duration::randomRealtimeSeconds ( RandomEngine rng,
int64_t  hi 
)
static

◆ randomRealtimeSeconds() [2/2]

Duration Duration::randomRealtimeSeconds ( RandomEngine rng,
int64_t  lo,
int64_t  hi 
)
static

◆ realtimeMilliseconds()

constexpr int64_t Duration::realtimeMilliseconds ( ) const
inlineconstexpr

◆ realtimeMillisecondsFloat()

constexpr float Duration::realtimeMillisecondsFloat ( ) const
inlineconstexpr

◆ realtimeSeconds()

constexpr int64_t Duration::realtimeSeconds ( ) const
inlineconstexpr

◆ roundedDown()

constexpr Duration Duration::roundedDown ( Duration  period) const
inlineconstexpr

◆ roundedUp()

constexpr Duration Duration::roundedUp ( Duration  period) const
inlineconstexpr

◆ seconds()

constexpr int64_t Duration::seconds ( ) const
inlineconstexpr

◆ ticks()

constexpr int64_t Duration::ticks ( ) const
inlineconstexpr

◆ toCivilDuration()

constexpr CivilDuration Duration::toCivilDuration ( ) const
inlineconstexpr

◆ toLongCivilDuration()

constexpr LongCivilDuration Duration::toLongCivilDuration ( ) const
inlineconstexpr

◆ weeks()

constexpr int Duration::weeks ( ) const
inlineconstexpr

◆ years()

constexpr int Duration::years ( ) const
inlineconstexpr

Friends And Related Function Documentation

◆ operator%

constexpr friend Duration operator% ( Duration  l,
Duration  r 
)
friend

◆ operator* [1/2]

template<class R >
requires std::is_arithmetic_v<R>
constexpr friend Duration operator* ( Duration  l,
r 
)
friend

◆ operator* [2/2]

template<class L >
requires std::is_arithmetic_v<L>
constexpr friend Duration operator* ( l,
Duration  r 
)
friend

◆ operator+

constexpr friend Duration operator+ ( Duration  l,
Duration  r 
)
friend

◆ operator-

constexpr friend Duration operator- ( Duration  l,
Duration  r 
)
friend

◆ operator/ [1/2]

constexpr friend int64_t operator/ ( Duration  l,
Duration  r 
)
friend

◆ operator/ [2/2]

template<class R >
requires std::is_arithmetic_v<R>
constexpr friend Duration operator/ ( Duration  l,
r 
)
friend

◆ operator<=>

constexpr friend auto operator<=> ( Duration  l,
Duration  r 
)
friend

◆ operator==

constexpr friend bool operator== ( Duration  l,
Duration  r 
)
friend

Member Data Documentation

◆ _ticks

int64_t Duration::_ticks = 0
private

◆ GAME_SECONDS_IN_REALTIME_SECOND

constexpr int64_t Duration::GAME_SECONDS_IN_REALTIME_SECOND = 30
staticconstexpr

◆ TICKS_PER_REALTIME_SECOND

constexpr int64_t Duration::TICKS_PER_REALTIME_SECOND = 128
staticconstexpr

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