00001 /* 00002 Free Download Manager Copyright (c) 2003-2007 FreeDownloadManager.ORG 00003 Open Download Manager Copyright (c) 2008-2010 OpenDownloadManager.ORG 00004 */ 00005 00006 #ifndef __REFTIME__ 00007 #define __REFTIME__ 00008 00009 const LONGLONG MILLISECONDS = (1000); 00010 const LONGLONG NANOSECONDS = (1000000000); 00011 const LONGLONG UNITS = (NANOSECONDS / 100); 00012 00013 #define MILLISECONDS_TO_100NS_UNITS(lMs) \ 00014 Int32x32To64((lMs), (UNITS / MILLISECONDS)) 00015 00016 class CRefTime 00017 { 00018 public: 00019 00020 REFERENCE_TIME m_time; 00021 00022 inline CRefTime() 00023 { 00024 00025 m_time = 0; 00026 }; 00027 00028 inline CRefTime(LONG msecs) 00029 { 00030 m_time = MILLISECONDS_TO_100NS_UNITS(msecs); 00031 }; 00032 00033 inline CRefTime(REFERENCE_TIME rt) 00034 { 00035 m_time = rt; 00036 }; 00037 00038 inline operator REFERENCE_TIME() const 00039 { 00040 return m_time; 00041 }; 00042 00043 inline CRefTime& operator=(const CRefTime& rt) 00044 { 00045 m_time = rt.m_time; 00046 return *this; 00047 }; 00048 00049 inline CRefTime& operator=(const LONGLONG ll) 00050 { 00051 m_time = ll; 00052 return *this; 00053 }; 00054 00055 inline CRefTime& operator+=(const CRefTime& rt) 00056 { 00057 return (*this = *this + rt); 00058 }; 00059 00060 inline CRefTime& operator-=(const CRefTime& rt) 00061 { 00062 return (*this = *this - rt); 00063 }; 00064 00065 inline LONG Millisecs(void) 00066 { 00067 return (LONG)(m_time / (UNITS / MILLISECONDS)); 00068 }; 00069 00070 inline LONGLONG GetUnits(void) 00071 { 00072 return m_time; 00073 }; 00074 }; 00075 00076 const LONGLONG TimeZero = 0; 00077 00078 #endif 00079
1.5.6