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 https://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 "mitkLinuxRealTimeClock.h" 00019 00020 #include <sys/time.h> 00021 00022 00026 mitk::LinuxRealTimeClock::LinuxRealTimeClock() 00027 { 00028 } 00029 00033 mitk::LinuxRealTimeClock::~LinuxRealTimeClock() 00034 { 00035 } 00036 00045 double mitk::LinuxRealTimeClock::GetCurrentStamp() 00046 { 00047 struct timeval tval; 00048 00049 if ( ::gettimeofday( &tval, 0 )!= 0 ) 00050 { 00051 itkGenericOutputMacro("gettimeofday-method could not successfully acquire the current time"); 00052 return -1; 00053 } 00054 double milliseconds; 00055 00056 milliseconds = static_cast< double >( tval.tv_sec ) + 00057 static_cast< double >( tval.tv_usec ) / 1e6; 00058 00059 return milliseconds*1000; // in milliseconds 00060 }