Sparkle 0.0.1
Loading...
Searching...
No Matches
spk::Timestamp Class Reference

Point in time with conversion helpers and arithmetic with Duration. More...

#include <spk_timestamp.hpp>

Collaboration diagram for spk::Timestamp:
Collaboration graph

Public Member Functions

 Timestamp ()
 Captures current time in nanoseconds.
 Timestamp (long double p_value, TimeUnit p_unit)
 Builds a timestamp from a raw value and unit.
 Timestamp (const Duration &p_duration)
 Builds a timestamp located after the origin by the given duration.
 Timestamp (const Timestamp &p_other)
 Copies timestamp value and caches from another instance.
 Timestamp (Timestamp &&p_other) noexcept
 Moves timestamp value and caches from another instance.
Timestampoperator= (const Timestamp &p_other)
 Copies timestamp value and caches from another instance.
Timestampoperator= (Timestamp &&p_other) noexcept
 Moves timestamp value and caches from another instance.
double seconds () const
 Returns the timestamp expressed in seconds.
long long milliseconds () const
 Returns the timestamp expressed in milliseconds.
long long nanoseconds () const
 Returns the timestamp expressed in nanoseconds.
Duration operator- (const Timestamp &p_other) const
 Computes the duration separating two timestamps.
Timestamp operator+ (const Duration &p_other) const
 Shifts the timestamp forward by a duration.
Timestamp operator- (const Duration &p_other) const
 Shifts the timestamp backward by a duration.
Timestampoperator+= (const Duration &p_other)
 Adds a duration to this timestamp in place.
Timestampoperator-= (const Duration &p_other)
 Subtracts a duration from this timestamp in place.
bool operator== (const Timestamp &p_other) const
 Equality comparison using canonical nanoseconds.
bool operator!= (const Timestamp &p_other) const
 Inequality comparison using canonical nanoseconds.
bool operator< (const Timestamp &p_other) const
 Strictly-less comparison using canonical nanoseconds.
bool operator> (const Timestamp &p_other) const
 Strictly-greater comparison using canonical nanoseconds.
bool operator<= (const Timestamp &p_other) const
 Less-or-equal comparison using canonical nanoseconds.
bool operator>= (const Timestamp &p_other) const
 Greater-or-equal comparison using canonical nanoseconds.

Detailed Description

Point in time with conversion helpers and arithmetic with Duration.

Constructor & Destructor Documentation

◆ Timestamp() [1/4]

spk::Timestamp::Timestamp ( long double p_value,
TimeUnit p_unit )

Builds a timestamp from a raw value and unit.

Parameters
p_valueNumeric representation of the moment.
p_unitUnit associated with the value.

◆ Timestamp() [2/4]

spk::Timestamp::Timestamp ( const Duration & p_duration)

Builds a timestamp located after the origin by the given duration.

Parameters
p_durationOffset from the origin time.
Here is the call graph for this function:

◆ Timestamp() [3/4]

spk::Timestamp::Timestamp ( const Timestamp & p_other)

Copies timestamp value and caches from another instance.

Parameters
p_otherTimestamp to copy.
Here is the call graph for this function:

◆ Timestamp() [4/4]

spk::Timestamp::Timestamp ( Timestamp && p_other)
noexcept

Moves timestamp value and caches from another instance.

Parameters
p_otherTimestamp to move.
Here is the call graph for this function:

Member Function Documentation

◆ milliseconds()

long long spk::Timestamp::milliseconds ( ) const

Returns the timestamp expressed in milliseconds.

Returns
Point in time as milliseconds.

◆ nanoseconds()

long long spk::Timestamp::nanoseconds ( ) const

Returns the timestamp expressed in nanoseconds.

Returns
Point in time as nanoseconds.
Here is the caller graph for this function:

◆ operator!=()

bool spk::Timestamp::operator!= ( const Timestamp & p_other) const

Inequality comparison using canonical nanoseconds.

Parameters
p_otherTimestamp to compare.
Returns
true when timestamps differ.
Here is the call graph for this function:

◆ operator+()

Timestamp spk::Timestamp::operator+ ( const Duration & p_other) const

Shifts the timestamp forward by a duration.

Parameters
p_otherDuration to add.
Returns
Updated timestamp.
Here is the call graph for this function:

◆ operator+=()

Timestamp & spk::Timestamp::operator+= ( const Duration & p_other)

Adds a duration to this timestamp in place.

Parameters
p_otherDuration to add.
Returns
Reference to this timestamp.
Here is the call graph for this function:

◆ operator-() [1/2]

Timestamp spk::Timestamp::operator- ( const Duration & p_other) const

Shifts the timestamp backward by a duration.

Parameters
p_otherDuration to subtract.
Returns
Updated timestamp.
Here is the call graph for this function:

◆ operator-() [2/2]

Duration spk::Timestamp::operator- ( const Timestamp & p_other) const

Computes the duration separating two timestamps.

Parameters
p_otherTimestamp to subtract.
Returns
Duration between the two instants.
Here is the call graph for this function:

◆ operator-=()

Timestamp & spk::Timestamp::operator-= ( const Duration & p_other)

Subtracts a duration from this timestamp in place.

Parameters
p_otherDuration to subtract.
Returns
Reference to this timestamp.
Here is the call graph for this function:

◆ operator<()

bool spk::Timestamp::operator< ( const Timestamp & p_other) const

Strictly-less comparison using canonical nanoseconds.

Parameters
p_otherTimestamp to compare.
Returns
true when this timestamp is earlier.
Here is the call graph for this function:

◆ operator<=()

bool spk::Timestamp::operator<= ( const Timestamp & p_other) const

Less-or-equal comparison using canonical nanoseconds.

Parameters
p_otherTimestamp to compare.
Returns
true when this timestamp is earlier or equal.
Here is the call graph for this function:

◆ operator=() [1/2]

Timestamp & spk::Timestamp::operator= ( const Timestamp & p_other)

Copies timestamp value and caches from another instance.

Parameters
p_otherTimestamp to copy.
Returns
Reference to this timestamp.
Here is the call graph for this function:

◆ operator=() [2/2]

Timestamp & spk::Timestamp::operator= ( Timestamp && p_other)
noexcept

Moves timestamp value and caches from another instance.

Parameters
p_otherTimestamp to move.
Returns
Reference to this timestamp.
Here is the call graph for this function:

◆ operator==()

bool spk::Timestamp::operator== ( const Timestamp & p_other) const

Equality comparison using canonical nanoseconds.

Parameters
p_otherTimestamp to compare.
Returns
true when timestamps are identical.
Here is the call graph for this function:

◆ operator>()

bool spk::Timestamp::operator> ( const Timestamp & p_other) const

Strictly-greater comparison using canonical nanoseconds.

Parameters
p_otherTimestamp to compare.
Returns
true when this timestamp is later.
Here is the call graph for this function:

◆ operator>=()

bool spk::Timestamp::operator>= ( const Timestamp & p_other) const

Greater-or-equal comparison using canonical nanoseconds.

Parameters
p_otherTimestamp to compare.
Returns
true when this timestamp is later or equal.
Here is the call graph for this function:

◆ seconds()

double spk::Timestamp::seconds ( ) const

Returns the timestamp expressed in seconds.

Returns
Point in time as seconds.

The documentation for this class was generated from the following files:
  • includes/structure/system/time/spk_timestamp.hpp
  • srcs/structure/system/time/spk_timestamp.cpp