AVPKit
com::avpkit::core::ITimeValue Class Referenceabstract

Time (duration) values with units. More...

#include <ITimeValue.h>

Inheritance diagram for com::avpkit::core::ITimeValue:
Collaboration diagram for com::avpkit::core::ITimeValue:

Public Types

enum  Unit {
  DAYS , HOURS , MINUTES , SECONDS ,
  MILLISECONDS , MICROSECONDS , NANOSECONDS
}
 

Public Member Functions

virtual int64_t get (Unit unit)=0
 Get the value of this ITimeValue, in the specified Unit. More...
 
virtual int32_t compareTo (ITimeValue *other)=0
 Compare this timeValue to another. More...
 
- Public Member Functions inherited from com::avpkit::ferry::RefCounted
virtual int32_t acquire ()
 Internal Only. More...
 
virtual int32_t release ()
 Internal Only. More...
 
virtual RefCountedcopyReference ()
 Create a new Java object that refers to the same native object. More...
 
virtual int32_t getCurrentRefCount ()
 Return the current reference count on this object. More...
 
void setJavaAllocator (void *allocator)
 This method is public but not part of the standard API. More...
 
void * getJavaAllocator ()
 This method is public but not part of the standard API. More...
 

Static Public Member Functions

static ITimeValuemake (int64_t value, Unit unit)
 Make a new time value. More...
 
static ITimeValuemake (ITimeValue *src)
 Make a copy of a time value from another time value. More...
 
static int32_t compare (ITimeValue *a, ITimeValue *b)
 Convenience method that calls a.compareTo(b). More...
 
static int32_t compare (int64_t a, int64_t b)
 And another convenience method that deals with un-unitted long values. More...
 

Additional Inherited Members

- Protected Member Functions inherited from com::avpkit::ferry::RefCounted
virtual void destroy ()
 This method is called by RefCounted objects when their Ref Count reaches zero and they are about to be destroyed.
 
- Protected Attributes inherited from com::avpkit::ferry::RefCounted
AtomicIntegermRefCount
 This is the internal reference count, represented as an AtomicInteger to make sure it is thread safe.
 
void * mAllocator
 Not part of public API.
 

Detailed Description

Time (duration) values with units.

This class also has methods that correctly account for long wrapping when comparing time values. @Deprecated. Do not use.

Definition at line 42 of file ITimeValue.h.

Member Function Documentation

◆ compare() [1/2]

int32_t com::avpkit::core::ITimeValue::compare ( int64_t  a,
int64_t  b 
)
static

And another convenience method that deals with un-unitted long values.

Parameters
athe first object.
bthe second object.
Returns
#compare(ITimeValue, ITimeValue) where both a and b are assumed to be MICROSECONDS.

Definition at line 74 of file ITimeValue.cpp.

75 {
76  return TimeValue::compare(a, b);
77 }

◆ compare() [2/2]

int32_t com::avpkit::core::ITimeValue::compare ( ITimeValue a,
ITimeValue b 
)
static

Convenience method that calls a.compareTo(b).

See also
compareTo
Parameters
afirst value.
bsecond value.
Returns
-1 if a < b; +1 if a > b; 0 otherwise

Definition at line 54 of file ITimeValue.cpp.

55 {
56  int32_t retval = 0;
57  if (a)
58  {
59  retval = a->compareTo(b);
60  }
61  else
62  {
63  if (b)
64  // null is always less than any non-null value
65  retval = 1;
66  else // both are null
67  retval = 0;
68  }
69 
70  return retval;
71 }

References compareTo().

◆ compareTo()

virtual int32_t com::avpkit::core::ITimeValue::compareTo ( ITimeValue other)
pure virtual

Compare this timeValue to another.

This compareTo will compare the values, but will assume that the values can never be more than half of int64_t's MAX_VALUE apart. If they are it will assume long wrapping has occurred. This is required especially if you're using TimeValue's as absolute time stamps, and want to know which is earlier.

Parameters
otherthe value to compare to
Returns
-1 if this < other; +1 if this > other; 0 otherwise

Implemented in com::avpkit::core::TimeValue.

Referenced by compare().

◆ get()

virtual int64_t com::avpkit::core::ITimeValue::get ( Unit  unit)
pure virtual

Get the value of this ITimeValue, in the specified Unit.

Parameters
unitThe unit you want to get a value as.
Returns
The value, converted into the appropriate Unit.

Implemented in com::avpkit::core::TimeValue.

◆ make() [1/2]

ITimeValue * com::avpkit::core::ITimeValue::make ( int64_t  value,
Unit  unit 
)
static

Make a new time value.

Parameters
valueThe value.
unitThe unit value is expressed in.
Returns
a new time value.

Definition at line 42 of file ITimeValue.cpp.

43 {
44  return TimeValue::make(aValue, aUnit);
45 }

◆ make() [2/2]

ITimeValue * com::avpkit::core::ITimeValue::make ( ITimeValue src)
static

Make a copy of a time value from another time value.

Parameters
srcThe time value to copy. If 0 this method returns 0.
Returns
a new time value.

Definition at line 48 of file ITimeValue.cpp.

49 {
50  return TimeValue::make(dynamic_cast<TimeValue*>(src));
51 }

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