TimeValue Class Reference

#include <timevalue.h>

Inheritance diagram for TimeValue:

Detailed Description

The TimeValue class encapsulates a timer value.

Classes

class  CurrentTime
 

Public Member Functions

 TimeValue ()
 
 TimeValue (CurrentTime)
 
 TimeValue (ENUM_DONT_INITIALIZE v)
 
 TimeValue (const TimeValue &src)
 
 TimeValue (Int frame, Float64 frameRate)
 
TimeValueoperator= (const TimeValue &src)
 
 MAXON_OPERATOR_EQUALITY_HASHCODE (TimeValue, _value)
 
Bool operator< (const TimeValue &b) const
 
 MAXON_OPERATOR_INEQUALITY (TimeValue)
 
TimeValue operator+ (const TimeValue &b) const
 
TimeValueoperator+= (const TimeValue &b)
 
TimeValue operator- (const TimeValue &b) const
 
const TimeValueoperator-= (const TimeValue &b)
 
TimeValueoperator*= (const Float64 b)
 
Float64 GetHours () const
 
void SetHours (Float64 hours)
 
Float64 GetMinutes () const
 
void SetMinutes (Float64 minutes)
 
Float64 GetSeconds () const
 
void SetSeconds (Float64 seconds)
 
Float64 GetMilliseconds () const
 
void SetMilliseconds (Float64 milliseconds)
 
Float64 GetMicroseconds () const
 
void SetMicroseconds (Float64 microseconds)
 
Float64 GetNanoseconds () const
 
void SetNanoseconds (Float64 nanoseconds)
 
const TimeValueStop ()
 
String ToString (const FormatStatement *formatStatement=nullptr) const
 
Int GetFrame (Float64 frameRate) const
 
void Quantize (Float64 frameRate)
 
String TimeToString (TIMEFORMAT timeFormat=TIMEFORMAT::SECONDS, Float64 frameRate=1) const
 
Result< void > TimeFromString (const String &str, TIMEFORMAT timeFormat, Float64 frameRate)
 

Static Public Member Functions

static TimeValue GetTime ()
 
static Result< void > DescribeIO (const DataSerializeInterface &stream)
 

Static Public Attributes

static const CurrentTime NOW
 

Protected Member Functions

 TimeValue (Float64 seconds)
 

Private Attributes

Float64 _value
 

Friends

TimeValue operator* (const TimeValue &a, const Float64 &b)
 
Float64 operator/ (const TimeValue &a, const TimeValue &b)
 
TimeValue operator/ (const TimeValue &a, const Float64 b)
 

Constructor & Destructor Documentation

◆ TimeValue() [1/6]

TimeValue ( )

Default constructor.

◆ TimeValue() [2/6]

TimeValue ( CurrentTime  )
explicit

Initialize with the current time stamp.

◆ TimeValue() [3/6]

Don't initialize class (for better speed)

◆ TimeValue() [4/6]

TimeValue ( const TimeValue src)

Default constructor.

◆ TimeValue() [5/6]

TimeValue ( Int  frame,
Float64  frameRate 
)
explicit

construct a time from an integer frame number and a frame rate. the frame rate doesn't need to be an integer and can e.g. be FRAMERATE_NTSC (29.97)

◆ TimeValue() [6/6]

TimeValue ( Float64  seconds)
explicitprotected

Member Function Documentation

◆ operator=()

TimeValue& operator= ( const TimeValue src)

Assignment operator.

◆ MAXON_OPERATOR_EQUALITY_HASHCODE()

MAXON_OPERATOR_EQUALITY_HASHCODE ( TimeValue  ,
_value   
)

◆ operator<()

Bool operator< ( const TimeValue b) const

Compares two TimeValues.

◆ MAXON_OPERATOR_INEQUALITY()

MAXON_OPERATOR_INEQUALITY ( TimeValue  )

◆ operator+()

TimeValue operator+ ( const TimeValue b) const

Adds two TimeValues.

◆ operator+=()

TimeValue& operator+= ( const TimeValue b)

Adds two TimeValues.

◆ operator-()

TimeValue operator- ( const TimeValue b) const

Subtracts two TimeValues.

◆ operator-=()

const TimeValue& operator-= ( const TimeValue b)

Subtracts two TimeValues.

◆ operator*=()

TimeValue& operator*= ( const Float64  b)

Multiplies a TimeValue with a factor.

Parameters
[in]bThe second factor.
Returns
The result of this * b.

◆ GetHours()

Float64 GetHours ( ) const

Get the TimerValue

Returns
Time value in hours.

◆ SetHours()

void SetHours ( Float64  hours)

Set the TimeValue

Parameters
[in]hoursTime value in hours.

◆ GetMinutes()

Float64 GetMinutes ( ) const

Get the TimeValue

Returns
Time value in minutes.

◆ SetMinutes()

void SetMinutes ( Float64  minutes)

Set the TimeValue

Parameters
[in]minutesTime value in minutes.

◆ GetSeconds()

Float64 GetSeconds ( ) const

Get the TimeValue

Returns
Time value in seconds.

◆ SetSeconds()

void SetSeconds ( Float64  seconds)

Set the TimeValue

Parameters
[in]secondstime value in seconds

