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
static constexpr 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:196
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:170
- 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
Gets the TimeValue in minutes.
Definition: timevalue.h:223
void SetMinutes(Float64 minutes)
Sets the TimeValue in minutes.
Definition: timevalue.h:232
Float64 GetMilliseconds() const
Gets the TimeValue in milliseconds.
Definition: timevalue.h:259
void SetHours(Float64 hours)
Sets the TimeValue in hours.
Definition: timevalue.h:214
void SetMilliseconds(Float64 milliseconds)
Sets the TimeValue in milliseconds.
Definition: timevalue.h:277
void SetSeconds(Float64 seconds)
Sets the TimeValue in seconds.
Definition: timevalue.h:250
void SetMicroseconds(Float64 microseconds)
Sets the TimeValue in microseconds.
Definition: timevalue.h:304
Float64 GetSeconds() const
Gets the TimeValue in seconds.
Definition: timevalue.h:241
void SetNanoseconds(Float64 nanoseconds)
Sets the TimeValue in nanoseconds.
Definition: timevalue.h:331
Float64 GetHours() const
Gets the value in hours.
Definition: timevalue.h:205
Int64 Int
signed 32/64 bit int, size depends on the platform
Definition: apibase.h:187
maxon::Float Float
Definition: ge_sys_math.h:57
maxon::Int Int
Definition: ge_sys_math.h:55
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
Returns an iterator for the first element.
Definition: basearray.h:1483
ResultMem Resize(Int newCnt, COLLECTION_RESIZE_FLAGS resizeFlags=COLLECTION_RESIZE_FLAGS::DEFAULT)
Resizes the array to contain newCnt elements. If newCnt is smaller than GetCount() all extra elements...
Definition: basearray.h:1217
MAXON_ATTRIBUTE_FORCE_INLINE ConstIterator End() const
Returns an iterator for the end (End() - 1 is the last element if the array is not empty).
Definition: basearray.h:1503
Definition: lib_math.h:19
FLOAT Get01()
Returns the next random value in the range of [0..1].
static TimeValue GetTime()
Returns the current time stamp. You can use this value for benchmarking/profiling....
const TimeValue & Stop()
Substracts the current time, subtracts it from the value stored in the TimeValue and returns this dur...
#define iferr_return
Definition: resultbase.h:1531
Conversion
A maxon::TimeValue can be converted to/from a different type using:
Definition: string.h:1287
Result< void > TimeFromString(const String &str, TIMEFORMAT timeFormat, Float64 frameRate)
Converts String into TimeValue.
String TimeToString(TIMEFORMAT timeFormat=TIMEFORMAT::SECONDS, Float64 frameRate=1) const
Converts TimeValue into String.
static constexpr const Float64 FRAMERATE_NTSC
NTSC frame rate is approximately 29.97 fps.
Definition: timevalue.h:15
static constexpr const Float64 FRAMERATE_PAL
PAL frame rate is 25 fps.
Definition: timevalue.h:16
static constexpr const Float64 FRAMERATE_DEFAULT
Default frame rate of 30 fps.
Definition: timevalue.h:14
static constexpr const Float64 FRAMERATE_FILM
Movie frame rate is 24 fps.
Definition: timevalue.h:17
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)
Quantizes the time for a given frame rate, so that its frame value is a multiple of the specified fra...
Int GetFrame(Float64 frameRate) const
Retrieves the frame number for a given frame rate.
UInt64 UInt
unsigned 32/64 bit int, size depends on the platform
Definition: apibase.h:188
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:243
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:40
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:72
Further Reading