CTime Class Reference

The CTime class is a utility class for manipulating time. More...

#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 (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)
CTime operator= (const CTime &in_time)
CTime operator= (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


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 );


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_time  time 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_time  time value
in_format  time format
in_customrate  frames per seconds for custom frame rate format

CTime ( const CTime in_time  ) 

Copy constructor for time object.

Parameters:
in_time  time 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_units  One 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_time  Time to set. By default time is set in frames
units  One 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_format  One of the CTime::Format enum values
in_customrate  Frames 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_str  Text representation of the time

CTime& operator= ( const CTime in_time  ) 

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

Parameters:
in_time  New 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_time  new time in seconds.
Returns:
The newly created CTime object.

bool operator== ( const CTime rhs  )  const

Equality operator (comparison to another CTime object).

Parameters:
rhs  Time object to compare
Returns:
bool

bool operator== ( const double  rhs  )  const

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

Parameters:
rhs  Time value to compare
Returns:
bool

bool operator!= ( const CTime rhs  )  const

Inequality operator (comparison to another CTime object).

Parameters:
rhs  Time object to compare
Returns:
bool

bool operator!= ( const double  rhs  )  const

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

Parameters:
rhs  Time value to compare
Returns:
bool

operator double (  )  const

Cast operator (returns the time in frames).

Returns:
The time in frames as a double.


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