CmTimerImp.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. Copyright (c) 2000-2011 Torus Knot Software Ltd
  7. Permission is hereby granted, free of charge, to any person obtaining a copy
  8. of this software and associated documentation files (the "Software"), to deal
  9. in the Software without restriction, including without limitation the rights
  10. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. copies of the Software, and to permit persons to whom the Software is
  12. furnished to do so, subject to the following conditions:
  13. The above copyright notice and this permission notice shall be included in
  14. all copies or substantial portions of the Software.
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. THE SOFTWARE.
  22. -----------------------------------------------------------------------------
  23. */
  24. #ifndef __OSXTimer_H__
  25. #define __OSXTimer_H__
  26. #include "../CmPrerequisitesUtil.h"
  27. namespace CamelotEngine
  28. {
  29. /** Timer class */
  30. class CM_UTILITY_EXPORT Timer
  31. {
  32. private:
  33. struct timeval start;
  34. clock_t zeroClock;
  35. public:
  36. Timer();
  37. ~Timer();
  38. /** Method for setting a specific option of the Timer. These options are usually
  39. specific for a certain implementation of the Timer class, and may (and probably
  40. will) not exist across different implementations. reset() must be called after
  41. all setOption() calls.
  42. @param
  43. strKey The name of the option to set
  44. @param
  45. pValue A pointer to the value - the size should be calculated by the timer
  46. based on the key
  47. @return
  48. On success, true is returned.
  49. @par
  50. On failure, false is returned.
  51. */
  52. bool setOption( const String& strKey, const void* pValue ) { return false; }
  53. /** Resets timer */
  54. void reset();
  55. /** Returns milliseconds since initialisation or last reset */
  56. unsigned long getMilliseconds();
  57. /** Returns microseconds since initialisation or last reset */
  58. unsigned long getMicroseconds();
  59. /** Returns milliseconds since initialisation or last reset, only CPU time measured */
  60. unsigned long getMillisecondsCPU();
  61. /** Returns microseconds since initialisation or last reset, only CPU time measured */
  62. unsigned long getMicrosecondsCPU();
  63. };
  64. }
  65. #endif