ITimer.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. #pragma once
  5. #include "IReferenceCounted.h"
  6. namespace irr
  7. {
  8. //! Interface for getting and manipulating the virtual time
  9. class ITimer : public virtual IReferenceCounted
  10. {
  11. public:
  12. //! Returns current real time in milliseconds of the system.
  13. /** This value does not start with 0 when the application starts.
  14. For example in one implementation the value returned could be the
  15. amount of milliseconds which have elapsed since the system was started.
  16. */
  17. virtual u32 getRealTime() const = 0;
  18. //! Returns current virtual time in milliseconds.
  19. /** This value starts with 0 and can be manipulated using setTime(),
  20. stopTimer(), startTimer(), etc. This value depends on the set speed of
  21. the timer if the timer is stopped, etc. If you need the system time,
  22. use getRealTime() */
  23. virtual u32 getTime() const = 0;
  24. //! sets current virtual time
  25. virtual void setTime(u32 time) = 0;
  26. //! Stops the virtual timer.
  27. /** The timer is reference counted, which means everything which calls
  28. stop() will also have to call start(), otherwise the timer may not
  29. start/stop correctly again. */
  30. virtual void stop() = 0;
  31. //! Starts the virtual timer.
  32. /** The timer is reference counted, which means everything which calls
  33. stop() will also have to call start(), otherwise the timer may not
  34. start/stop correctly again. */
  35. virtual void start() = 0;
  36. //! Sets the speed of the timer
  37. /** The speed is the factor with which the time is running faster or
  38. slower then the real system time. */
  39. virtual void setSpeed(f32 speed = 1.0f) = 0;
  40. //! Returns current speed of the timer
  41. /** The speed is the factor with which the time is running faster or
  42. slower then the real system time. */
  43. virtual f32 getSpeed() const = 0;
  44. //! Returns if the virtual timer is currently stopped
  45. virtual bool isStopped() const = 0;
  46. //! Advances the virtual time
  47. /** Makes the virtual timer update the time value based on the real
  48. time. This is called automatically when calling IrrlichtDevice::run(),
  49. but you can call it manually if you don't use this method. */
  50. virtual void tick() = 0;
  51. };
  52. } // end namespace irr