Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
SecurityCam - Timer.h

Timer.h

Caricato da: Carlduke
Scarica il programma completo

  1. #ifndef TIMER_H
  2.  #define TIMER_H
  3.  
  4. #include <Windows.h>
  5. #include <iostream>
  6. #include <time.h>
  7.  
  8. #include "Thread.h"
  9.  
  10. class Timer
  11. {
  12.    public :
  13.            Timer();
  14.            ~Timer();
  15.  
  16.            float time_shift;
  17.            bool started;
  18.  
  19.            void start();
  20.            void stop();
  21.            void restart();
  22.  
  23. #ifdef WIN32
  24.            SYSTEMTIME get_time(){ return _time; };
  25. #endif
  26.            int get_seconds();
  27.            float get_milliseconds();
  28.            int delta_time(int t1,int t0);
  29.  
  30.    protected :
  31. #ifdef WIN32
  32.            SYSTEMTIME _time;  
  33. #endif
  34.            int second_elapsed;
  35.            time_t second_from_1970;
  36.  
  37.            Thread<Timer> *timer_thread;
  38.          
  39.            friend DWORD get_update(void *data)
  40.            {
  41.                    Timer *t = (Timer*)data;
  42.                    return t->update();
  43.            }
  44.          
  45.            
  46.            int update();
  47. };
  48.  
  49. #endif