00001 #ifndef BCTIMER_H 00002 #define BCTIMER_H 00003 00004 #include <stdint.h> 00005 #include <sys/time.h> 00006 00007 00008 class Timer 00009 { 00010 public: 00011 Timer(); 00012 virtual ~Timer(); 00013 00014 // set last update to now 00015 int update(); 00016 00017 // get difference between now and last update in milliseconds 00018 // must be positive or error results 00019 int64_t get_difference(struct timeval *result); // also stores in timeval 00020 int64_t get_difference(); 00021 00022 // get difference in arbitrary units between now and last update 00023 int64_t get_scaled_difference(long denominator); 00024 static int delay(long milliseconds); 00025 00026 private: 00027 struct timeval current_time; 00028 struct timeval new_time; 00029 struct timeval delay_duration; 00030 }; 00031 00032 00033 00034 #endif
1.5.5