00001
00002 Copyright (c) 2001, Lee Patterson & Ant Works Software
00003 http://ssobjects.sourceforge.net
00004
00005 created : September 4, 2001
00006 filename : stopwatch.h
00007 author : Lee Patterson (lee@antws.com)
00008
00009 *********************************************************************/
00010
00011 #ifndef STOPWATCH_H
00012 #define STOPWATCH_H
00013
00014 #ifdef _WIN32
00015 # include "gettimeofday.h"
00016 #else
00017 # include <sys/time.h>
00018 #endif
00019
00020 #include "ssobjects.h"
00021
00022 namespace ssobjects
00023 {
00024
00034 class StopWatch
00035 {
00036 private:
00037 bool m_bRunning;
00038 struct timeval m_tvStart;
00039 struct timeval m_tvStop;
00040
00041 public:
00042 StopWatch();
00043 void start();
00044 void stop();
00045 void reset();
00046
00047 bool isRunning() const;
00048 unsigned32 milliseconds() const;
00049 unsigned32 seconds() const;
00050
00051 private:
00052 unsigned32 elapsedMSecs(const struct timeval* pFrom,const struct timeval* pTo) const;
00053 unsigned32 elapsedSeconds(const struct timeval* pFrom,const struct timeval* pTo) const;
00054 };
00055
00056 };
00057
00058 #endif