About
maxon::TimeValue is a MAXON API class used to create an object capable of handling time-related actions. A maxon::TimeValue object stores information on different time-scale basis, actually from hours to nanoseconds, making it possible to deliver unprecedented time granularity.
Creation and Initialization
A maxon::TimeValue can be created on the stack and initialized through the proper method:
The TimeValue class encapsulates a timer value.
Definition: timevalue.h:33
static const CurrentTime NOW
Definition: timevalue.h:37
const Float64 FRAMERATE_FILM_NTSC
Modified movie frame rate to avoid frame roll when transfering video to NTSC, approx....
Definition: timevalue.h:18
A value can be assigned to a maxon::TimeValue by using the assignment operator:
Definition: timevalue.h:35
Standard Operations
A maxon::TimeValue can be modified by using standard operators:
sum0A += timevalueA;
productA6 *= 2.0;
Float64 Float
Definition: apibase.h:197
Comparison
A maxon::TimeValue can be compared by using standard mathematical-like operators:
if (timevalueA < timevalueB)
DiagnosticOutput(diagIDString +
"timevalueA [@] is smaller than timevalueB [@]", timevalueA, timevalueB);
else if (timevalueA == timevalueB)
DiagnosticOutput(diagIDString +
"timevalueA [@] is equal to timevalueB [@]", timevalueA, timevalueB);
else
DiagnosticOutput(diagIDString +
"timevalueA [@] is grater than timevalueB [@]", timevalueA, timevalueB);
#define DiagnosticOutput(formatString,...)
Definition: debugdiagnostics.h:176
- Note
- From the above operators all the remaining operators (!=, >, >=, <=) are build and can thus be used as normal, too.
Get and Set operations
The value stored in a maxon::TimeValue can be set using:
Similarly the value stored in a maxon::TimeValue can be retrieved using:
timevalueFinal += timevalueSet;
timevalueFinal += timevalueSet;
timevalueFinal += timevalueSet;
timevalueFinal += timevalueSet;
timevalueFinal += timevalueSet;
timevalueFinal += timevalueSet;
Float64 GetMinutes() const
Definition: timevalue.h:198
void SetMinutes(Float64 minutes)
Definition: timevalue.h:207
Float64 GetMilliseconds() const
Definition: timevalue.h:234
void SetHours(Float64 hours)
Definition: timevalue.h:189
void SetMilliseconds(Float64 milliseconds)
Definition: timevalue.h:252
void SetSeconds(Float64 seconds)
Definition: timevalue.h:225
void SetMicroseconds(Float64 microseconds)
Definition: timevalue.h:279
Float64 GetSeconds() const
Definition: timevalue.h:216
void SetNanoseconds(Float64 nanoseconds)
Definition: timevalue.h:306
Float64 GetHours() const
Definition: timevalue.h:180
maxon::Float Float
Definition: ge_sys_math.h:66
maxon::Int Int
Definition: ge_sys_math.h:64
Int64 Int
signed 32/64 bit int, size depends on the platform
Definition: apibase.h:188
Timer
Benchmarking or profiling parts of code can be delivered using the functions:
while (itBegin != hugearray.
End())
{
itBegin++;
}
DiagnosticOutput(diagIDString +
"Filling @ float items in the array have required @", itemsCnt, timer);
MAXON_ATTRIBUTE_FORCE_INLINE ConstIterator Begin() const
Definition: basearray.h:1637
ResultMem Resize(Int newCnt, COLLECTION_RESIZE_FLAGS resizeFlags=COLLECTION_RESIZE_FLAGS::DEFAULT)
Definition: basearray.h:1369
MAXON_ATTRIBUTE_FORCE_INLINE ConstIterator End() const
Definition: basearray.h:1657
Definition: lib_math.h:19
FLOAT Get01()
Returns the next random value in the range of [0..1].
static TimeValue GetTime()
#define iferr_return
Definition: resultbase.h:1519
Conversion
A maxon::TimeValue can be converted to/from a different type using:
Definition: string.h:1235
Result< void > TimeFromString(const String &str, TIMEFORMAT timeFormat, Float64 frameRate)
String TimeToString(TIMEFORMAT timeFormat=TIMEFORMAT::SECONDS, Float64 frameRate=1) const
const Float64 FRAMERATE_PAL
PAL frame rate is 25 fps.
Definition: timevalue.h:16
const Float64 FRAMERATE_DEFAULT
Default frame rate of 30 fps.
Definition: timevalue.h:14
const Float64 FRAMERATE_FILM
Movie frame rate is 24 fps.
Definition: timevalue.h:17
const Float64 FRAMERATE_NTSC
NTSC frame rate is approximately 29.97 fps.
Definition: timevalue.h:15
FRAMES
display time as a frame number
Definition: timevalue.h:1
SMPTE
display time as SMPTE time code
Definition: timevalue.h:2
SECONDS
display time in seconds
Definition: timevalue.h:0
Utilities
A few helpful methods are provided with the maxon::TimeValue as utilities:
timeoffset += timevalue;
void Quantize(Float64 frameRate)
quantize the time for a given frame rate, so that its frame value is a multiple of the specified fram...
Int GetFrame(Float64 frameRate) const
UInt64 UInt
unsigned 32/64 bit int, size depends on the platform
Definition: apibase.h:189
A maxon::TimeValue object can be read from and written to disk by serializing the data contained using the conventional functions.
const maxon::Id fileID {
"net.maxonexample.timevalue" };
Definition: apibaseid.h:253
std::enable_if< GetCollectionKind< T >::value==COLLECTION_KIND::ARRAY, Result< void > >::type ReadDocument(const Url &url, const Id &id, T &object, const DataDictionary &dict=DataDictionary())
Definition: io.h:35
Result< void > WriteDocument(const Url &url, OPENSTREAMFLAGS flags, const Id &id, const T &object, IOFORMAT format=IOFORMAT::DEFAULT, const DataDictionary &dict=DataDictionary())
Definition: io.h:67
Further Reading