[5789] | 1 | /* |
---|
| 2 | ----------------------------------------------------------------------------- |
---|
| 3 | This source file is part of OGRE |
---|
| 4 | (Object-oriented Graphics Rendering Engine) |
---|
| 5 | For the latest info, see http://www.ogre3d.org/ |
---|
| 6 | |
---|
| 7 | Copyright (c) 2000-2006 Torus Knot Software Ltd |
---|
| 8 | Also see acknowledgements in Readme.html |
---|
| 9 | |
---|
| 10 | This program is free software; you can redistribute it and/or modify it under |
---|
| 11 | the terms of the GNU Lesser General Public License as published by the Free Software |
---|
| 12 | Foundation; either version 2 of the License, or (at your option) any later |
---|
| 13 | version. |
---|
| 14 | |
---|
| 15 | This program is distributed in the hope that it will be useful, but WITHOUT |
---|
| 16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
---|
| 17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
---|
| 18 | |
---|
| 19 | You should have received a copy of the GNU Lesser General Public License along with |
---|
| 20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
---|
| 21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to |
---|
| 22 | http://www.gnu.org/copyleft/lesser.txt. |
---|
| 23 | |
---|
| 24 | You may alternatively use this source under the terms of a specific version of |
---|
| 25 | the OGRE Unrestricted License provided you have obtained such a license from |
---|
| 26 | Torus Knot Software Ltd. |
---|
| 27 | ----------------------------------------------------------------------------- |
---|
| 28 | */ |
---|
| 29 | #ifndef __Win32Timer_H__ |
---|
| 30 | #define __Win32Timer_H__ |
---|
| 31 | |
---|
| 32 | #include <ctime> |
---|
| 33 | |
---|
| 34 | #ifndef WIN32_LEAN_AND_MEAN |
---|
| 35 | # define WIN32_LEAN_AND_MEAN |
---|
| 36 | #endif |
---|
| 37 | #include "windows.h" |
---|
| 38 | |
---|
| 39 | //Get around Windows hackery |
---|
| 40 | #ifdef max |
---|
| 41 | # undef max |
---|
| 42 | #endif |
---|
| 43 | #ifdef min |
---|
| 44 | # undef min |
---|
| 45 | #endif |
---|
| 46 | |
---|
| 47 | namespace Ogre |
---|
| 48 | { |
---|
| 49 | class _OgreExport Timer |
---|
| 50 | { |
---|
| 51 | private: |
---|
| 52 | clock_t mZeroClock; |
---|
| 53 | |
---|
| 54 | DWORD mStartTick; |
---|
| 55 | LONGLONG mLastTime; |
---|
| 56 | LARGE_INTEGER mStartTime; |
---|
| 57 | LARGE_INTEGER mFrequency; |
---|
| 58 | |
---|
| 59 | DWORD mTimerMask; |
---|
| 60 | public: |
---|
| 61 | /** Timer constructor. MUST be called on same thread that calls getMilliseconds() */ |
---|
| 62 | Timer(); |
---|
| 63 | ~Timer(); |
---|
| 64 | |
---|
| 65 | /** Method for setting a specific option of the Timer. These options are usually |
---|
| 66 | specific for a certain implementation of the Timer class, and may (and probably |
---|
| 67 | will) not exist across different implementations. reset() must be called after |
---|
| 68 | all setOption() calls. |
---|
| 69 | @par |
---|
| 70 | Current options supported are: |
---|
| 71 | <ul><li>"QueryAffinityMask" (DWORD): Set the thread affinity mask to be used |
---|
| 72 | to check the timer. If 'reset' has been called already this mask should |
---|
| 73 | overlap with the process mask that was in force at that point, and should |
---|
| 74 | be a power of two (a single core).</li></ul> |
---|
| 75 | @param |
---|
| 76 | strKey The name of the option to set |
---|
| 77 | @param |
---|
| 78 | pValue A pointer to the value - the size should be calculated by the timer |
---|
| 79 | based on the key |
---|
| 80 | @return |
---|
| 81 | On success, true is returned. |
---|
| 82 | @par |
---|
| 83 | On failure, false is returned. |
---|
| 84 | */ |
---|
| 85 | bool setOption( const String& strKey, const void* pValue ); |
---|
| 86 | |
---|
| 87 | /** Resets timer */ |
---|
| 88 | void reset(); |
---|
| 89 | |
---|
| 90 | /** Returns milliseconds since initialisation or last reset */ |
---|
| 91 | unsigned long getMilliseconds(); |
---|
| 92 | |
---|
| 93 | /** Returns microseconds since initialisation or last reset */ |
---|
| 94 | unsigned long getMicroseconds(); |
---|
| 95 | |
---|
| 96 | /** Returns milliseconds since initialisation or last reset, only CPU time measured */ |
---|
| 97 | unsigned long getMillisecondsCPU(); |
---|
| 98 | |
---|
| 99 | /** Returns microseconds since initialisation or last reset, only CPU time measured */ |
---|
| 100 | unsigned long getMicrosecondsCPU(); |
---|
| 101 | }; |
---|
| 102 | } |
---|
| 103 | #endif |
---|