00001
00002
00003 #ifndef GAME_PLAYING_CSASTOPWATCH_H
00004 #define GAME_PLAYING_CSASTOPWATCH_H
00005
00006 #include <sys/time.h>
00007
00008 namespace osl
00009 {
00010 namespace game_playing
00011 {
00012 class CsaStopwatch
00013 {
00014 timeval start;
00015 public:
00016 CsaStopwatch()
00017 {
00018 gettimeofday(&start, 0);
00019 }
00020 int read() {
00021 timeval current;
00022 gettimeofday(¤t, 0);
00023 int ret = current.tv_sec - start.tv_sec;
00024 if (current.tv_usec < start.tv_usec)
00025 --ret;
00026 if (ret == 0)
00027 ret = 1;
00028 return ret;
00029 }
00030 };
00031 }
00032 }
00033
00034
00035 #endif
00036
00037
00038
00039