HTManager
-
class
HTManager HTManagerprovides 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 byHTCObjectRotate.[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.
Index
Methods
GetCurrentHTManager()HTManager()Init()RegisterClient()ScheduleNextTick()Tick()UnRegisterClient()~HTManager()
Variables
Methods
-
HTManager::HTManager(int output_hz = 100) Constructs an
HTManagerobject.Parameters
output_hz: The number of buckets into which the timer manager splits a single second.
-
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.
-
void
HTManager::RegisterClient(HTClient *c) This method informs the timer manager of a client that would like to start receiving timer events.
Parameters
c: A pointer to theHTClientthat would like to receiver timer events.
-
void
HTManager::UnRegisterClient(HTClient *c) This method stops the timer service for the given client.
Parameters
c: A pointer theHTClientthat no longer wants to receive timer events.
-
static HTManager *
HTManager::GetCurrentHTManager() static
Returns
A pointer to the timer manager currently associated with hoops_mvo’s centralHDBobject.
-
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_time: The time, as reported by #HC_Show_Time, at which this class was initialized.
-
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
c: The client that is requesting a timer event.
time: Pass the ideal time at which this timer event should be delivered.
Variables
-
double
HTManager::m_request_time protected
doubleThe time that the current bucket’s events had requested.
-
double
HTManager::m_actual_time protected
doubleThe actual time which may be different from m_request_time if control is lost for a while.
-
int
HTManager::m_output_hz protected
intThe 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 **
HTManager::m_buckets protected
struct vlist_sThe array of buckets of size m_output_hz. This array holds precisely 1 sec of events.
-
struct vlist_s *
HTManager::m_spillover protected
struct vlist_sAn array of things that need to be scheduled for more than 1s away.
-
struct vhash_s *
HTManager::m_active_clients protected
struct vhash_sA 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. */