Alphabetical Class Index  Class Hierarchy   File Members   Compound Members   File List  

HTManager.h
Go to the documentation of this file.
00001 // Copyright (c) 1998-2014 by Tech Soft 3D, Inc.
00002 //
00003 // The information contained herein is confidential and proprietary to Tech Soft 3D, Inc.,
00004 // and considered a trade secret as defined under civil and criminal statutes.
00005 // Tech Soft 3D, Inc. shall pursue its civil and criminal remedies in the event of
00006 // unauthorized use or misappropriation of its trade secrets.  Use of this information
00007 // by anyone other than authorized employees of Tech Soft 3D, Inc. is granted only under
00008 // a written non-disclosure agreement, expressly prescribing the scope and manner of such use.
00009 
00014 #ifndef _H_HT_MANAGER_H
00015 #define _H_HT_MANAGER_H
00016 
00017 #ifdef H_PACK_8
00018 #pragma pack(push)
00019 #pragma pack(8)
00020 #endif
00021 
00022 
00023 #include "HTools.h"
00024 
00025 class HTClient;
00026 class HTDriver;
00027 
00050 class MVO_API HTManager
00051 {
00052 public:
00056     HTManager( int output_hz = 100 );
00057     virtual ~HTManager();
00058 
00062     virtual void Tick( float time );
00066     void RegisterClient( HTClient *c );
00070     void UnRegisterClient( HTClient *c );
00072     static HTManager *GetCurrentHTManager();
00073 
00074 protected:
00075     double m_interval;               
00076     double m_request_time;           
00077     double m_actual_time;            
00078     int m_output_hz;                
00079     struct vlist_s **m_buckets;     
00080     int m_current_bucket;           
00081     struct vlist_s *m_spillover;    
00082     struct vhash_s *m_active_clients; 
00083     struct vlist_s *m_recently_deleted_expirations; 
00084     struct vlist_s *m_recently_deleted_clients; 
00085 
00090     void Init( float start_time );
00096     void ScheduleNextTick( HTClient *c, float time );
00097 };
00098 
00102 enum HTCStyle {
00103     HTCS_Invalid,       
00104     HTCS_Once,          
00105     HTCS_Periodic,      
00106     HTCS_PeriodicSkip   
00107 };
00108 
00110 typedef bool(*HTClientTickFunction)(float request_time, float actual_time, void * user_data);
00111 
00157 class MVO_API HTClient
00158 {
00159 public:
00168     HTClient(   float interval = 0.1f, 
00169                 HTCStyle style = HTCS_Invalid, 
00170                 HTClientTickFunction tick_function = 0, 
00171                 void* user_data = 0 ) {
00172         mt_interval = interval;
00173         mt_style = style;
00174         mt_next_request = 0;
00175         mt_priority = 0;
00176         mt_tick_function = tick_function;
00177         mt_user_data = user_data;
00178     }
00179     virtual ~HTClient();
00180 
00186     virtual bool Tick( float request_time, float actual_time ){ 
00187         if( mt_tick_function ) 
00188             return mt_tick_function(request_time, actual_time, mt_user_data);
00189         else
00190             return true;
00191     };
00192 
00195     void SetInterval( float interval ) { mt_interval = interval; };
00196     
00198     float GetInterval() const { return mt_interval; };
00199     
00204     void SetStyle( HTCStyle style ) { mt_style = style; };
00205     
00207     HTCStyle GetStyle() const { return mt_style; };
00208     
00212     void SetNextRequest( float nr ) { mt_next_request = nr; };
00213     
00215     float GetNextRequest() const { return mt_next_request; };
00216     
00220     int  GetPriority() const { return mt_priority; };
00221     
00225     void SetPriorityLowest() { mt_priority = -1; };
00226     
00230     void SetUserData( void* user_data ) { mt_user_data = user_data; };
00231     
00233     void* GetUserData() const { return mt_user_data; };
00234     
00238     void SetTickFunction( HTClientTickFunction tick_function) { mt_tick_function = tick_function; };
00239     
00241     HTClientTickFunction GetTickFunction() const { return mt_tick_function; };
00242 
00243 protected:
00245     HTCStyle mt_style;                      
00246 
00250     float mt_interval;        
00251 
00253     float mt_next_request;                  
00254 
00258     int mt_priority;                        
00259 
00261     void* mt_user_data;                     
00262     
00265     HTClientTickFunction mt_tick_function;  
00266 };
00267 
00268 
00269 
00270 #ifdef H_PACK_8
00271 #pragma pack(pop)
00272 #endif
00273 
00274 #endif
00275 
00276 
00277 
00278