Class: TTime

Declaration: TimeClasses.h

Taxonomy Categories:

Member Functions:


Interface Category:

API.

Inherits From:

MOrderableCollectible

Inherited By:

TDays THours TMIDITick TMicroseconds TMilliseconds TMinutes TNanoseconds TPicoseconds TSamples TSeconds TSQLDate TSQLTime

Purpose:

Represents an instance or amount of time and provides arithmetic operators and conversions between different time units. Time objects are most frequently used to determine the current time and set alarms or delays. Time objects can also be used across different time bases (clocks). It is possible to convert between them because they all inherit from TTime. Because TTime has a double, its accuracy varies depending on its size. The math operators are also treated like a double. This means that the same calculations can vary on different machines or compilers. The trade off for speed was chosen instead of guaranteed accuracy.

Instantiation:

Allocate on the heap or the stack.

Deriving Classes:

TTime has a double that represents the amount of time. Most of its derived classes can type cast between each other to convert time units; TPicoseconds, TNanoseconds, TMicroseconds, TMilliseconds, TSeconds, THours, and TDays can be type cast between each other. Common users of TTime are TClock and TDelay. TTime is derived to provide different units of time, such as TMicroseconds, TVideoFrames, and TSamples.

Concurrency:

TTime is not multithread or multiprocessor safe, in that when the value is being set or changed there is no mutual exclusion preventing another thread from getting or reading the value.

Resource Use:

No special requirements.

Member Function: TTime::TTime

  1. TTime ()
  2. TTime (const TTime & theTime)

Interface Category:

API.

Purpose:

  1. Default constructor.
  2. Copy constructor.

Calling Context:

  1. Called by the stream-in operators and directly.
  2. Called to copy an object.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

TTime is not multithread or multiprocessor safe.

Other Considerations:

If the derived class of time is not a real-time time unit, the time must still be represented in what the closest default real-time units would be.

Member Function: TTime::~TTime

virtual ~ TTime ()

Interface Category:

API.

Purpose:

Destructor.

Calling Context:

Call this function directly. Called to destroy an object.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

TTime is not multithread or multiprocessor safe.

Other Considerations:

None.

Member Function: TTime::operator=

TTime & operator =(const TTime & theTime)

Interface Category:

API.

Purpose:

Assignment operator.

Calling Context:

Call this function directly. Called when an object is assigned to another compatible object.

Parameters:

Return Value:

A non-const reference to the left-hand side object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

TTime is not multithread or multiprocessor safe.

Other Considerations:

None.

Member Function: TTime::operator+=

const TTime & operator += (const TTime & theTime)

Interface Category:

API.

Purpose:

Sets a TTime to itself plus another TTime.

Calling Context:

Call this function directly. Called to set a TTime to itself plus another TTime.

Parameters:

Return Value:

A const reference to the left-hand side object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

TTime is not multithread or multiprocessor safe.

Other Considerations:

None.

Member Function: TTime::operator-=

const TTime & operator -=(const TTime & theTime)

Interface Category:

API.

Purpose:

Sets a TTime to itself minus another TTime.

Calling Context:

Call this function directly. Called to set a TTime to itself minus another TTime.

Parameters:

Return Value:

A const reference to the left-hand side object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

TTime is not multithread or multiprocessor safe.

Other Considerations:

None.

Member Function: TTime::operator*=

const TTime & operator *= (double howMuch)

Interface Category:

API.

Purpose:

Sets a TTime to itself multiplied by a double.

Calling Context:

Call this function directly. Called to set a TTime to itself multiplied by a double.

Parameters:

Return Value:

A const reference to the left-hand side object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

TTime is not multithread or multiprocessor safe.

Other Considerations:

None.

Member Function: TTime::operator/=

const TTime & operator /= (double howMuch)

Interface Category:

API.

Purpose:

Sets a TTime to itself divided by a double.

Calling Context:

Call this function directly. Called to set a TTime to itself divided by a double.

Parameters:

Return Value:

A const reference to the left-hand side object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

TTime is not multithread or multiprocessor safe.

Other Considerations:

None.

Member Function: TTime::operator<

bool operator < (const TTime & theTime) const

Interface Category:

API.

Purpose:

Compares two TTime objects.

Calling Context:

Call this function directly. Called to compare two TTimes.

Parameters:

Return Value:

Returns true if the object is less than theTime, otherwise returns false.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

TTime is not multithread or multiprocessor safe.

Other Considerations:

None.

Member Function: TTime::operator<=

bool operator <= (const TTime & theTime) const

Interface Category:

API.

Purpose:

Compares two TTime objects.

Calling Context:

