ITimer.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. // Copyright (C) 2002-2012 Nikolaus Gebhardt
  2. // This file is part of the "Irrlicht Engine".
  3. // For conditions of distribution and use, see copyright notice in irrlicht.h
  4. #ifndef IRR_I_TIMER_H_INCLUDED
  5. #define IRR_I_TIMER_H_INCLUDED
  6. #include "IReferenceCounted.h"
  7. namespace irr
  8. {
  9. //! Interface for getting and manipulating the virtual time
  10. class ITimer : public virtual IReferenceCounted
  11. {
  12. public:
  13. //! Returns current real time in milliseconds of the system.
  14. /** This value does not start with 0 when the application starts.
  15. For example in one implementation the value returned could be the
  16. amount of milliseconds which have elapsed since the system was started.
  17. */
  18. virtual u32 getRealTime() const = 0;
  19. enum EWeekday
  20. {
  21. EWD_SUNDAY=0,
  22. EWD_MONDAY,
  23. EWD_TUESDAY,
  24. EWD_WEDNESDAY,
  25. EWD_THURSDAY,
  26. EWD_FRIDAY,
  27. EWD_SATURDAY
  28. };
  29. struct RealTimeDate
  30. {
  31. // Hour of the day, from 0 to 23
  32. u32 Hour;
  33. // Minute of the hour, from 0 to 59
  34. u32 Minute;
  35. // Second of the minute, due to extra seconds from 0 to 61
  36. u32 Second;
  37. // Year of the Gregorian calendar
  38. s32 Year;
  39. // Month of the year, from 1 to 12
  40. u32 Month;
  41. // Day of the month, from 1 to 31
  42. u32 Day;
  43. // Weekday for the current day
  44. EWeekday Weekday;
  45. // Day of the year, from 1 to 366
  46. u32 Yearday;
  47. // Whether daylight saving is on
  48. bool IsDST;
  49. };
  50. virtual RealTimeDate getRealTimeAndDate() const = 0;
  51. //! Returns current virtual time in milliseconds.
  52. /** This value starts with 0 and can be manipulated using setTime(),
  53. stopTimer(), startTimer(), etc. This value depends on the set speed of
  54. the timer if the timer is stopped, etc. If you need the system time,
  55. use getRealTime() */
  56. virtual u32 getTime() const = 0;
  57. //! sets current virtual time
  58. virtual void setTime(u32 time) = 0;
  59. //! Stops the virtual timer.
  60. /** The timer is reference counted, which means everything which calls
  61. stop() will also have to call start(), otherwise the timer may not
  62. start/stop correctly again. */
  63. virtual void stop() = 0;
  64. //! Starts the virtual timer.
  65. /** The timer is reference counted, which means everything which calls
  66. stop() will also have to call start(), otherwise the timer may not
  67. start/stop correctly again. */
  68. virtual void start() = 0;
  69. //! Sets the speed of the timer
  70. /** The speed is the factor with which the time is running faster or
  71. slower then the real system time. */
  72. virtual void setSpeed(f32 speed = 1.0f) = 0;
  73. //! Returns current speed of the timer
  74. /** The speed is the factor with which the time is running faster or
  75. slower then the real system time. */
  76. virtual f32 getSpeed() const = 0;
  77. //! Returns if the virtual timer is currently stopped
  78. virtual bool isStopped() const = 0;
  79. //! Advances the virtual time
  80. /** Makes the virtual timer update the time value based on the real
  81. time. This is called automatically when calling IrrlichtDevice::run(),
  82. but you can call it manually if you don't use this method. */
  83. virtual void tick() = 0;
  84. };
  85. } // end namespace irr
  86. #endif