Introduction

Getting Started

Programming Guides

API Reference

Additional Resources

HTManager.h
Go to the documentation of this file.
1 // Copyright (c) Tech Soft 3D, Inc.
2 //
3 // The information contained herein is confidential and proprietary to Tech Soft 3D, Inc.,
4 // and considered a trade secret as defined under civil and criminal statutes.
5 // Tech Soft 3D, Inc. shall pursue its civil and criminal remedies in the event of
6 // unauthorized use or misappropriation of its trade secrets. Use of this information
7 // by anyone other than authorized employees of Tech Soft 3D, Inc. is granted only under
8 // a written non-disclosure agreement, expressly prescribing the scope and manner of such use.
9 
14 #ifndef _H_HT_MANAGER_H
15 #define _H_HT_MANAGER_H
16 
17 #ifdef H_PACK_8
18 #pragma pack(push)
19 #pragma pack(8)
20 #endif
21 
22 
23 #include "HTools.h"
24 
25 class HTClient;
26 class HTDriver;
27 
50 class MVO_API HTManager
51 {
52 public:
56  HTManager( int output_hz = 100 );
57  virtual ~HTManager();
58 
62  virtual void Tick( float time );
66  void RegisterClient( HTClient *c );
70  void UnRegisterClient( HTClient *c );
72  static HTManager *GetCurrentHTManager();
73 
74 protected:
75  double m_interval;
76  double m_request_time;
77  double m_actual_time;
79  struct vlist_s **m_buckets;
81  struct vlist_s *m_spillover;
82  struct vhash_s *m_active_clients;
84  struct vlist_s *m_recently_deleted_clients;
85 
90  void Init( float start_time );
96  void ScheduleNextTick( HTClient *c, float time );
97 };
98 
102 enum HTCStyle {
107 };
108 
110 typedef bool(*HTClientTickFunction)(float request_time, float actual_time, void * user_data);
111 
157 class MVO_API HTClient
158 {
159 public:
168  HTClient( float interval = 0.1f,
169  HTCStyle style = HTCS_Invalid,
170  HTClientTickFunction tick_function = 0,
171  void* user_data = 0 ) {
172  mt_interval = interval;
173  mt_style = style;
174  mt_next_request = 0;
175  mt_priority = 0;
176  mt_tick_function = tick_function;
177  mt_user_data = user_data;
178  }
179  virtual ~HTClient();
180 
186  virtual bool Tick( float request_time, float actual_time ){
187  if( mt_tick_function )
188  return mt_tick_function(request_time, actual_time, mt_user_data);
189  else
190  return true;
191  };
192 
195  void SetInterval( float interval ) { mt_interval = interval; };
196 
198  float GetInterval() const { return mt_interval; };
199 
204  void SetStyle( HTCStyle style ) { mt_style = style; };
205 
207  HTCStyle GetStyle() const { return mt_style; };
208 
212  void SetNextRequest( float nr ) { mt_next_request = nr; };
213 
215  float GetNextRequest() const { return mt_next_request; };
216 
220  int GetPriority() const { return mt_priority; };
221 
225  void SetPriorityLowest() { mt_priority = -1; };
226 
230  void SetUserData( void* user_data ) { mt_user_data = user_data; };
231 
233  void* GetUserData() const { return mt_user_data; };
234 
238  void SetTickFunction( HTClientTickFunction tick_function) { mt_tick_function = tick_function; };
239 
241  HTClientTickFunction GetTickFunction() const { return mt_tick_function; };
242 
243 protected:
245  HTCStyle mt_style;
246 
250  float mt_interval;
251 
254 
259 
261  void* mt_user_data;
262 
266 };
267 
268 
269 
270 #ifdef H_PACK_8
271 #pragma pack(pop)
272 #endif
273 
274 #endif
275 
276 
277 
278 
void * mt_user_data
Definition: HTManager.h:261
Definition: HTManager.h:50
HTClient(float interval=0.1f, HTCStyle style=HTCS_Invalid, HTClientTickFunction tick_function=0, void *user_data=0)
Definition: HTManager.h:168
void * GetUserData() const
Definition: HTManager.h:233
HTClientTickFunction mt_tick_function
Definition: HTManager.h:265
int mt_priority
Definition: HTManager.h:258
void SetNextRequest(float nr)
Definition: HTManager.h:212
float GetNextRequest() const
Definition: HTManager.h:215
double m_request_time
The time that the current bucket's events had requested.
Definition: HTManager.h:76
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:79
An invalid default state for the client style. The client style must be set before anything useful wi...
Definition: HTManager.h:103
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:77
Definition: HTManager.h:157
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:78
A single event will be delivered at the designated time, after which the timer client will automatica...
Definition: HTManager.h:104
HTCStyle GetStyle() const
Definition: HTManager.h:207
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:82
int GetPriority() const
Definition: HTManager.h:220
void SetInterval(float interval)
Definition: HTManager.h:195
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:83
HTCStyle
Definition: HTManager.h:102
Similar to HTCS_Periodic but this option has no make-up events.
Definition: HTManager.h:106
void SetPriorityLowest()
Definition: HTManager.h:225
float GetInterval() const
Definition: HTManager.h:198
void SetUserData(void *user_data)
Definition: HTManager.h:230
Events will be delivered at the interval specified with the timer client's "mt_interval" member varia...
Definition: HTManager.h:105
void SetTickFunction(HTClientTickFunction tick_function)
Definition: HTManager.h:238
void SetStyle(HTCStyle style)
Definition: HTManager.h:204
struct vlist_s * m_spillover
An array of things that need to be scheduled for more than 1s away.
Definition: HTManager.h:81
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:84
float mt_interval
Definition: HTManager.h:250
virtual bool Tick(float request_time, float actual_time)
Definition: HTManager.h:186
bool(* HTClientTickFunction)(float request_time, float actual_time, void *user_data)
Definition: HTManager.h:110
double m_interval
1.0 / m_output_hz
Definition: HTManager.h:75
float mt_next_request
Definition: HTManager.h:253
int m_current_bucket
The bucket of events currently being dispatched.
Definition: HTManager.h:80