00001 /* 00002 * timer.h 00003 * 00004 * Created on: Jan 24, 2012 00005 * Author: sushil 00006 */ 00007 00008 #ifndef TIMER_H_ 00009 #define TIMER_H_ 00010 00011 #include <boost/date_time/posix_time/posix_time.hpp> 00012 using namespace boost::posix_time; 00013 #include <utils.h> 00014 00015 namespace FastEcslent { 00016 00017 00018 class MilliSecondTimer { 00019 private: 00020 00021 ptime start; 00022 time_duration diff; 00023 float interval; 00024 ptime current; 00025 00026 public: 00027 MilliSecondTimer(float inter) { 00028 start = getCurrentTime(); 00029 interval = inter; 00030 } 00031 00032 bool hasFired(){ 00033 current = getCurrentTime(); 00034 diff = current - start; 00035 if (diff.total_milliseconds() > interval) { 00036 start = current; 00037 return true; 00038 } 00039 return false; 00040 } 00041 00042 }; 00043 00044 00045 00046 } 00047 00048 00049 #endif /* TIMER_H_ */