00001 
00002 
00003 
00004 
00005 
00006 
00007 #ifndef POSIX_TIMER_HH
00008 #define POSIX_TIMER_HH
00009 
00010 #ifndef INCLUDED_THREAD_LOCK_HH
00011 #include "Thread/LockFwd.hh"
00012 #endif
00013 
00014 
00015 namespace fatalmind {
00016     template <class TMTS, class TM> class timer;
00017 
00018     class nopTimer;
00019 }
00020 
00021 
00022 #ifndef POSIX_TIME_HH
00023 #include "POSIX/time.hh"
00024 #endif
00025 
00026 #include <time.h>
00027 
00028 
00029 namespace fatalmind {
00030 
00031 
00032 
00033 template<class TMTS, class TM>
00034 class timer {
00035     public:
00036         timer(POSIX::timespec<TMTS>& tm, bool start);
00037         ~timer();
00038 
00039         void start();
00040         void stop();
00041 
00042         
00043     private:
00044         timer(timer&); 
00045         void getRealTime(POSIX::timespec<TM>* tm);
00046 
00047 
00048         POSIX::timespec<TM> _start;
00049         POSIX::timespec<TMTS>& _tm;
00050         bool _running;
00051 };
00052 
00053 class nopTimer {
00054     public:
00055         inline nopTimer(int i, bool start) {
00056         }
00057         inline ~nopTimer() {};
00058 
00059         inline void start() {};
00060         inline void stop() {};
00061     private:
00062         nopTimer(nopTimer&); 
00063 };
00064 
00065 
00066 
00067 } 
00068 
00069 
00070 #endif
00071