00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date: 2009-02-10 18:08:54 +0100 (Di, 10 Feb 2009) $ 00006 Version: $Revision: 16228 $ 00007 00008 Copyright (c) German Cancer Research Center, Division of Medical and 00009 Biological Informatics. All rights reserved. 00010 See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 #include "mitkWindowsRealTimeClock.h" 00019 00020 #include "windows.h" 00021 00022 00026 mitk::WindowsRealTimeClock::WindowsRealTimeClock() 00027 { 00028 SetFrequency(); 00029 } 00030 00034 mitk::WindowsRealTimeClock::~WindowsRealTimeClock() 00035 { 00036 00037 } 00038 00039 void mitk::WindowsRealTimeClock::SetFrequency() 00040 { 00041 if ( !QueryPerformanceFrequency(&m_Frequency) ) 00042 { 00043 m_Frequency.QuadPart = 0; 00044 } 00045 } 00046 00050 double mitk::WindowsRealTimeClock::GetCurrentStamp() 00051 { 00052 // "if defined" not really necessary in this case, as the class is only available on Windows-systems 00053 __int64 time, ticks = 0; 00054 00055 if (m_Frequency.QuadPart < 1) 00056 { 00057 return -1.0; 00058 } 00059 00060 QueryPerformanceCounter( (LARGE_INTEGER*) &ticks); 00061 time = (ticks * 100000) / this->m_Frequency.QuadPart; 00062 double milliseconds = (double) (time & 0xffffffff); 00063 milliseconds /= (double)100.0; 00064 return milliseconds; 00065 } 00066 00070 LARGE_INTEGER mitk::WindowsRealTimeClock::GetFrequency() 00071 { 00072 return this->m_Frequency; 00073 } 00074 00075 00076