svcore  1.9
RealTime Struct Reference

RealTime represents time values to nanosecond precision with accurate arithmetic and frame-rate conversion functions. More...

#include <RealTime.h>

Collaboration diagram for RealTime:

Public Member Functions

int usec () const
 
int msec () const
 
 RealTime ()
 
 RealTime (int s, int n)
 
 RealTime (const RealTime &r)
 
double toDouble () const
 
RealTimeoperator= (const RealTime &r)
 
RealTime operator+ (const RealTime &r) const
 
RealTime operator- (const RealTime &r) const
 
RealTime operator- () const
 
bool operator< (const RealTime &r) const
 
bool operator > (const RealTime &r) const
 
bool operator== (const RealTime &r) const
 
bool operator!= (const RealTime &r) const
 
bool operator>= (const RealTime &r) const
 
bool operator<= (const RealTime &r) const
 
RealTime operator * (int m) const
 
RealTime operator/ (int d) const
 
RealTime operator * (double m) const
 
RealTime operator/ (double d) const
 
double operator/ (const RealTime &r) const
 Return the ratio of two times. More...
 
std::string toString (bool align=false) const
 Return a human-readable debug-type string to full precision (probably not a format to show to a user directly). More...
 
std::string toText (bool fixedDp=false) const
 Return a user-readable string to the nearest millisecond, in a form like HH:MM:SS.mmm. More...
 
