Public Types | Public Member Functions | Static Public Member Functions
CTime Class Reference

Detailed Description

The CTime class is a utility class for manipulating time.

Creating a time object using the default constructor can be used to get the current time. The CTime class can also be used to convert from one time format to another.

Example:
        using namespace XSI;

        // Set time to frame 30 using the default frame rate
        CTime time( 30 );

        // Get time in seconds
        double secs = time.GetTime( CTime::Seconds );

#include <xsi_time.h>

List of all members.

Public Types

enum  Format {
  NTSC,
  PAL,
  FILM,
  CUSTOM
}
 The time format defines the number of frames per second. More...
enum  Unit {
  Frames,
  Hours,
  Minutes,
  Seconds,
  Milliseconds
}
 Time units are used to determine how to interpret the time. More...

Public Member Functions

 CTime ()
 CTime (double in_time)
 CTime (double in_time, Format in_format, double in_customrate=1.0)
 CTime (double in_time, CTime::Unit in_units, Format in_format, double in_customrate=1.0)
 CTime (const CTime &in_time)
 ~CTime ()
double GetTime (Unit in_units=CTime::Frames) const
void PutTime (double in_time, CTime::Unit units=CTime::Frames)
CTime::Format GetFormat (void) const
double GetFrameRate (void) const
void PutFormat (CTime::Format in_format, double in_customrate=1.0)
CString GetAsText (void) const
void SetAsText (const CString &in_str)
CTimeoperator= (const CTime &in_time)
CTimeoperator= (double in_time)
bool operator== (const CTime &rhs) const
bool operator== (const double rhs) const
bool operator!= (const CTime &rhs) const
bool operator!= (const double rhs) const
 operator double () const
CTime Round () const

Static Public Member Functions

static CTime::Format ConvertFromPlayControlFormat (const long lFormat)
static LONG ConvertToPlayControlFormat (const CTime::Format eFormat)

Member Enumeration Documentation

enum Format

The time format defines the number of frames per second.

Enumerator:
NTSC 

NTSC time format (29.97fps)

PAL 

PAL time format (25fps)

FILM 

FILM time format (24fps)

CUSTOM 

User defined time format.

enum Unit

Time units are used to determine how to interpret the time.

Enumerator:
Frames 

time in frames

Hours 

time in hours or units of 3600 seconds

Minutes 

time in minutes or units of 60 seconds

Seconds 

time in seconds

Milliseconds 

time in milliseconds or units of 1/1000 of a second


Constructor & Destructor Documentation

CTime ( )

Constructs a time object with the current time and current time format specified by the user preferences for the default frame rate in the Time preferences.

CTime ( double  in_time)

Constructs a time object with a specified time value in the time format specified by the user preferences for the default frame rate in the Time preferences.

Parameters:
in_timetime value
CTime ( double  in_time,
Format  in_format,
double  in_customrate = 1.0 
)

Constructs a time object with a specified time value and time format.

Parameters:
in_timetime value in the format units.
in_formattime format
in_customrateframes per seconds for custom frame rate format
CTime ( double  in_time,
CTime::Unit  in_units,
Format  in_format,
double  in_customrate = 1.0 
)

Constructs a time object with a specified time value in user defined time units

Parameters:
in_timetime in units specified by in_units
in_unitsunits for input time
in_formattime format
in_customrateframes per seconds for custom frame rate format
CTime ( const CTime in_time)

Copy constructor for time object.

Parameters:
in_timetime to copy
~CTime ( )

Destructor


Member Function Documentation

double GetTime ( Unit  in_units = CTime::Frames) const

Returns the time in the specified units. By default time is returned in frames.

Parameters:
in_unitsOne of the CTime::Unit enum values
Returns:
The time in the specified units.
void PutTime ( double  in_time,
CTime::Unit  units = CTime::Frames 
)

Sets the time in the specified units.

Parameters:
in_timeTime to set. By default time is set in frames
unitsOne of the CTime::Unit enum values
CTime::Format GetFormat ( void  ) const

Returns the time format

Returns:
Time format as one of the CTime::Format enum values.
double GetFrameRate ( void  ) const

Returns the frame rate in seconds for the given time format

Returns:
The frame rate in seconds as a double.
void PutFormat ( CTime::Format  in_format,
double  in_customrate = 1.0 
)

Sets the time format.

Parameters:
in_formatOne of the CTime::Format enum values
in_customrateFrames per second for custom frame rate format
CString GetAsText ( void  ) const

Returns the time as a string using SMPTE format. SMPTE, which stands for the Society of Motion Picture and Television Engineers, is a method of displaying time. There are two ways that SMPTE can be displayed, non-drop or drop frame:

SMPTE non-drop
Represented by the display; hours, minutes, seconds and frame number, or 0:00:00:00.
SMPTE drop frame
Represented by the display; hours, minutes, seconds and frame number, or 0:00:00;00.

Custom frame rate formats are returned as a string representation of the time as a double precision floating point number to 0 decimal places.

Returns:
The time as a string (SMPTE).
void SetAsText ( const CString in_str)

Sets the time from a string formated using the SMPTE format. SMPTE, which stands for the Society of Motion Picture and Television Engineers, is a method of displaying time. There are two ways that SMPTE can be displayed, non-drop or drop frame:

SMPTE non-drop
Represented by the display; hours, minutes, seconds and frame number, or 0:00:00:00.
SMPTE drop frame
Represented by the display; hours, minutes, seconds and frame number, or 0:00:00;00.

If the time is specified using a custom format then the time is expected as a double precision floating point number to 0 decimal places.

Parameters:
in_strText representation of the time
CTime& operator= ( const CTime in_time)

Assignment operator (sets the CTime object with a given time).

Parameters:
in_timeNew time
Returns:
The newly created CTime object.
CTime& operator= ( double  in_time)

Assignment operator (sets the CTime object with a given time specified in frames).

Parameters:
in_timenew time in seconds.
Returns:
The newly created CTime object.
bool operator== ( const CTime rhs) const

Equality operator (comparison to another CTime object).

Parameters:
rhsTime object to compare
Returns:
bool
bool operator== ( const double  rhs) const

Equality operator (comparison to a CTime::Time value).

Parameters:
rhsTime value to compare
Returns:
bool
bool operator!= ( const CTime rhs) const

Inequality operator (comparison to another CTime object).

Parameters:
rhsTime object to compare
Returns:
bool
bool operator!= ( const double  rhs) const

Inequality operator (comparison to a CTime::Time value).

Parameters:
rhsTime value to compare
Returns:
bool
operator double ( ) const

Cast operator (returns the time in frames).

Returns:
The time in frames as a double.
CTime Round ( ) const

Return the time rounded with respect to the current time format.

Returns:
Rounded time
Since:
9.0 (2011)
static CTime::Format ConvertFromPlayControlFormat ( const long  lFormat) [static]

Returns the CTime::Format given a playcontrol frame rate format.

Returns:
Converted format
Since:
9.0 (2011)
static LONG ConvertToPlayControlFormat ( const CTime::Format  eFormat) [static]

Returns the frame rate format id used by playcontrol, time preferences and scene data objects.

Returns:
Converted format
Since:
9.0 (2011)

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