#include <HTManager.h>

Public Member Functions

 HTManager (int output_hz=100)
 
void RegisterClient (HTClient *c)
 
virtual void Tick (float time)
 
void UnRegisterClient (HTClient *c)
 

Static Public Member Functions

static HTManagerGetCurrentHTManager ()
 

Protected Member Functions

void Init (float start_time)
 
void ScheduleNextTick (HTClient *c, float time)
 

Protected Attributes

struct vhash_s * m_active_clients
 A hash table of all the currently registered clients. Only currently registered clients can receive ticks, or even accessed in any way to make sure we don't access any memory after free. */.
 
double m_actual_time
 The actual time which may be different from m_request_time if control is lost for a while.
 
struct vlist_s ** m_buckets
 The array of buckets of size m_output_hz. This array holds precisely 1 sec of events.
 
int m_current_bucket
 The bucket of events currently being dispatched.
 
double m_interval
 1.0 / m_output_hz
 
int m_output_hz
 The granularity of the timer, i.e. the number of buckets into which the timer manager splits a single second. Timer events scheduled in the same bucket may be delivered sorted only by priority.
 
struct vlist_s * m_recently_deleted_clients
 A list of recently deleted clients. Only if an item is unregistered and then re-registered very quickly.
 
struct vlist_s * m_recently_deleted_expirations
 A vlist parallel to m_recently_deleted_clients to indicate how long things need to stay on the list.
 
double m_request_time
 The time that the current bucket's events had requested.
 
struct vlist_s * m_spillover
 An array of things that need to be scheduled for more than 1s away.
 

Detailed Description

HTManager provides a centralized timing service for MVO. It is intended to allow animation or other ongoing actions to proceed without completely usurping control of the application.

The timer service is completely platform and GUI independent and therefore requires timer ticks to be delivered from whatever GUI or system calls are appropriate from the environment. It is recommended (though not required) that such ticks be delivered at the highest available frequency from the system. See CTDriver.cpp in hoops_mfc for an example.

Once such ticks are set up, clients can register themselves to request notification at any frequency. Such clients must derive from HTClient. A reference implementation is provided by HTCObjectRotate.[cpp,h]

The HTManager's sense of time is achieved by repeated calls to HOOPS/3dGS' HC_Show_Time.
Refer to the 3dGS reference manual.

This platform-independent class keeps an array of linked lists to store all of the events for one second, then has a spillover list to handle anything that needs to be scheduled further out. Its main job is to dispatch timer messages from the OS to whatever clients would like to request them. With this service in place, clients can safely release control during an animation, knowing that control will be returned when it is needed.

Constructor & Destructor Documentation

◆ HTManager()

HTManager::HTManager ( int  output_hz = 100)

Constructs an HTManager object.

Parameters
output_hzThe number of buckets into which the timer manager splits a single second.

Member Function Documentation

◆ GetCurrentHTManager()

static HTManager* HTManager::GetCurrentHTManager ( )
static
Returns
A pointer to the timer manager currently associated with hoops_mvo's central HDB object.

◆ Init()

void HTManager::Init ( float  start_time)
protected

This method must be called before any dispatching can be done. Note it is automatically performed on the first call to RegisterClient. It allocates all required memory for member data.

Parameters
start_timeThe time, as reported by #HC_Show_Time, at which this class was initialized.

◆ RegisterClient()

void HTManager::RegisterClient ( HTClient c)

This method informs the timer manager of a client that would like to start receiving timer events.

Parameters
cA pointer to the HTClient that would like to receiver timer events.

◆ ScheduleNextTick()

void HTManager::ScheduleNextTick ( HTClient c,
float  time 
)
protected

This method finds the appropriate list to which the given client should be added so that an event is scheduled at the right time.

Parameters
cThe client that is requesting a timer event.
timePass the ideal time at which this timer event should be delivered.

◆ Tick()

virtual void HTManager::Tick ( float  time)
virtual

The mechanism for receiving timer events from the OS is platform dependent, so here we only provide a function call for the external "timer driver" to deliver timer events. It is recommended that such events be delivered at the highest available frequency.

◆ UnRegisterClient()

void HTManager::UnRegisterClient ( HTClient c)

This method stops the timer service for the given client.

Parameters
cA pointer the HTClient that no longer wants to receive timer events.

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