00001 /* -*- C++ -*- */ 00002 00003 /* COPYRIGHT 00004 * 00005 * This file is part of the Visual Effects Engine - VEE 00006 * 00007 * Read the "VEE-LICENSE" file for the license. 00008 * 00009 * Authors & Copyright: 00010 * 00011 * Tommi Ilmonen, Tuukka Heikura, Marko Myllymaa and 00012 * Janne Kontkanen 2001-2004 00013 * 00014 * Additional copyrights: Tekes 2003-2004 00015 * 00016 * firstname.lastname@hut.fi 00017 * 00018 */ 00019 00020 #ifndef VEE_TIME_H 00021 #define VEE_TIME_H 00022 00023 #include <sys/time.h> 00024 00025 class VEE_Time 00026 { 00027 public: 00028 VEE_Time() {} 00029 ~VEE_Time() {} 00030 00031 void getTimeOfDay() { gettimeofday(&m_tv, 0); } 00032 00033 double secsTo(const VEE_Time &t) const 00034 { 00035 return t.m_tv.tv_sec - m_tv.tv_sec + 00036 (t.m_tv.tv_usec - m_tv.tv_usec) / 1000000.0; 00037 } 00038 00039 uint usecsTo(const VEE_Time &t) const 00040 { 00041 return (t.m_tv.tv_sec - m_tv.tv_sec) * 1000000 + 00042 t.m_tv.tv_usec - m_tv.tv_usec; 00043 } 00044 00045 double secsSince() const 00046 { VEE_Time tmp; tmp.getTimeOfDay(); return secsTo(tmp); } 00047 00048 long usecs() const { return m_tv.tv_sec * 1000000 + m_tv.tv_usec; } 00049 00050 protected: 00051 struct timeval m_tv; 00052 }; 00053 00054 #endif