Call this function directly. Called to compare two TTimes.

Parameters:

Return Value:

Returns true if the object is less than or equal to theTime, otherwise returns false.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

TTime is not multithread or multiprocessor safe.

Other Considerations:

None.

Member Function: TTime::operator>=

bool operator >=(const TTime & theTime) const

Interface Category:

API.

Purpose:

Compares two TTime objects.

Calling Context:

Call this function directly. Called to compare two TTimes.

Parameters:

Return Value:

Returns true if theTime is greater than or equal to this object, otherwise returns false.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

TTime is not multithread or multiprocessor safe.

Other Considerations:

None.

Member Function: TTime::operator>

bool operator >(const TTime & theTime) const

Interface Category:

API.

Purpose:

Compares two TTime objects.

Calling Context:

Call this function directly. Called to compare two TTimes.

Parameters:

Return Value:

Returns true if the object is greater than theTime, otherwise returns false.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

TTime is not multithread or multiprocessor safe.

Other Considerations:

None.

Member Function: TTime::operator==

bool operator ==(const TTime & theTime) const

Interface Category:

API.

Purpose:

Compares two TTime objects for equality.

Calling Context:

Call this function directly. Called to see if two TTimes are equal.

Parameters:

Return Value:

Returns true if the two objects are equal, otherwise returns false.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

TTime is not multithread or multiprocessor safe.

Other Considerations:

None.

Member Function: TTime::Hash

virtual long Hash () const

Interface Category:

API.

Purpose:

Generates a hash value.

Calling Context:

Call this function directly. Call this function directly. Called to get a hash value.

Parameters:

Return Value:

A long hash value.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

TTime is not multithread or multiprocessor safe.

Other Considerations:

None.

Member Function: TTime::IsGreaterThan

virtual bool IsGreaterThan (const MOrderableCollectible * obj) const

Interface Category:

API.

Purpose:

Compares two TTime objects, returning whether the source object is greater than the targets object.

Calling Context:

Call this function directly. Called by some collection classes.

Parameters:

Return Value:

Returns true if the source object is greater than the object being compared to, otherwise returns false.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

TTime is not multithread or multiprocessor safe.

Other Considerations:

Use compare operators for comparing TTime objects; it is faster.

Member Function: TTime::IsLessThan

virtual bool IsLessThan (const MOrderableCollectible * obj) const

Interface Category:

API.

Purpose:

Compares two TTime objects, returning whether the source object is less than the targets object.

Calling Context:

Call this function directly. Called by some collection classes.

Parameters:

Return Value:

Returns true if the source object is less than the compared object, otherwise returns false.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

TTime is not multithread or multiprocessor safe.

Other Considerations:

None.

Member Function: TTime::operator<<=

virtual TStream & operator <<= (TStream & fromWhere)

Interface Category:

API.

Purpose:

Stream-in operator.

Calling Context:

Call this function directly. Called to stream in data.

Parameters:

Return Value:

Returns a reference to the stream the object streams itself in from.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

TTime is not multithread or multiprocessor safe.

Other Considerations:

None.

Member Function: TTime::operator>>=

virtual TStream & operator >>=(TStream & toWhere) const

Interface Category:

API.

Purpose:

Stream-out operator.

Calling Context:

Call this function directly. Called to stream out data.

Parameters:

Return Value:

Returns a reference to the stream the object streams itself out to.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

TTime is not multithread or multiprocessor safe.

Other Considerations:

None.

Member Function: TTime::SetPicoseconds

void SetPicoseconds (double thePicoseconds)

Interface Category:

API.

Purpose:

Sets the number of picoseconds that the TTime object represents.

Calling Context:

Call this function directly. Called by deriving classes to set their time value.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

TTime is not multithread or multiprocessor safe.

Other Considerations:

None.

Member Function: TTime::GetPicoseconds

double GetPicoseconds () const

Interface Category:

API.

Purpose:

Gets the number of picoseconds that the TTime object represents.

Calling Context:

Call this function directly. Called to get the time in double representation.

Parameters:

Return Value:

The number of picoseconds.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

TTime is not multithread or multiprocessor safe.

Other Considerations:

Returns a double that could be a NaN, or positive or negative infinity, depending on the time.

Member Function: TTime::operator!=

bool operator != (const TTime & theTime) const

Interface Category:

API.

Purpose:

Compares two TTime objects for inequality.

Calling Context:

Call this function directly. Called to see if two TTimes are not equal.

Parameters:

Return Value:

Returns true if the two objects are not equal, otherwise returns false.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

TTime is not multithread or multiprocessor safe.

Other Considerations:

None.
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.