Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkWindowsRealTimeClock.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
18 
19 #include "windows.h"
20 
21 
26 {
27  SetFrequency();
28 }
29 
34 {
35 
36 }
37 
39 {
40  if ( !QueryPerformanceFrequency(&m_Frequency) )
41  {
42  m_Frequency.QuadPart = 0;
43  }
44 }
45 
50 {
51 // "if defined" not really necessary in this case, as the class is only available on Windows-systems
52  __int64 time, ticks = 0;
53 
54  if (m_Frequency.QuadPart < 1)
55  {
56  return -1.0;
57  }
58 
59  QueryPerformanceCounter( (LARGE_INTEGER*) &ticks);
60  time = (ticks * 100000) / this->m_Frequency.QuadPart;
61  double milliseconds = (double) (time & 0xffffffff);
62  milliseconds /= (double)100.0;
63  return milliseconds;
64 }
65 
70 {
71  return this->m_Frequency;
72 }
virtual LARGE_INTEGER GetFrequency()
returns the QueryPerformanceFrequency
virtual double GetCurrentStamp()
returns the current time in milliseconds as a double
virtual ~WindowsRealTimeClock()
basic destructor