You.i Engine
CYITime Class Reference

Detailed Description

global class used to notify the system of time updates

This class, accessed through the CYIFramework singleton, is used to drive animations, timelines, timers by informing them of the current time in a platform-independent way. No animation on the system can advance unless UpdateTime() is called on a regular basis.

#include <utility/YiTime.h>

Classes

class  UpdateListener
 

Public Member Functions

 CYITime ()
 
virtual ~CYITime ()
 
void UpdateTime (bool notifyListeners=true)
 
void UpdateTime (std::chrono::microseconds deltaTime, bool notifyListeners=true)
 
void RegisterTimeUpdateListener (CYITime::UpdateListener *pListener)
 
void UnregisterTimeUpdateListener (CYITime::UpdateListener *pListener)
 
bool HasListeners () const
 
uint64_t GetListenerCount () const
 
std::chrono::microseconds GetFrameTime ()
 
uint64_t GetRefTime ()
 
uint32_t GetLastUpdateStatus ()
 
void EnableFixedTimeStep (std::chrono::microseconds fixedTimeStep)
 
bool IsFixedTimeStepEnabled () const
 
void DisableFixedTimeStep ()
 
void SetTimeDilationFactor (float factor)
 
float GetTimeDilationFactor () const
 

Public Attributes

CYISignal TimeConfigurationChanged
 

Static Public Attributes

static const uint32_t UPDATE_STATUS_NONE
 A bitfield value indicating no update status. More...
 
static const uint32_t UPDATE_STATUS_DISABLE_INPUT
 A bitfield value indicating that input is disabled. More...
 
static const uint32_t UPDATE_STATUS_SCENE_DIRTY
 A bitfield value indicating that the scene is dirty. More...
 

Protected Member Functions

void NotifyTimeUpdated (std::chrono::microseconds frameTime)
 

Constructor & Destructor Documentation

◆ CYITime()

CYITime::CYITime ( )

◆ ~CYITime()

virtual CYITime::~CYITime ( )
virtual

Member Function Documentation

◆ DisableFixedTimeStep()

void CYITime::DisableFixedTimeStep ( )

Disable running the application at a fixed time-step.

See also
EnableFixedTimeStep
Note
Emits TimeConfigurationChanged

◆ EnableFixedTimeStep()

void CYITime::EnableFixedTimeStep ( std::chrono::microseconds  fixedTimeStep)

Enable running the application at a fixed time-step. Systems making use of CYITime (such as implementations of CYITime::UpdateListener) will receive fixedTimeStep as the time delta between frames instead of the true elapsed time. Zero is a special value equivalent to DisableFixedTimeStep.

Warning
This is meant as a debugging or profiling feature and is not expected to be used in live applications.
Note
Emits TimeConfigurationChanged
See also
DisableFixedTimeStep
IsFixedTimeStepEnabled

◆ GetFrameTime()

std::chrono::microseconds CYITime::GetFrameTime ( )

Returns the frame time, i.e. the delta time between the last two time updates

◆ GetLastUpdateStatus()

uint32_t CYITime::GetLastUpdateStatus ( )

Returns any status flags since last call to UpdateTime();

◆ GetListenerCount()

uint64_t CYITime::GetListenerCount ( ) const

Returns the number of registered listeners.

See also
RegisterTimeUpdateListener
UnregisterTimeUpdateListener

◆ GetRefTime()

uint64_t CYITime::GetRefTime ( )

Returns the reference time, in milliseconds. Exact meaning of the value is unspecified, so it is useful only through comparison with another reference time acquired previously

◆ GetTimeDilationFactor()

float CYITime::GetTimeDilationFactor ( ) const

Gets the current time dilation factor. 1.0 represents normal execution speed.

See also
SetTimeDilationFactor

◆ HasListeners()

bool CYITime::HasListeners ( ) const

Returns true if there are any registered listeners.

See also
RegisterTimeUpdateListener
UnregisterTimeUpdateListener

◆ IsFixedTimeStepEnabled()

bool CYITime::IsFixedTimeStepEnabled ( ) const

Returns true if the application is running at a fixed time-step. The default state is false, will also become false if EnableFixedTimeStep is called with a value of zero or if DisableFixedTimeStep is called.

See also
EnableFixedTimeStep
DisableFixedTimeStep

◆ NotifyTimeUpdated()

void CYITime::NotifyTimeUpdated ( std::chrono::microseconds  frameTime)
protected

◆ RegisterTimeUpdateListener()

void CYITime::RegisterTimeUpdateListener ( CYITime::UpdateListener pListener)

Registers a new listener for notification of time updates

◆ SetTimeDilationFactor()

void CYITime::SetTimeDilationFactor ( float  factor)

Sets the time dilation factor to factor. The time dilation factor affects how fast time appears to pass in You.i Engine. By default, the factor is 1.0. When larger than 1.0, time appears to pass faster than normal. When smaller than 1.0, time appears to pass slower than normal.

The time dilation factor only affects the frame time. Animations and timers are affected by modified frame times. The values returned by the GetRefTime() and the YiGetTimeuS() functions are not affected.

Note
Negative and zero values are not supported.
Emits TimeConfigurationChanged

◆ UnregisterTimeUpdateListener()

void CYITime::UnregisterTimeUpdateListener ( CYITime::UpdateListener pListener)

Unregisters a listener from notification of time updates

◆ UpdateTime() [1/2]

void CYITime::UpdateTime ( bool  notifyListeners = true)

Updates frame time and ref time according to the time elapsed since this function was last called. Notifies the listeners of the time update.

See also
GetFrameTime()
GetRefTime()
GetLastUpdateStatus()

◆ UpdateTime() [2/2]

void CYITime::UpdateTime ( std::chrono::microseconds  deltaTime,
bool  notifyListeners = true 
)

Updates frame time and ref time according to the provided delta time. Notifies the listeners of the time update. Using this function can be used to make time-based activities (animations, timers etc) operate faster or slower than real time.

See also
GetFrameTime()
GetRefTime()
GetLastUpdateStatus()

Member Data Documentation

◆ TimeConfigurationChanged

CYISignal CYITime::TimeConfigurationChanged

◆ UPDATE_STATUS_DISABLE_INPUT

const uint32_t CYITime::UPDATE_STATUS_DISABLE_INPUT
static

A bitfield value indicating that input is disabled.

◆ UPDATE_STATUS_NONE

const uint32_t CYITime::UPDATE_STATUS_NONE
static

A bitfield value indicating no update status.

◆ UPDATE_STATUS_SCENE_DIRTY

const uint32_t CYITime::UPDATE_STATUS_SCENE_DIRTY
static

A bitfield value indicating that the scene is dirty.


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