◆ GetMilliseconds()

Float64 GetMilliseconds ( ) const

Get the TimeValue

Returns
time value in milliseconds

◆ SetMilliseconds()

void SetMilliseconds ( Float64  milliseconds)

Set the TimeValue

Parameters
[in]millisecondstime value in milliseconds

◆ GetMicroseconds()

Float64 GetMicroseconds ( ) const

Get the TimeValue

Returns
time value in microseconds

◆ SetMicroseconds()

void SetMicroseconds ( Float64  microseconds)

Set the TimeValue

Parameters
[in]microsecondstime value in microseconds

◆ GetNanoseconds()

Float64 GetNanoseconds ( ) const

Get the TimeValue

Returns
time value in nanoseconds

◆ SetNanoseconds()

void SetNanoseconds ( Float64  nanoseconds)

Set the TimeValue

Parameters
[in]nanosecondstime value in nanoseconds

◆ GetTime()

static TimeValue GetTime ( )
static

Returns the current time stamp. You can use this value for benchmarking/profiling. The resolution is much higher than milliseconds.

Returns
Current time stamp.

◆ Stop()

const TimeValue& Stop ( )

Gets the current time and subtracts it from the value stored in the TimeValue.

... do anything ...
t1.Stop();
DiagnosticOutput("Duration: @", t1);
static TimeValue GetTime()
TimeValue()
Default constructor.
Definition: timevalue.h:42
#define DiagnosticOutput(formatString,...)
Definition: debugdiagnostics.h:176
Returns
Returns the timer difference.

◆ ToString()

String ToString ( const FormatStatement formatStatement = nullptr) const

Converts the value into a string.

Parameters
[in]formatStatementNullptr or an additional formatting instruction. See also Formatting Timer values.
Returns
The converted result.

◆ GetFrame()

Int GetFrame ( Float64  frameRate) const

retrieve frame number for a given frame rate. note that frame numbers are integer and therefore quantized

◆ Quantize()

void Quantize ( Float64  frameRate)

quantize the time for a given frame rate, so that its frame value is a multiple of the specified frame rate

◆ TimeToString()

String TimeToString ( TIMEFORMAT  timeFormat = TIMEFORMAT::SECONDS,
Float64  frameRate = 1 
) const

Convert TimeValue into String.

Parameters
[in]timeFormatSpecifies the display format. In case of TIMEFORMAT::SECONDS the string will contain a floating point number with two digits after the comma.
In case of TIMEFORMAT::FRAMES the string will contain an integer frame number or -if the time does not fall on frame boundaries- a floating point number with two digits after the comma.
In case of TIMEFORMAT::SMPTE the return will have the format HH:MM:SS:FF. Frames are always integer values.
In case of TIMEFORMAT::SMPTE_DROPFRAMES the return will have the format HH;MM;SS;FF. Note the semicolons instead of the colons. Read more about drop frames here. A TimeValue(3600.0) equals a drop frame time code of 01:00:03:18 (3600 * 30 frames take roughly 1 hour and 3.6 seconds to play back at NTSC frame rate). If the passed frame rate does not match FRAMERATE_NTSC or FRAMERATE_FILM_NTSC the result will be as if TIMEFORMAT::SMPTE was passed.
[in]frameRateThe used frame rate, does not need to be provided if TIMEFORMAT::SECONDS is set.
Returns
The time as a readable string.

◆ TimeFromString()

Result<void> TimeFromString ( const String str,
TIMEFORMAT  timeFormat,
Float64  frameRate 
)

Convert String into TimeValue.

Parameters
[in]strThe string to be converted.
[in]timeFormatSpecifies the format of the passed string. See also TimeValue::ToString. In case of a SMPTE format drop frame or non-drop frame style is determined by this value and both colons or semicolons are allowed.
[in]frameRateThe used frame rate, does not need to be provided if TIMEFORMAT::SECONDS is set.
Returns
OK on success.

◆ DescribeIO()

static Result<void> DescribeIO ( const DataSerializeInterface stream)
static

Describe all elements of this class for I/O operations.

Parameters
[in]streamThe stream that is used to register the class members.
Returns
OK on success.

Friends And Related Function Documentation

◆ operator*

TimeValue operator* ( const TimeValue a,
const Float64 b 
)
friend

Multiplies a TimeValue with a factor.

Parameters
[in]aThe first factor.
[in]bThe second factor.
Returns
The result of a * b.

◆ operator/ [1/2]

Float64 operator/ ( const TimeValue a,
const TimeValue b 
)
friend

Divides two TimeValues and returns the quotient.

Parameters
[in]aThe dividend.
[in]bThe divisor. If the divisor is 0, the result will be undefined (floating point exception).
Returns
The result of a / b, the quotient has unit therefore it is returned as Float64.

◆ operator/ [2/2]

TimeValue operator/ ( const TimeValue a,
const Float64  b 
)
friend

Divides a TimeValues by a scalar and returns the quotient.

Parameters
[in]aThe dividend.
[in]bThe divisor. If the divisor is 0, the result will be undefined (floating point exception).
Returns
The result of a / b.

Member Data Documentation

◆ NOW

const CurrentTime NOW
static

◆ _value

Float64 _value
private