std::string toFrameText (int fps) const
 Return a user-readable string in which seconds are divided into frames (presumably at a lower frame rate than audio rate, e.g. More...
 
std::string toSecText () const
 Return a user-readable string to the nearest second, in a form like "6s" (for less than a minute) or "2:21" (for more). More...
 
std::string toXsdDuration () const
 Return a string in xsd:duration format. More...
 

Static Public Member Functions

static RealTime fromSeconds (double sec)
 
static RealTime fromMilliseconds (int msec)
 
static RealTime fromTimeval (const struct timeval &)
 
static RealTime fromXsdDuration (std::string xsdd)
 
static RealTime fromString (std::string)
 Convert a string as obtained from toString back to a RealTime object. More...
 
static long realTime2Frame (const RealTime &r, unsigned int sampleRate)
 Convert a RealTime into a sample frame at the given sample rate. More...
 
static RealTime frame2RealTime (long frame, unsigned int sampleRate)
 Convert a sample frame at the given sample rate into a RealTime. More...
 

Public Attributes

int sec
 
int nsec
 

Static Public Attributes

static const RealTime zeroTime
 

Detailed Description

RealTime represents time values to nanosecond precision with accurate arithmetic and frame-rate conversion functions.

Definition at line 35 of file RealTime.h.

Constructor & Destructor Documentation

◆ RealTime() [1/3]

RealTime::RealTime ( )
inline

◆ RealTime() [2/3]

RealTime::RealTime ( int  s,
int  n 
)

Definition at line 44 of file RealTime.cpp.

References nsec, ONE_BILLION, and sec.

◆ RealTime() [3/3]

RealTime::RealTime ( const RealTime r)
inline

Definition at line 46 of file RealTime.h.

Member Function Documentation

◆ usec()

int RealTime::usec ( ) const
inline

Definition at line 40 of file RealTime.h.

References nsec.

◆ msec()

int RealTime::msec ( ) const
inline

Definition at line 41 of file RealTime.h.

References nsec.

Referenced by fromMilliseconds(), and toText().

◆ fromSeconds()

RealTime RealTime::fromSeconds ( double  sec)
static

◆ fromMilliseconds()

RealTime RealTime::fromMilliseconds ( int  msec)
static

Definition at line 66 of file RealTime.cpp.

References msec(), and RealTime().

◆ fromTimeval()

RealTime RealTime::fromTimeval ( const struct timeval &  tv)
static

Definition at line 72 of file RealTime.cpp.

References RealTime().

Referenced by Profiler::end(), Profiler::Profiler(), and Profiler::update().

◆ fromXsdDuration()

RealTime RealTime::fromXsdDuration ( std::string  xsdd)
static

◆ toDouble()

double RealTime::toDouble ( ) const

Definition at line 159 of file RealTime.cpp.

References nsec, ONE_BILLION, and sec.

Referenced by FeatureExtractionModelTransformer::addFeature().

◆ operator=()

RealTime& RealTime::operator= ( const RealTime r)
inline

Definition at line 56 of file RealTime.h.

References nsec, and sec.

◆ operator+()

RealTime RealTime::operator+ ( const RealTime r) const
inline

Definition at line 60 of file RealTime.h.

References nsec, RealTime(), and sec.

◆ operator-() [1/2]

RealTime RealTime::operator- ( const RealTime r) const
inline

Definition at line 63 of file RealTime.h.

References nsec, RealTime(), and sec.

◆ operator-() [2/2]

RealTime RealTime::operator- ( ) const
inline

Definition at line 66 of file RealTime.h.

References nsec, RealTime(), and sec.

◆ operator<()

bool RealTime::operator< ( const RealTime r) const
inline

Definition at line 70 of file RealTime.h.

References nsec, and sec.

◆ operator >()

bool RealTime::operator > ( const RealTime r) const
inline

Definition at line 75 of file RealTime.h.

References nsec, and sec.

◆ operator==()

bool RealTime::operator== ( const RealTime r) const
inline

Definition at line 80 of file RealTime.h.

References nsec, and sec.

◆ operator!=()

bool RealTime::operator!= ( const RealTime r) const
inline

Definition at line 84 of file RealTime.h.

◆ operator>=()

bool RealTime::operator>= ( const RealTime r) const
inline

Definition at line 88 of file RealTime.h.

References nsec, and sec.

◆ operator<=()

bool RealTime::operator<= ( const RealTime r) const
inline

Definition at line 93 of file RealTime.h.

References nsec, and sec.

◆ operator *() [1/2]

RealTime RealTime::operator * ( int  m) const

Definition at line 397 of file RealTime.cpp.

References fromSeconds(), nsec, ONE_BILLION, and sec.

◆ operator/() [1/3]

RealTime RealTime::operator/ ( int  d) const

Definition at line 405 of file RealTime.cpp.

References nsec, ONE_BILLION, RealTime(), and sec.

◆ operator *() [2/2]

RealTime RealTime::operator * ( double  m) const

Definition at line 416 of file RealTime.cpp.

References fromSeconds(), nsec, ONE_BILLION, and sec.

◆ operator/() [2/3]

RealTime RealTime::operator/ ( double  d) const

Definition at line 424 of file RealTime.cpp.

References fromSeconds(), nsec, ONE_BILLION, and sec.

◆ operator/() [3/3]

double RealTime::operator/ ( const RealTime r) const

Return the ratio of two times.

Definition at line 432 of file RealTime.cpp.

References nsec, ONE_BILLION, and sec.

◆ toString()

std::string RealTime::toString ( bool  align = false) const

Return a human-readable debug-type string to full precision (probably not a format to show to a user directly).

If align is true, prepend " " to the start of positive values so that they line up with negative ones (which start with "-").

Definition at line 191 of file RealTime.cpp.

References zeroTime.

Referenced by SparseModel< RegionRec >::getData(), PathPoint::toDelimitedDataString(), OneDimensionalPoint::toDelimitedDataString(), TimeValuePoint::toDelimitedDataString(), TextPoint::toDelimitedDataString(), ImagePoint::toDelimitedDataString(), RegionRec::toDelimitedDataString(), Note::toDelimitedDataString(), FlexiNote::toDelimitedDataString(), Transform::toXml(), and toXsdDuration().

◆ fromString()

RealTime RealTime::fromString ( std::string  s)
static

Convert a string as obtained from toString back to a RealTime object.

Definition at line 208 of file RealTime.cpp.

References nsec, RealTime(), and sec.

Referenced by Transform::setFromXmlAttributes().

◆ toText()

◆ toFrameText()

std::string RealTime::toFrameText ( int  fps) const

Return a user-readable string in which seconds are divided into frames (presumably at a lower frame rate than audio rate, e.g.

24 or 25 video frames), in a form like HH:MM:SS:FF. fps gives the number of frames per second, and must be integral (29.97 not supported).

Definition at line 314 of file RealTime.cpp.

References nsec, ONE_BILLION, sec, and zeroTime.

Referenced by toText().

◆ toSecText()

std::string RealTime::toSecText ( ) const

Return a user-readable string to the nearest second, in a form like "6s" (for less than a minute) or "2:21" (for more).

Definition at line 360 of file RealTime.cpp.

References sec, and zeroTime.

◆ toXsdDuration()

std::string RealTime::toXsdDuration ( ) const

Return a string in xsd:duration format.

Definition at line 390 of file RealTime.cpp.

References toString().

Referenced by RDFTransformFactoryImpl::writeTransformToRDF().

◆ realTime2Frame()

long RealTime::realTime2Frame ( const RealTime r,
unsigned int  sampleRate 
)
static

◆ frame2RealTime()

Member Data Documentation

◆ sec

◆ nsec

◆ zeroTime


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