Alphabetical Class Index  Class Hierarchy   File Members   Compound Members   File List  

HTManager.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2000 by Tech Soft 3D, LLC.
3 // The information contained herein is confidential and proprietary to
4 // Tech Soft 3D, LLC., and considered a trade secret as defined under
5 // civil and criminal statutes. Tech Soft 3D shall pursue its civil
6 // and criminal remedies in the event of unauthorized use or misappropriation
7 // of its trade secrets. Use of this information by anyone other than
8 // authorized employees of Tech Soft 3D, LLC. is granted only under a
9 // written non-disclosure agreement, expressly prescribing the scope and
10 // manner of such use.
11 //
12 // $Id: 11ae4afa6b74675b47795aeee778c5ec061fe5da $
13 //
14 
19 #ifndef _H_HT_MANAGER_H
20 #define _H_HT_MANAGER_H
21 
22 #ifdef H_PACK_8
23 #pragma pack(push)
24 #pragma pack(8)
25 #endif
26 
27 
28 #include "HTools.h"
29 
30 class HTClient;
31 class HTDriver;
32 
55 class MVO_API HTManager
56 {
57 public:
61  HTManager( int output_hz = 100 );
62  virtual ~HTManager();
63 
67  virtual void Tick( float time );
71  void RegisterClient( HTClient *c );
75  void UnRegisterClient( HTClient *c );
77  static HTManager *GetCurrentHTManager();
78 
79 protected:
80  double m_interval;
81  double m_request_time;
82  double m_actual_time;
84  struct vlist_s **m_buckets;
86  struct vlist_s *m_spillover;
87  struct vhash_s *m_active_clients;
89  struct vlist_s *m_recently_deleted_clients;
90 
95  void Init( float start_time );
101  void ScheduleNextTick( HTClient *c, float time );
102 };
103 
107 enum HTCStyle {
112 };
113 
115 typedef bool(*HTClientTickFunction)(float request_time, float actual_time, void * user_data);
116 
162 class MVO_API HTClient
163 {
164 public:
173  HTClient( float interval = 0.1f,
174  HTCStyle style = HTCS_Invalid,
175  HTClientTickFunction tick_function = 0,
176  void* user_data = 0 ) {
177  mt_interval = interval;
178  mt_style = style;
179  mt_next_request = 0;
180  mt_priority = 0;
181  mt_tick_function = tick_function;
182  mt_user_data = user_data;
183  }
184  virtual ~HTClient();
185 
191  virtual bool Tick( float request_time, float actual_time ){
192  if( mt_tick_function )
193  return mt_tick_function(request_time, actual_time, mt_user_data);
194  else
195  return true;
196  };
197 
200  void SetInterval( float interval ) { mt_interval = interval; };
201 
203  float GetInterval() const { return mt_interval; };
204 
209  void SetStyle( HTCStyle style ) { mt_style = style; };
210 
212  HTCStyle GetStyle() const { return mt_style; };
213 
217  void SetNextRequest( float nr ) { mt_next_request = nr; };
218 
220  float GetNextRequest() const { return mt_next_request; };
221 
225  int GetPriority() const { return mt_priority; };
226 
230  void SetPriorityLowest() { mt_priority = -1; };
231 
235  void SetUserData( void* user_data ) { mt_user_data = user_data; };
236 
238  void* GetUserData() const { return mt_user_data; };
239 
243  void SetTickFunction( HTClientTickFunction tick_function) { mt_tick_function = tick_function; };
244 
246  HTClientTickFunction GetTickFunction() const { return mt_tick_function; };
247 
248 protected:
250  HTCStyle mt_style;
251 
255  float mt_interval;
256 
259 
264 
266  void* mt_user_data;
267 
271 };
272 
273 
274 
275 #ifdef H_PACK_8
276 #pragma pack(pop)
277 #endif
278 
279 #endif
280 
281 
282 
283 
void * mt_user_data
Definition: HTManager.h:266
Definition: HTManager.h:55
HTClient(float interval=0.1f, HTCStyle style=HTCS_Invalid, HTClientTickFunction tick_function=0, void *user_data=0)
Definition: HTManager.h:173
void * GetUserData() const
Definition: HTManager.h:238
HTClientTickFunction mt_tick_function
Definition: HTManager.h:270
int mt_priority
Definition: HTManager.h:263
void SetNextRequest(float nr)
Definition: HTManager.h:217
float GetNextRequest() const
Definition: HTManager.h:220
double m_request_time
The time that the current bucket's events had requested.
Definition: HTManager.h:81
struct vlist_s ** m_buckets
The array of buckets of size m_output_hz. This array holds precisely 1 sec of events.
Definition: HTManager.h:84
An invalid default state for the client style. The client style must be set before anything useful wi...
Definition: HTManager.h:108
double m_actual_time
The actual time which may be different from m_request_time if control is lost for a while...
Definition: HTManager.h:82
Definition: HTManager.h:162
int m_output_hz
The granularity of the timer, i.e. the number of buckets into which the timer manager splits a single...
Definition: HTManager.h:83
A single event will be delivered at the designated time, after which the timer client will automatica...
Definition: HTManager.h:109
HTCStyle GetStyle() const
Definition: HTManager.h:212
struct vhash_s * m_active_clients
A hash table of all the currently registered clients. Only currently registered clients can receive t...
Definition: HTManager.h:87
int GetPriority() const
Definition: HTManager.h:225
void SetInterval(float interval)
Definition: HTManager.h:200
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...
Definition: HTManager.h:88
HTCStyle
Definition: HTManager.h:107
Similar to HTCS_Periodic but this option has no make-up events.
Definition: HTManager.h:111
void SetPriorityLowest()
Definition: HTManager.h:230
float GetInterval() const
Definition: HTManager.h:203
void SetUserData(void *user_data)
Definition: HTManager.h:235
Events will be delivered at the interval specified with the timer client's "mt_interval" member var...
Definition: HTManager.h:110
void SetTickFunction(HTClientTickFunction tick_function)
Definition: HTManager.h:243
void SetStyle(HTCStyle style)
Definition: HTManager.h:209
struct vlist_s * m_spillover
An array of things that need to be scheduled for more than 1s away.
Definition: HTManager.h:86
struct vlist_s * m_recently_deleted_clients
A list of recently deleted clients. Only if an item is unregistered and then re-registered very quick...
Definition: HTManager.h:89
float mt_interval
Definition: HTManager.h:255
virtual bool Tick(float request_time, float actual_time)
Definition: HTManager.h:191
bool(* HTClientTickFunction)(float request_time, float actual_time, void *user_data)
Definition: HTManager.h:115
double m_interval
1.0 / m_output_hz
Definition: HTManager.h:80
float mt_next_request
Definition: HTManager.h:258
int m_current_bucket
The bucket of events currently being dispatched.
Definition: HTManager.h:85