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 HTManager * | GetCurrentHTManager () |
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.
|
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.