Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

Timer.cpp

00001 /*************************************************************************** 00002 * This file is part of OpenCAL: Open Computer Animation Library * 00003 * I created OpenCAL as my master's thesis Computer Science (multimedia) * 00004 * at the tUL university in Diepenbeek, Belgium * 00005 * * 00006 * Copyright (C) 2003-2004 by Jeroen Dierckx * 00007 * jeroen.dierckx@student.luc.ac.be * 00008 * * 00009 ***************************************************************************/ 00010 00011 // Includes 00012 #include "Timer.h" 00013 using namespace OpenCAL::Utils; 00014 00015 #ifndef WIN32 // Only in linux 00016 #include <sys/time.h> 00017 #include <unistd.h> 00018 #endif // WIN32 00019 00020 using namespace std; 00021 00022 00023 /****************************** 00024 * Constructors and destructor * 00025 ******************************/ 00026 00027 Timer::Timer() 00028 { 00029 } 00030 00031 Timer::~Timer() 00032 { 00033 } 00034 00035 00036 /************************ 00037 * Get and set functions * 00038 ************************/ 00039 00040 unsigned int Timer::getCurrentTime() 00041 { 00042 #ifdef WIN32 // Only in windows 00043 return GetTickCount(); 00044 #else // Linux 00045 struct timeval currentTime; 00046 gettimeofday(&currentTime, 0); 00047 return currentTime.tv_sec * 1000 + currentTime.tv_usec / 1000; 00048 #endif // WIN32 00049 } 00050 00051 void Timer::wait(unsigned int milliSeconds) 00052 { 00053 #ifdef WIN32 // Only in windows 00054 Sleep(milliSeconds); 00055 #else // Linux 00056 usleep(milliSeconds * 1000); 00057 #endif // WIN32 00058 }

Generated on Sun Aug 15 19:19:23 2004 for OpenCAL: Open Computer Animation Library by doxygen 1.3.8